From f8deba2f0285592190849ae7ab853d7c678dbb6d Mon Sep 17 00:00:00 2001 From: Yuxiao Mao Date: Tue, 26 Nov 2024 11:28:51 +0100 Subject: [PATCH] Fix small cond breakpoint loop: prevent locking process, prevent eval on pause --- hld/Debugger.hx | 6 +++--- src/HLAdapter.hx | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hld/Debugger.hx b/hld/Debugger.hx index 5f2891f..4079f53 100644 --- a/hld/Debugger.hx +++ b/hld/Debugger.hx @@ -215,7 +215,7 @@ class Debugger { public function pause() { if( !api.breakpoint() ) throw "Failed to break process"; - var r = wait(); + var r = wait(false, false, true); // if we have stopped on a not HL thread, let's switch on main thread var found = false; for( t in threads ) @@ -295,7 +295,7 @@ class Debugger { return fields; } - function wait( onStep = false, onEvalCall = false ) : Api.WaitResult { + function wait( onStep = false, onEvalCall = false, onPause = false ) : Api.WaitResult { var cmd = null; var condition : String = null; watchBreak = null; @@ -400,7 +400,7 @@ class Debugger { prepareStack(cmd.r == Watchbreak); // if breakpoint has a condition, try to evaluate and do not actually break on false - if( condition != null ) { + if( !onStep && !onEvalCall && !onPause && condition != null ) { try { var value = getValue(condition); if( value != null ) { diff --git a/src/HLAdapter.hx b/src/HLAdapter.hx index 62c2b33..b5d2712 100644 --- a/src/HLAdapter.hx +++ b/src/HLAdapter.hx @@ -416,6 +416,7 @@ class HLAdapter extends DebugSession { return true; dbg.customTimeout = 0; var ret = false; + var count = 0; while( true ) { var msg = dbg.run(); handleWait(msg); @@ -428,6 +429,12 @@ class HLAdapter extends DebugSession { case Handled, SingleStep: // wait a bit (prevent locking the process until next tick when many events are pending) dbg.customTimeout = 0.1; + // prevent small loop with conditional breakpoint locking the adapter process + count++; + if( count > 100 ) { + shouldRun = true; + break; + } } } if( dbg != null )