Skip to content

Commit

Permalink
Make backtrace show previous line if triggered by watch (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao authored Feb 22, 2024
1 parent 1a2dbe4 commit a42a950
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hld/Debugger.hx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class Debugger {
mainThread = stoppedThread;

readThreads();
prepareStack();
prepareStack(cmd.r == Watchbreak);
return cmd.r;
}

Expand Down Expand Up @@ -426,9 +426,9 @@ class Debugger {
threads.set(currentThread,{ id : currentThread, stackTop: null, exception: null, name : null });
}

function prepareStack() {
function prepareStack( isWatchbreak=false ) {
currentStackFrame = 0;
currentStack = makeStack(currentThread);
currentStack = makeStack(currentThread, isWatchbreak);
}

function skipFunction( fidx : Int ) {
Expand Down Expand Up @@ -567,7 +567,7 @@ class Debugger {
var r = wait(true);
if( r != SingleStep || currentThread != tid )
break;
var st = makeStack(tid,1)[0];
var st = makeStack(tid,false,1)[0];
if( isRet ) {
if( op == 0xC3 ) {
if( st == null ) {
Expand All @@ -594,7 +594,7 @@ class Debugger {
return Breakpoint;
}

function makeStack(tid,max = 0) {
function makeStack( tid, isWatchbreak : Bool, max = 0 ) {
var stack = [];
var tinf = threads.get(tid);
if( tinf == null || tinf.stackTop == null )
Expand All @@ -606,6 +606,8 @@ class Debugger {

var eip = getReg(tid, Eip);
var asmPos = eip.sub(jit.codeStart);
if( isWatchbreak )
asmPos -= 1;
var e = jit.resolveAsmPos(asmPos);
var inProlog = false;

Expand Down

0 comments on commit a42a950

Please sign in to comment.