@@ -125,6 +125,7 @@ public synchronized void startDebug(AndroidRunner runner, Device device) {
125
125
vmBreakPointEvent ((BreakpointEvent ) e );
126
126
127
127
} else if (e instanceof StepEvent ) {
128
+ vmStepEvent (((StepEvent ) e ));
128
129
129
130
} else if (e instanceof VMDisconnectEvent ) {
130
131
stopDebug ();
@@ -136,6 +137,32 @@ public synchronized void startDebug(AndroidRunner runner, Device device) {
136
137
}
137
138
}
138
139
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
+
139
166
private void vmBreakPointEvent (BreakpointEvent be ) {
140
167
currentThread = be .thread (); // save this thread
141
168
updateVariableInspector (currentThread ); // this is already on the EDT
@@ -162,30 +189,38 @@ private void vmBreakPointEvent(BreakpointEvent be) {
162
189
editor .statusHalted ();
163
190
}
164
191
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 ();
180
194
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 ();
185
204
}
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
+ });
186
223
}
187
- paused = false ; // resuming now
188
- runtime .vm ().resume ();
189
224
}
190
225
191
226
@ Override public synchronized void continueDebug () {
0 commit comments