[all-commits] [llvm/llvm-project] 4da2b5: [lldb] Fix dwim-print to not delete non-result per...

Dave Lee via All-commits all-commits at lists.llvm.org
Fri Mar 15 16:09:46 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4da2b542b142dac441722e044ee75da2475d9a20
      https://github.com/llvm/llvm-project/commit/4da2b542b142dac441722e044ee75da2475d9a20
  Author: Dave Lee <davelee.com at gmail.com>
  Date:   2024-03-15 (Fri, 15 Mar 2024)

  Changed paths:
    M lldb/source/Commands/CommandObjectDWIMPrint.cpp
    M lldb/test/API/commands/dwim-print/TestDWIMPrint.py

  Log Message:
  -----------
  [lldb] Fix dwim-print to not delete non-result persistent variables (#85152)

`EvaluateExpression` does not always create a new persistent result. If the expression 
is a bare persistent variable, then a new persistent result is not created. This means 
the caller can't assume a new persistent result is created for each evaluation. 
However, `dwim-print` was doing exactly that: assuming a new persistent result for each 
evaluation. This resulted in a bug:

```
(lldb) p int $j = 23
(lldb) p $j
(lldb) p $j
```

The first `p $j` would not create a persistent result, and so `dwim-print` would 
inadvertently delete `$j`. The second `p $j` would fail.

The fix is to try `expr` as a persistent variable, after trying `expr` as a frame 
variable. For persistent variables, this avoids calling `EvaluateExpression`.

Resolves https://github.com/llvm/llvm-project/issues/84806

rdar://124688427



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list