22
22
*/
23
23
package com .oracle .truffle .espresso .jdwp .api ;
24
24
25
+ import com .oracle .truffle .api .TruffleLogger ;
25
26
import com .oracle .truffle .api .debug .DebugScope ;
26
27
import com .oracle .truffle .api .debug .DebugStackFrame ;
27
28
import com .oracle .truffle .api .debug .DebugValue ;
34
35
import com .oracle .truffle .api .interop .UnsupportedMessageException ;
35
36
import com .oracle .truffle .api .nodes .Node ;
36
37
import com .oracle .truffle .api .nodes .RootNode ;
37
- import com .oracle .truffle .espresso .jdwp .impl .DebuggerController ;
38
38
39
39
public final class CallFrame {
40
-
41
40
private static final InteropLibrary INTEROP = InteropLibrary .getFactory ().getUncached ();
42
41
public static final Object INVALID_VALUE = new Object ();
43
42
@@ -53,11 +52,11 @@ public final class CallFrame {
53
52
private final DebugStackFrame debugStackFrame ;
54
53
private final DebugScope debugScope ;
55
54
private final JDWPContext context ;
56
- private final DebuggerController controller ;
57
55
private Object scope ;
56
+ private final TruffleLogger logger ;
58
57
59
58
public CallFrame (long threadId , byte typeTag , long classId , MethodRef method , long methodId , long codeIndex , Frame frame , Node currentNode , RootNode rootNode ,
60
- DebugStackFrame debugStackFrame , JDWPContext context , DebuggerController controller ) {
59
+ DebugStackFrame debugStackFrame , JDWPContext context , TruffleLogger logger ) {
61
60
this .threadId = threadId ;
62
61
this .typeTag = typeTag ;
63
62
this .classId = classId ;
@@ -70,11 +69,12 @@ public CallFrame(long threadId, byte typeTag, long classId, MethodRef method, lo
70
69
this .debugStackFrame = debugStackFrame ;
71
70
this .debugScope = debugStackFrame != null ? debugStackFrame .getScope () : null ;
72
71
this .context = context ;
73
- this .controller = controller ;
72
+ this .logger = logger ;
74
73
}
75
74
76
- public CallFrame (long threadId , byte typeTag , long classId , long methodId , long codeIndex ) {
77
- this (threadId , typeTag , classId , null , methodId , codeIndex , null , null , null , null , null , null );
75
+ // used for tests in comparisons only
76
+ public CallFrame (long threadId , byte typeTag , long classId , long methodId , long codeIndex , TruffleLogger logger ) {
77
+ this (threadId , typeTag , classId , null , methodId , codeIndex , null , null , null , null , null , logger );
78
78
}
79
79
80
80
public byte getTypeTag () {
@@ -124,9 +124,7 @@ public Object getThisValue() {
124
124
}
125
125
return INTEROP .readMember (theScope , "0" );
126
126
} catch (UnsupportedMessageException | UnknownIdentifierException e ) {
127
- if (controller != null ) {
128
- controller .warning (() -> "Unable to read 'this' value from method: " + getMethod () + " with currentNode: " + currentNode .getClass ());
129
- }
127
+ logger .warning (() -> "Unable to read 'this' value from method: " + getMethod () + " with currentNode: " + currentNode .getClass ());
130
128
return INVALID_VALUE ;
131
129
}
132
130
}
@@ -144,9 +142,7 @@ public void setVariable(Object value, String identifier) {
144
142
try {
145
143
INTEROP .writeMember (theScope , identifier , value );
146
144
} catch (Exception e ) {
147
- if (controller != null ) {
148
- controller .warning (() -> "Unable to write member " + identifier + " from variables" );
149
- }
145
+ logger .warning (() -> "Unable to write member " + identifier + " from variables" );
150
146
}
151
147
}
152
148
@@ -164,14 +160,10 @@ private Object getScope() {
164
160
try {
165
161
scope = NodeLibrary .getUncached ().getScope (node , frame , true );
166
162
} catch (UnsupportedMessageException e ) {
167
- if (controller != null ) {
168
- controller .warning (() -> "Unable to get scope for " + currentNode .getClass ());
169
- }
163
+ logger .warning (() -> "Unable to get scope for " + currentNode .getClass ());
170
164
}
171
165
} else {
172
- if (controller != null ) {
173
- controller .warning (() -> "Unable to get scope for " + currentNode .getClass ());
174
- }
166
+ logger .warning (() -> "Unable to get scope for " + currentNode .getClass ());
175
167
}
176
168
return scope ;
177
169
}
0 commit comments