Skip to content

Commit 84e83e0

Browse files
committedMar 19, 2025·
disable ObjdumpDisassemblerProvider in libgraal
1 parent 6a42915 commit 84e83e0

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed
 

‎compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/code/ObjdumpDisassemblerProvider.java

+30-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
import java.util.regex.Pattern;
3737

3838
import jdk.graal.compiler.code.CompilationResult.CodeAnnotation;
39+
import jdk.graal.compiler.core.common.NativeImageSupport;
40+
import jdk.graal.compiler.debug.GraalError;
41+
import jdk.graal.compiler.debug.TTY;
3942
import jdk.graal.compiler.options.Option;
4043
import jdk.graal.compiler.options.OptionKey;
4144
import jdk.graal.compiler.options.OptionType;
@@ -91,6 +94,9 @@ public boolean isAvailable(OptionValues options) {
9194

9295
@Override
9396
public String disassembleCompiledCode(OptionValues options, CodeCacheProvider codeCache, CompilationResult compResult) {
97+
if (NativeImageSupport.inRuntimeCode() && !ENABLE_OBJDUMP) {
98+
throw new GraalError("Objdump not available");
99+
}
94100
String objdump = getObjdump(options);
95101
if (objdump == null) {
96102
return null;
@@ -206,13 +212,36 @@ public static String quoteShellArg(String arg) {
206212
return "'" + arg.replace("'", "'\"'\"'") + "'";
207213
}
208214

215+
private static final String ENABLE_OBJDUMP_PROP = "debug.jdk.graal.enableObjdump";
216+
217+
/**
218+
* Support for objdump is excluded by default from native images (including libgraal) to reduce
219+
* the image size. It also reduces security concerns related to running subprocesses.
220+
*
221+
* To objdump during development, set the {@value #ENABLE_OBJDUMP_PROP} system property to true
222+
* when building native images.
223+
*/
224+
private static final boolean ENABLE_OBJDUMP = Boolean.parseBoolean(GraalServices.getSavedProperty(ENABLE_OBJDUMP_PROP));
225+
226+
private static boolean objdumpUnsupportedWarned;
227+
209228
/**
210229
* Searches for a valid GNU objdump executable.
211230
*/
212-
private String getObjdump(OptionValues options) {
231+
private static String getObjdump(OptionValues options) {
213232
// for security, user must provide the possible objdump locations.
214233
String candidates = Options.ObjdumpExecutables.getValue(options);
215234
if (candidates != null && !candidates.isEmpty()) {
235+
if (NativeImageSupport.inRuntimeCode() && !ENABLE_OBJDUMP) {
236+
if (!objdumpUnsupportedWarned) {
237+
// Ignore races or multiple isolates - an extra warning is ok
238+
objdumpUnsupportedWarned = true;
239+
TTY.printf("WARNING: Objdump not supported as the %s system property was false when building.%n",
240+
ENABLE_OBJDUMP_PROP);
241+
}
242+
return null;
243+
}
244+
216245
for (String candidate : candidates.split(",")) {
217246
synchronized (objdumpCache) {
218247
// first checking to see if a cached verdict for this candidate exists.

‎compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/debug/IgvDumpChannel.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ final class IgvDumpChannel implements WritableByteChannel {
5050
private static final String ENABLE_NETWORK_DUMPING_PROP = "debug.jdk.graal.enableNetworkDumping";
5151

5252
/**
53-
* Support for IGV dumping to a network port is excluded by default from libgraal to reduce the
54-
* libgraal image size. It also reduces security concerns related to opening random network
55-
* connections.
53+
* Support for IGV dumping to a network port is excluded by default from native images
54+
* (including libgraal) to reduce the image size. It also reduces security concerns related to
55+
* opening random network connections.
5656
*
57-
* To enable IGV dumping to the network during libgraal based development, set the
58-
* {@value #ENABLE_NETWORK_DUMPING_PROP} system property to true when building libgraal.
57+
* To enable IGV dumping to the network during development, set the
58+
* {@value #ENABLE_NETWORK_DUMPING_PROP} system property to true when building native images.
5959
*/
6060
private static final boolean ENABLE_NETWORK_DUMPING = Boolean.parseBoolean(GraalServices.getSavedProperty(ENABLE_NETWORK_DUMPING_PROP));
6161

@@ -107,7 +107,7 @@ WritableByteChannel channel() throws IOException {
107107
if (!networkDumpingUnsupportedWarned) {
108108
// Ignore races or multiple isolates - an extra warning is ok
109109
networkDumpingUnsupportedWarned = true;
110-
TTY.printf("WARNING: Graph dumping to network not supported as the %s system property was false when building libgraal - dumping to file instead.%n",
110+
TTY.printf("WARNING: Graph dumping to network not supported as the %s system property was false when building - dumping to file instead.%n",
111111
ENABLE_NETWORK_DUMPING_PROP);
112112
}
113113
sharedChannel = createFileChannel(pathProvider, null);

0 commit comments

Comments
 (0)
Please sign in to comment.