From efd35a5776eebd347c2004c8bbf9e7d1e97a9457 Mon Sep 17 00:00:00 2001 From: Yuxiao Mao Date: Tue, 18 Jun 2024 10:08:44 +0200 Subject: [PATCH] evalCall prevent singlestep, which can remove our breakpoints --- hld/Debugger.hx | 3 ++- hld/Eval.hx | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hld/Debugger.hx b/hld/Debugger.hx index bca3d43..eeb1e19 100644 --- a/hld/Debugger.hx +++ b/hld/Debugger.hx @@ -171,6 +171,7 @@ class Debugger { this.api = api; eval = new Eval(module, api, jit); eval.resumeDebug = evalResumeDebug; + eval.setSingleStep = singleStep; if( !api.start() ) return false; wait(); // wait first break @@ -289,7 +290,7 @@ class Debugger { while( true ) { cmd = api.wait(customTimeout == null ? 1000 : Math.ceil(customTimeout * 1000)); - if( cmd.r == Breakpoint && (nextStep >= 0 || onStep) ) { + if( cmd.r == Breakpoint && !onEvalCall && (nextStep >= 0 || onStep) ) { // On Linux, singlestep is not reset cmd.r = SingleStep; singleStep(cmd.tid,false); diff --git a/hld/Eval.hx b/hld/Eval.hx index f7be75b..010463c 100644 --- a/hld/Eval.hx +++ b/hld/Eval.hx @@ -490,7 +490,12 @@ class Eval { if( !api.write(eip, buffer, asmSize) ) throw "assert"; api.flush(eip, asmSize); + var isSingleStep = (api.readRegister(currentThread, EFlags).toInt() & 256) == 256; + if( isSingleStep ) + setSingleStep(currentThread, false); resumeDebug(); + if( isSingleStep ) + setSingleStep(currentThread, true); // restore api.write(eip, prevAsm, asmSize); api.flush(eip, asmSize); @@ -509,6 +514,10 @@ class Eval { throw "Not implemented"; } + public dynamic function setSingleStep(tid : Int, set : Bool) { + throw "Not implemented"; + } + function getNum( v : Value ) : Float { return switch( v.v ) { case VInt(i): i;