Skip to content

Commit

Permalink
[coverage] Correctly free DebugInfo in the absence of breakpoints
Browse files Browse the repository at this point in the history
It's quite possible for DebugInfos to exist without the presence of a
bytecode array, since DebugInfos are created for all functions for which
we have a CoverageInfo. Free such objects properly.

Also move the corresponding deletion of CoverageInfos on unload up
before the early exit.

Bug: v8:6000
Change-Id: Idde45b222290aa8b6828b61ff2251918b8ed2aed
Reviewed-on: https://chromium-review.googlesource.com/664811
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48024}
  • Loading branch information
schuay authored and Commit Bot committed Sep 15, 2017
1 parent 78446a8 commit 1420e44
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/debug/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,12 @@ bool Debug::Load() {
void Debug::Unload() {
ClearAllBreakPoints();
ClearStepping();
if (FLAG_block_coverage) RemoveAllCoverageInfos();
RemoveDebugDelegate();

// Return debugger is not loaded.
if (!is_loaded()) return;

if (FLAG_block_coverage) RemoveAllCoverageInfos();

// Clear debugger context global handle.
GlobalHandles::Destroy(Handle<Object>::cast(debug_context_).location());
debug_context_ = Handle<Context>();
Expand Down Expand Up @@ -642,8 +641,11 @@ void Debug::ApplyBreakPoints(Handle<DebugInfo> debug_info) {
}

void Debug::ClearBreakPoints(Handle<DebugInfo> debug_info) {
// If we attempt to clear breakpoints but none exist, simply return. This can
// happen e.g. CoverageInfos exit but no breakpoints are set.
if (!debug_info->HasDebugBytecodeArray()) return;

DisallowHeapAllocation no_gc;
DCHECK(debug_info->HasDebugBytecodeArray());
for (BreakIterator it(debug_info); !it.Done(); it.Next()) {
it.ClearDebugBreak();
}
Expand Down

0 comments on commit 1420e44

Please sign in to comment.