diff graal/com.oracle.truffle.tools.debug.engine/src/com/oracle/truffle/tools/debug/engine/DebugEngine.java @ 21890:894f82515e38

Truffle/APIs and Debugging: Evolutionary steps to integrating debugging and tool support with TruffleVM APIs - Add a version string to language registration: Language.getShortName() produces a string with both language and version - Rename SLMain --> SLLanguage (little change current machinery) - Remove DebugEngine dependence on ExecutionContext: Visualizer access migrated to TruffleLanguage - ExecutionContext now has only one method left: getCompilerOptions() - Rename SourceExecutionProvider to DebugSupportProvider, now supplied by implementing abstract TruffleLanguage.getDebugSupport() - Revise DebugEngine and its helper classes to work with the new APIs
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 09 Jun 2015 15:20:30 -0700
parents c072fbce5756
children
line wrap: on
line diff
--- a/graal/com.oracle.truffle.tools.debug.engine/src/com/oracle/truffle/tools/debug/engine/DebugEngine.java	Fri Jun 05 18:05:13 2015 -0700
+++ b/graal/com.oracle.truffle.tools.debug.engine/src/com/oracle/truffle/tools/debug/engine/DebugEngine.java	Tue Jun 09 15:20:30 2015 -0700
@@ -33,7 +33,8 @@
 import com.oracle.truffle.api.instrument.*;
 import com.oracle.truffle.api.nodes.*;
 import com.oracle.truffle.api.source.*;
-import com.oracle.truffle.tools.debug.engine.SourceExecutionProvider.ExecutionListener;
+import com.oracle.truffle.api.vm.TruffleVM.Language;
+import com.oracle.truffle.tools.debug.engine.DebugExecutionSupport.DebugExecutionListener;
 
 /**
  * Language-agnostic engine for running Truffle languages under debugging control.
@@ -70,12 +71,14 @@
         void addWarning(String warning);
     }
 
+    private final Language language;
+
     /**
      * The client of this engine.
      */
     private final DebugClient debugClient;
 
-    private final SourceExecutionProvider sourceExecutionProvider;
+    private final DebugExecutionSupport executionSupport;
 
     /**
      * Implementation of line-oriented breakpoints.
@@ -94,11 +97,12 @@
 
     /**
      * @param debugClient
-     * @param sourceExecutionProvider
+     * @param language
      */
-    private DebugEngine(DebugClient debugClient, SourceExecutionProvider sourceExecutionProvider) {
+    private DebugEngine(DebugClient debugClient, Language language) {
         this.debugClient = debugClient;
-        this.sourceExecutionProvider = sourceExecutionProvider;
+        this.language = language;
+        this.executionSupport = new DebugExecutionSupport(language.getShortName(), language.getDebugSupport());
 
         Source.setFileCaching(true);
 
@@ -107,7 +111,7 @@
         prepareContinue();
         debugContext.contextTrace("START EXEC DEFAULT");
 
-        sourceExecutionProvider.addExecutionListener(new ExecutionListener() {
+        executionSupport.addExecutionListener(new DebugExecutionListener() {
 
             public void executionStarted(Source source, boolean stepInto) {
                 // Push a new execution context onto stack
@@ -146,13 +150,13 @@
             }
         };
 
-        this.lineBreaks = new LineBreakpointFactory(sourceExecutionProvider, breakpointCallback, warningLog);
+        this.lineBreaks = new LineBreakpointFactory(executionSupport, breakpointCallback, warningLog);
 
-        this.tagBreaks = new TagBreakpointFactory(sourceExecutionProvider, breakpointCallback, warningLog);
+        this.tagBreaks = new TagBreakpointFactory(executionSupport, breakpointCallback, warningLog);
     }
 
-    public static DebugEngine create(DebugClient debugClient, SourceExecutionProvider sourceExecutionProvider) {
-        return new DebugEngine(debugClient, sourceExecutionProvider);
+    public static DebugEngine create(DebugClient debugClient, Language language) {
+        return new DebugEngine(debugClient, language);
     }
 
     /**
@@ -162,7 +166,7 @@
      * @throws DebugException if an unexpected failure occurs
      */
     public void run(Source source, boolean stepInto) throws DebugException {
-        sourceExecutionProvider.run(source, stepInto);
+        executionSupport.run(source, stepInto);
     }
 
     /**
@@ -316,9 +320,11 @@
 
     /**
      * Evaluates code in a halted execution context, at top-level if <code>mFrame==null</code>.
+     *
+     * @throws DebugException
      */
-    public Object eval(Source source, Node node, MaterializedFrame mFrame) {
-        return sourceExecutionProvider.eval(source, node, mFrame);
+    public Object eval(Source source, Node node, MaterializedFrame mFrame) throws DebugException {
+        return executionSupport.evalInContext(source, node, mFrame);
     }
 
     /**
@@ -806,9 +812,7 @@
             if (frames == null) {
                 stream.println("<empty stack>");
             } else {
-                // TODO (mlvdv) get visualizer via the (to be developed) Truffle langauge API
-                final Visualizer visualizer = debugClient.getExecutionContext().getVisualizer();
-
+                final Visualizer visualizer = language.getDebugSupport().getVisualizer();
                 for (FrameDebugDescription frameDesc : frames) {
                     final StringBuilder sb = new StringBuilder("    frame " + Integer.toString(frameDesc.index()));
                     sb.append(":at " + visualizer.displaySourceLocation(frameDesc.node()));