Skip to content

[lldb] Fix updating persistent variables without JIT #149642

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions lldb/source/Expression/Materializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,23 @@ class EntityPersistentVariable : public Materializer::Entity {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def test_persist_var(self):
self.target.EvaluateExpression("int $my_int = 5")
self.expect_expr("$my_int * 2", result_type="int", result_value="10")

# Try assigning the persistent variable a new value.
self.target.EvaluateExpression("$my_int = 55")
self.expect_expr("$my_int", result_type="int", result_value="55")

def test_context_object(self):
"""Test expression evaluation in context of an object."""

Expand Down
Loading