Fix breakpoint handling
This commit is contained in:
@@ -25,22 +25,27 @@ public class DebugStackState extends StackState implements DebugRequestListener
|
||||
public void debugHooks( int pc ) {
|
||||
if ( exiting )
|
||||
throw new java.lang.RuntimeException("exiting");
|
||||
if ( ! suspended )
|
||||
return;
|
||||
|
||||
synchronized ( this ) {
|
||||
// vm is in suspended state, although it might also
|
||||
// be stepping to the next instruction at the same time.
|
||||
// in either case we need the current line number
|
||||
|
||||
// anytime the line doesn't change we keep going
|
||||
int[] li = calls[cc].closure.p.lineinfo;
|
||||
int line = (li!=null && li.length>pc? li[pc]: -1);
|
||||
if ( stepping ) {
|
||||
if ( lastline == line )
|
||||
return;
|
||||
stepping = false;
|
||||
}
|
||||
|
||||
// save line in case next op is a step
|
||||
lastline = line;
|
||||
if ( stepping )
|
||||
stepping = false;
|
||||
|
||||
// check for a break point if we aren't suspended already
|
||||
if ( ! suspended ) {
|
||||
if ( breakpoints.containsKey(line) )
|
||||
suspended = true;
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
// wait for a state change
|
||||
while ( suspended && (!exiting) && (!stepping) ) {
|
||||
@@ -146,12 +151,12 @@ public class DebugStackState extends StackState implements DebugRequestListener
|
||||
public String callgraph() {
|
||||
int n = cc;
|
||||
if ( n < 0 || n >= calls.length )
|
||||
return "<empty>";
|
||||
return "";
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for ( int i=0; i<n; i++ ) {
|
||||
for ( int i=0; i<=n; i++ ) {
|
||||
CallInfo ci = calls[i];
|
||||
// TODO: fill this out with proper format, names, etc.
|
||||
sb.append( String.valueOf(ci) );
|
||||
sb.append( String.valueOf(ci.closure.p) );
|
||||
sb.append( "\n" );
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
@@ -24,6 +24,7 @@ public class DebugStackStateTest extends TestCase {
|
||||
|
||||
// suspend the vm right away
|
||||
state.suspend();
|
||||
state.set( 14 );
|
||||
|
||||
// start the call processing in its own thread
|
||||
new Thread() {
|
||||
@@ -36,10 +37,10 @@ public class DebugStackStateTest extends TestCase {
|
||||
}
|
||||
}.start();
|
||||
|
||||
// step for 25 steps
|
||||
for ( int i=0; i<10; i++ ) {
|
||||
// step for 5 steps
|
||||
for ( int i=0; i<5; i++ ) {
|
||||
state.step();
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(500);
|
||||
System.out.println("--- callgraph="+state.callgraph() );
|
||||
System.out.println("--- stack="+state.stack() );
|
||||
System.out.println("--- variable(1,0)="+state.variable(1,0) );
|
||||
@@ -47,5 +48,10 @@ public class DebugStackStateTest extends TestCase {
|
||||
|
||||
// resume the vm
|
||||
state.resume();
|
||||
Thread.sleep(500);
|
||||
System.out.println("--- callgraph="+state.callgraph() );
|
||||
state.resume();
|
||||
Thread.sleep(500);
|
||||
System.out.println("--- callgraph="+state.callgraph() );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user