Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kastiglione
Copy link

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 llvm#84806

rdar://124688427
(cherry picked from commit 4da2b54)

(cherry-picked from commit 38b55e1)

…lvm#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 llvm#84806

rdar://124688427
(cherry picked from commit 4da2b54)

(cherry-picked from commit 38b55e1)
@kastiglione kastiglione merged commit 5195ad3 into next Mar 18, 2024
@kastiglione kastiglione deleted the dl/next/lldb-Fix-dwim-print-to-not-delete-non-result-persistent-variables-85152 branch March 18, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLDB: Inconsistant existance of expression global variable (use of undeclared identifier)
1 participant