diff options
author | Igor Kudrin <ikudrin@accesssoftek.com> | 2025-07-30 12:54:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-30 12:54:15 -0700 |
commit | e4c0f300309fbdcdabc43ff4bf57957181d6451e (patch) | |
tree | 2bd8ed253519651af834b99ab1ab23566e94c9f8 /lldb/source/Expression/Materializer.cpp | |
parent | a7ac43125eabb5845a2855bbf37fd4485831e860 (diff) | |
download | llvm-e4c0f300309fbdcdabc43ff4bf57957181d6451e.zip llvm-e4c0f300309fbdcdabc43ff4bf57957181d6451e.tar.gz llvm-e4c0f300309fbdcdabc43ff4bf57957181d6451e.tar.bz2 |
[lldb] Fix updating persistent variables without JIT (#149642)
This patch fixes updating persistent variables when memory cannot be
allocated in an inferior process:
```
> lldb -c test.core
(lldb) expr int $i = 5
(lldb) expr $i = 55
(int) $0 = 55
(lldb) expr $i
(int) $i = 5
```
With this patch, the last command prints:
```
(int) $i = 55
```
The issue was introduced in #145599.
Diffstat (limited to 'lldb/source/Expression/Materializer.cpp')
-rw-r--r-- | lldb/source/Expression/Materializer.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 17ea159..329768d 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -102,22 +102,23 @@ public: m_persistent_variable_sp->GetName(), mem, eAddressTypeLoad, map.GetAddressByteSize()); - if (m_persistent_variable_sp->m_flags & - ExpressionVariable::EVKeepInTarget) { - if (used_policy == IRMemoryMap::eAllocationPolicyMirror) { + if (used_policy == IRMemoryMap::eAllocationPolicyMirror) { + if (m_persistent_variable_sp->m_flags & + ExpressionVariable::EVKeepInTarget) { // Clear the flag if the variable will never be deallocated. Status leak_error; map.Leak(mem, leak_error); m_persistent_variable_sp->m_flags &= ~ExpressionVariable::EVNeedsAllocation; - } else { - // If the variable cannot be kept in target, clear this flag... - m_persistent_variable_sp->m_flags &= - ~ExpressionVariable::EVKeepInTarget; - // ...and set the flag to copy the value during dematerialization. - m_persistent_variable_sp->m_flags |= - ExpressionVariable::EVNeedsFreezeDry; } + } else { + // If we cannot allocate memory in the process, + // - clear the 'EVKeepInTarget' flag to ensure that 'm_live_sp' is reset + // during dematerialization, + m_persistent_variable_sp->m_flags &= ~ExpressionVariable::EVKeepInTarget; + // - set the 'EVNeedsFreezeDry' flag so that the value is copied to + // 'm_frozen_sp' during dematerialization. + m_persistent_variable_sp->m_flags |= ExpressionVariable::EVNeedsFreezeDry; } // Write the contents of the variable to the area. |