Skip to content

Commit

Permalink
Fix small cond breakpoint loop: prevent locking process, prevent eval…
Browse files Browse the repository at this point in the history
… on pause
  • Loading branch information
yuxiaomao committed Nov 26, 2024
1 parent 1651468 commit f8deba2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hld/Debugger.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) {
Expand Down
7 changes: 7 additions & 0 deletions src/HLAdapter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 )
Expand Down

0 comments on commit f8deba2

Please sign in to comment.