[Lldb-commits] [lldb] [lldb] When re-enabling a watchpoint, save the current bytes (PR #218819)

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 26 18:03:56 PDT 2026


jasonmolenda wrote:

> > Does `watch enable` not re-evaluate the variable expression that was passed in when the watchpoint was set? I was wondering why you have to require ASLR?
> 
> _cough_ I forgot how all this works, I had to reread a bit. We don't reevaluate the watchpoint specification when re-enabling. In the Watchpoint object the specification is resolved to an address and a size, and the WatchpointResource(s) for that Watchpoint are based on that addr+size.

Ah, Watchpoint itself never interprets the specification, at least not watch set variable.  That's done in CommandObjectWatchpointSetVariable::DoExecute,
```
    valobj_sp = frame->GetValueForVariableExpressionPath(
        command.GetArgumentAtIndex(0), eNoDynamicValues, expr_path_options,
        var_sp, error);

    auto [addr, addr_type] = valobj_sp->GetAddressOf(false);

    WatchpointSP watch_sp =
        target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error);

      if (var_sp->GetScope() == eValueTypeVariableLocal)
        watch_sp->SetupVariableWatchpointDisabler(m_exe_ctx.GetFrameSP());
```

So re-enabling a watchpoint will never re-evaluate the expression used to create it.  Maybe it should, but I'd probably redesign the Watchpoint ctor from "requires an addr & size" to optionally only giving a specification string to be evaluated in an ExecutionContext, and let Watchpoint itself resolve this to an addr+size,  and re-do that when re-enabling (with the new ExecutionContext of course).

https://github.com/llvm/llvm-project/pull/218819


More information about the lldb-commits mailing list