Skip to content

Commit

Permalink
[GR-48600] Support CompilationWrapper.dumpOnError with truffle
Browse files Browse the repository at this point in the history
PullRequest: graal/15646
  • Loading branch information
tkrodriguez committed Sep 25, 2023
2 parents 2ae69a8 + d951f72 commit 69f247b
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.DebugContext.Builder;
import org.graalvm.compiler.debug.DebugContext.Scope;
import org.graalvm.compiler.debug.DebugDumpScope;
import org.graalvm.compiler.debug.DiagnosticsOutputDirectory;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.debug.Indent;
Expand Down Expand Up @@ -540,6 +541,9 @@ private StructuredGraph truffleTier(TruffleCompilationWrapper wrapper, DebugCont
wrapper.compilationId, TruffleTierContext.getSpeculationLog(wrapper), wrapper.task,
handler);

// Save the graph so it can dumped into the graal_diagnostics zip
wrapper.graph = context.graph;

try (Scope s = context.debug.scope("CreateGraph", context.graph);
Indent indent = context.debug.logAndIndent("evaluate %s", context.graph);) {
truffleTier.apply(context.graph, context);
Expand Down Expand Up @@ -676,6 +680,7 @@ final class TruffleCompilationWrapper extends CompilationWrapper<Void> {
final CompilationIdentifier compilationId;
final ExpansionStatistics statistics;
final OptionValues compilerOptions;
StructuredGraph graph;
boolean silent;

private TruffleCompilationWrapper(
Expand All @@ -700,6 +705,18 @@ public String toString() {
return compilable.toString();
}

@SuppressWarnings("try")
@Override
protected void dumpOnError(DebugContext errorContext, Throwable cause) {
if (graph != null) {
try (DebugContext.Scope s = errorContext.scope("DumpOnError", graph, compilationId, new DebugDumpScope("Original failure"))) {
errorContext.forceDump(graph, "Exception: %s", cause);
} catch (Throwable t) {
throw errorContext.handle(t);
}
}
}

@Override
protected ExceptionAction lookupAction(OptionValues options, Throwable cause) {
// Respect current action if it has been explicitly set.
Expand Down

0 comments on commit 69f247b

Please sign in to comment.