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