File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -409,6 +409,15 @@ bool Watchpoint::IsDisabledDuringEphemeralMode() {
409409}
410410
411411void 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;
Original file line number Diff line number Diff line change 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:
You can’t perform that action at this time.
0 commit comments