Skip to content

Commit d8e84a0

Browse files
committed
Feat : step event handled
1 parent 5113bfe commit d8e84a0

File tree

1 file changed

+56
-21
lines changed

1 file changed

+56
-21
lines changed

mode/src/processing/mode/android/AndroidDebugger.java

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public synchronized void startDebug(AndroidRunner runner, Device device) {
125125
vmBreakPointEvent((BreakpointEvent) e);
126126

127127
} else if (e instanceof StepEvent) {
128+
vmStepEvent(((StepEvent) e));
128129

129130
} else if (e instanceof VMDisconnectEvent) {
130131
stopDebug();
@@ -136,6 +137,32 @@ public synchronized void startDebug(AndroidRunner runner, Device device) {
136137
}
137138
}
138139

140+
private void vmClassPrepareEvent(ClassPrepareEvent ce) {
141+
ReferenceType rt = ce.referenceType();
142+
currentThread = ce.thread();
143+
paused = true; // for now we're paused
144+
145+
if (rt.name().equals(mainClassName)) {
146+
//printType(rt);
147+
mainClass = rt;
148+
classes.add(rt);
149+
// log("main class load: " + rt.name());
150+
started = true; // now that main class is loaded, we're started
151+
} else {
152+
classes.add(rt); // save loaded classes
153+
// log("class load: {0}" + rt.name());
154+
}
155+
156+
// notify listeners
157+
for (ClassLoadListener listener : classLoadListeners) {
158+
if (listener != null) {
159+
listener.classLoaded(rt);
160+
}
161+
}
162+
paused = false; // resuming now
163+
runtime.vm().resume();
164+
}
165+
139166
private void vmBreakPointEvent(BreakpointEvent be) {
140167
currentThread = be.thread(); // save this thread
141168
updateVariableInspector(currentThread); // this is already on the EDT
@@ -162,30 +189,38 @@ private void vmBreakPointEvent(BreakpointEvent be) {
162189
editor.statusHalted();
163190
}
164191

165-
private void vmClassPrepareEvent(ClassPrepareEvent ce) {
166-
ReferenceType rt = ce.referenceType();
167-
currentThread = ce.thread();
168-
paused = true; // for now we're paused
169-
170-
if (rt.name().equals(mainClassName)) {
171-
//printType(rt);
172-
mainClass = rt;
173-
classes.add(rt);
174-
// log("main class load: " + rt.name());
175-
started = true; // now that main class is loaded, we're started
176-
} else {
177-
classes.add(rt); // save loaded classes
178-
// log("class load: {0}" + rt.name());
179-
}
192+
private void vmStepEvent(StepEvent se) {
193+
currentThread = se.thread();
180194

181-
// notify listeners
182-
for (ClassLoadListener listener : classLoadListeners) {
183-
if (listener != null) {
184-
listener.classLoaded(rt);
195+
//printSourceLocation(currentThread);
196+
updateVariableInspector(currentThread); // this is already on the EDT
197+
final LineID newCurrentLine = locationToLineID(se.location());
198+
javax.swing.SwingUtilities.invokeLater(new Runnable() {
199+
@Override
200+
public void run() {
201+
editor.setCurrentLine(newCurrentLine);
202+
editor.deactivateStep();
203+
editor.deactivateContinue();
185204
}
205+
});
206+
207+
// delete the steprequest that triggered this step so new ones can be placed (only one per thread)
208+
EventRequestManager mgr = runtime.vm().eventRequestManager();
209+
mgr.deleteEventRequest(se.request());
210+
requestedStep = null; // mark that there is no step request pending
211+
paused = true;
212+
editor.statusHalted();
213+
214+
// disallow stepping into invisible lines
215+
if (!locationIsVisible(se.location())) {
216+
// TODO: this leads to stepping, should it run on the EDT?
217+
javax.swing.SwingUtilities.invokeLater(new Runnable() {
218+
@Override
219+
public void run() {
220+
stepOutIntoViewOrContinue();
221+
}
222+
});
186223
}
187-
paused = false; // resuming now
188-
runtime.vm().resume();
189224
}
190225

191226
@Override public synchronized void continueDebug() {

0 commit comments

Comments
 (0)