Skip to content

Commit

Permalink
Make linking of shim DLLs traceable
Browse files Browse the repository at this point in the history
  • Loading branch information
pejovica committed Mar 5, 2021
1 parent 2ea2843 commit 01d91a4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.Arrays;
import java.util.List;

import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.nativeimage.ImageSingletons;

import com.oracle.svm.core.SubstrateOptions;
Expand Down Expand Up @@ -117,17 +118,32 @@ public static ProcessBuilder prepareCommand(List<String> args, Path commandDir)
}

public static void traceCommand(ProcessBuilder command) {
if (SubstrateOptions.TraceNativeToolUsage.getValue()) {
if (isTraceEnabled()) {
String commandLine = SubstrateUtil.getShellCommandString(command.command(), false);
System.out.printf(">> %s%n", commandLine);
trace(">> %s", commandLine);
}
}

public static void traceCommandOutput(List<String> lines) {
if (SubstrateOptions.TraceNativeToolUsage.getValue()) {
if (isTraceEnabled()) {
for (String line : lines) {
System.out.printf("># %s%n", line);
trace("># %s", line);
}
}
}

private static boolean isTraceEnabled() {
return SubstrateOptions.TraceNativeToolUsage.getValue() ||
DebugContext.forCurrentThread().isLogEnabled(DebugContext.VERBOSE_LEVEL);
}

private static void trace(String format, String arg) {
assert isTraceEnabled();
DebugContext debug = DebugContext.forCurrentThread();
if (debug.isLogEnabled(DebugContext.VERBOSE_LEVEL)) {
debug.log(format, arg);
} else {
System.out.printf(format + "%n", arg);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.concurrent.ConcurrentMap;

import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.DebugContext.Activation;
import org.graalvm.compiler.debug.DebugContext.Scope;
import org.graalvm.compiler.debug.Indent;
import org.graalvm.compiler.nodes.ValueNode;
Expand Down Expand Up @@ -238,7 +239,8 @@ private void makeShimDLL(String shimName) {
}

DebugContext debug = accessImpl.getDebugContext();
try (Scope s = debug.scope("link")) {
try (Scope s = debug.scope("link");
Activation a = debug.activate()) {
if (FileUtils.executeCommand(linkerCommand) != 0) {
VMError.shouldNotReachHere();
}
Expand Down

0 comments on commit 01d91a4

Please sign in to comment.