Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/debug/Debugger.java @ 22128:f879b1fe3773
Separating the TruffleVM into its own project makes it possible to cleanup various system parts interations
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Thu, 03 Sep 2015 16:38:45 +0200 |
parents | c2cb9f1c8688 |
children | dc83cc1f94f2 b31dcacfc8ff 3aad794eec0e |
comparison
equal
deleted
inserted
replaced
22127:5a0cccf023c4 | 22128:f879b1fe3773 |
---|---|
32 import com.oracle.truffle.api.frame.*; | 32 import com.oracle.truffle.api.frame.*; |
33 import com.oracle.truffle.api.impl.Accessor; | 33 import com.oracle.truffle.api.impl.Accessor; |
34 import com.oracle.truffle.api.instrument.*; | 34 import com.oracle.truffle.api.instrument.*; |
35 import com.oracle.truffle.api.nodes.*; | 35 import com.oracle.truffle.api.nodes.*; |
36 import com.oracle.truffle.api.source.*; | 36 import com.oracle.truffle.api.source.*; |
37 import com.oracle.truffle.api.vm.TruffleVM; | |
38 | 37 |
39 /** | 38 /** |
40 * Represents debugging related state of a {@link TruffleVM}. Instance of this class is delivered | 39 * Represents debugging related state of a {@link com.oracle.truffle.api.vm.TruffleVM}. Instance of |
41 * via {@link SuspendedEvent#getDebugger()} and {@link ExecutionEvent#getDebugger()} events, once | 40 * this class is delivered via {@link SuspendedEvent#getDebugger()} and |
42 * {@link com.oracle.truffle.api.debug debugging is turned on}. | 41 * {@link ExecutionEvent#getDebugger()} events, once {@link com.oracle.truffle.api.debug debugging |
42 * is turned on}. | |
43 */ | 43 */ |
44 @SuppressWarnings("javadoc") | |
44 public final class Debugger { | 45 public final class Debugger { |
45 | 46 |
46 private static final boolean TRACE = false; | 47 private static final boolean TRACE = false; |
47 private static final String TRACE_PREFIX = "DEBUG ENGINE: "; | 48 private static final String TRACE_PREFIX = "DEBUG ENGINE: "; |
48 | 49 |
55 if (TRACE) { | 56 if (TRACE) { |
56 OUT.println(TRACE_PREFIX + String.format(format, args)); | 57 OUT.println(TRACE_PREFIX + String.format(format, args)); |
57 } | 58 } |
58 } | 59 } |
59 | 60 |
60 private final TruffleVM vm; | 61 private final Object vm; |
61 private Source lastSource; | 62 private Source lastSource; |
62 | 63 |
63 interface BreakpointCallback { | 64 interface BreakpointCallback { |
64 | 65 |
65 /** | 66 /** |
89 /** | 90 /** |
90 * Head of the stack of executions. | 91 * Head of the stack of executions. |
91 */ | 92 */ |
92 private DebugExecutionContext debugContext; | 93 private DebugExecutionContext debugContext; |
93 | 94 |
94 Debugger(TruffleVM vm) { | 95 Debugger(Object vm) { |
95 this.vm = vm; | 96 this.vm = vm; |
96 | 97 |
97 Source.setFileCaching(true); | 98 Source.setFileCaching(true); |
98 | 99 |
99 // Initialize execution context stack | 100 // Initialize execution context stack |
119 | 120 |
120 this.lineBreaks = new LineBreakpointFactory(this, breakpointCallback, warningLog); | 121 this.lineBreaks = new LineBreakpointFactory(this, breakpointCallback, warningLog); |
121 this.tagBreaks = new TagBreakpointFactory(this, breakpointCallback, warningLog); | 122 this.tagBreaks = new TagBreakpointFactory(this, breakpointCallback, warningLog); |
122 } | 123 } |
123 | 124 |
124 TruffleVM vm() { | 125 Object vm() { |
125 return vm; | 126 return vm; |
126 } | 127 } |
127 | 128 |
128 /** | 129 /** |
129 * Sets a breakpoint to halt at a source line. | 130 * Sets a breakpoint to halt at a source line. |
792 } | 793 } |
793 | 794 |
794 @SuppressWarnings("rawtypes") | 795 @SuppressWarnings("rawtypes") |
795 private static final class AccessorDebug extends Accessor { | 796 private static final class AccessorDebug extends Accessor { |
796 @Override | 797 @Override |
797 protected Closeable executionStart(TruffleVM vm, Debugger[] fillIn, Source s) { | 798 protected Closeable executionStart(Object vm, Debugger[] fillIn, Source s) { |
798 final Debugger d; | 799 final Debugger d; |
799 if (fillIn[0] == null) { | 800 if (fillIn[0] == null) { |
800 d = fillIn[0] = new Debugger(vm); | 801 d = fillIn[0] = new Debugger(vm); |
801 } else { | 802 } else { |
802 d = fillIn[0]; | 803 d = fillIn[0]; |
814 protected Class<? extends TruffleLanguage> findLanguage(Probe probe) { | 815 protected Class<? extends TruffleLanguage> findLanguage(Probe probe) { |
815 return super.findLanguage(probe); | 816 return super.findLanguage(probe); |
816 } | 817 } |
817 | 818 |
818 @Override | 819 @Override |
819 protected TruffleLanguage.Env findLanguage(TruffleVM vm, Class<? extends TruffleLanguage> languageClass) { | 820 protected TruffleLanguage.Env findLanguage(Object vm, Class<? extends TruffleLanguage> languageClass) { |
820 return super.findLanguage(vm, languageClass); | 821 return super.findLanguage(vm, languageClass); |
821 } | 822 } |
822 | 823 |
823 @Override | 824 @Override |
824 protected TruffleLanguage<?> findLanguage(TruffleLanguage.Env env) { | 825 protected TruffleLanguage<?> findLanguage(TruffleLanguage.Env env) { |
829 protected DebugSupportProvider getDebugSupport(TruffleLanguage<?> l) { | 830 protected DebugSupportProvider getDebugSupport(TruffleLanguage<?> l) { |
830 return super.getDebugSupport(l); | 831 return super.getDebugSupport(l); |
831 } | 832 } |
832 | 833 |
833 @Override | 834 @Override |
834 protected void dispatchEvent(TruffleVM vm, Object event) { | 835 protected void dispatchEvent(Object vm, Object event) { |
835 super.dispatchEvent(vm, event); | 836 super.dispatchEvent(vm, event); |
836 } | 837 } |
837 } | 838 } |
838 | 839 |
839 // registers into Accessor.DEBUG | 840 // registers into Accessor.DEBUG |