Skip to content

Commit 023cea7

Browse files
Ben Newmantargos
authored andcommitted
Skip restoring debug state unless thread previously in DebugScope.
A simpler version of the changes I proposed upstream in this V8 change request: https://chromium-review.googlesource.com/c/v8/v8/+/1168449 In this version, Debug::RestoreDebug never attempts to enter a new DebugScope, but merely reuses the previous one, if we're returning to a thread that was previously in a DebugScope. If the thread was not previously in a DebugScope, I believe it does not need to have any debugging state restored with ClearOneShot and PrepareStep. The tests from https://chromium-review.googlesource.com/c/v8/v8/+/833260 still pass, and the failing V8-CI tests are now passing locally for me: https://ci.nodejs.org/job/node-test-commit-v8-linux/1601/
1 parent 3a2d175 commit 023cea7

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

deps/v8/src/debug/debug.cc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,21 @@ char* Debug::RestoreDebug(char* storage) {
364364
MemCopy(reinterpret_cast<char*>(&thread_local_), storage,
365365
ArchiveSpacePerThread());
366366

367-
// Enter the debugger.
368-
DebugScope debug_scope(this);
369-
370-
// Clear any one-shot breakpoints that may have been set by the other
371-
// thread, and reapply breakpoints for this thread.
372-
ClearOneShot();
367+
if (in_debug_scope()) {
368+
// If this thread was in a DebugScope when we archived it, restore the
369+
// previous debugging state now. Note that in_debug_scope() returns
370+
// true when thread_local_.current_debug_scope_ (restored by MemCopy
371+
// above) is non-null.
372+
373+
// Clear any one-shot breakpoints that may have been set by the other
374+
// thread, and reapply breakpoints for this thread.
375+
HandleScope scope(isolate_);
376+
ClearOneShot();
373377

374-
if (thread_local_.last_step_action_ != StepNone) {
375-
// Reset the previous step action for this thread.
376-
PrepareStep(thread_local_.last_step_action_);
378+
if (thread_local_.last_step_action_ != StepNone) {
379+
// Reset the previous step action for this thread.
380+
PrepareStep(thread_local_.last_step_action_);
381+
}
377382
}
378383

379384
return storage + ArchiveSpacePerThread();

0 commit comments

Comments
 (0)