Skip to content

Commit 2b8cce2

Browse files
committed
[lldb] Fix crash after second run when set a previous watchpoint.
1 parent 46e7347 commit 2b8cce2

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lldb/source/Breakpoint/Watchpoint.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,15 @@ bool Watchpoint::IsDisabledDuringEphemeralMode() {
409409
}
410410

411411
void Watchpoint::SetEnabled(bool enabled, bool notify) {
412+
// Whenever setting the enabled state of a watchpoint, we need to ensure
413+
// that `m_new_value_sp` exists to avoid crash when reading old_data later.
414+
// See https://github.com/llvm/llvm-project/issues/135590.
415+
if (!m_new_value_sp) {
416+
ExecutionContext exe_ctx;
417+
m_target.GetProcessSP()->CalculateExecutionContext(exe_ctx);
418+
CaptureWatchedValue(exe_ctx);
419+
}
420+
412421
if (!enabled) {
413422
if (m_is_ephemeral)
414423
++m_disabled_count;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# RUN: %clangxx_host %p/Inputs/languages.cpp -g -o %t.out
2+
# RUN: %lldb -b -o 'settings set interpreter.stop-command-source-on-error false' -s %s %t.out 2>&1 | FileCheck %s
3+
4+
b main
5+
run
6+
# CHECK: stopped
7+
# CHECK-NEXT: stop reason = breakpoint
8+
9+
watchpoint set variable val
10+
# CHECK: Watchpoint created:
11+
12+
kill
13+
run
14+
# CHECK: stopped
15+
# CHECK-NEXT: stop reason = breakpoint
16+
17+
watchpoint set variable val
18+
# CHECK: Watchpoint created:
19+
20+
continue
21+
# CHECK: Watchpoint 1 hit:

0 commit comments

Comments
 (0)