diff options
| author | Greg Clayton <gclayton@apple.com> | 2010-09-02 02:59:18 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2010-09-02 02:59:18 +0000 |
| commit | 288bdf9c1df39ae2be88dac6ca80adb9d123e9c9 (patch) | |
| tree | 6705032b3965a864f2ec3f2560a52e8277702c85 /lldb/source/Core/ValueObject.cpp | |
| parent | 6a7f63448702860ec23d2d98a2a78d1c85cc7a50 (diff) | |
| download | bcm5719-llvm-288bdf9c1df39ae2be88dac6ca80adb9d123e9c9.tar.gz bcm5719-llvm-288bdf9c1df39ae2be88dac6ca80adb9d123e9c9.zip | |
StackFrame objects now own ValueObjects for any frame variables (locals, args,
function statics, file globals and static variables) that a frame contains.
The StackFrame objects can give out ValueObjects instances for
each variable which allows us to track when a variable changes and doesn't
depend on variable names when getting value objects.
StackFrame::GetVariableList now takes a boolean to indicate if we want to
get the frame compile unit globals and static variables.
The value objects in the stack frames can now correctly track when they have
been modified. There are a few more tweaks needed to complete this work. The
biggest issue is when stepping creates partial stacks (just frame zero usually)
and causes previous stack frames not to match up with the current stack frames
because the previous frames only has frame zero. We don't really want to
require that all previous frames be complete since stepping often must check
stack frames to complete their jobs. I will fix this issue tomorrow.
llvm-svn: 112800
Diffstat (limited to 'lldb/source/Core/ValueObject.cpp')
| -rw-r--r-- | lldb/source/Core/ValueObject.cpp | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 9c70c3bd649..e14875b10d6 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -44,12 +44,16 @@ ValueObject::ValueObject () : m_data (), m_value (), m_error (), - m_flags (), - m_value_str(), - m_location_str(), - m_summary_str(), - m_children(), - m_synthetic_children() + m_value_str (), + m_old_value_str (), + m_location_str (), + m_summary_str (), + m_children (), + m_synthetic_children (), + m_value_is_valid (false), + m_value_did_change (false), + m_children_count_valid (false), + m_old_value_valid (false) { } @@ -77,10 +81,19 @@ ValueObject::UpdateValueIfNeeded (ExecutionContextScope *exe_scope) const user_id_t stop_id = process->GetStopID(); if (m_update_id != stop_id) { + bool first_update = m_update_id == 0; // Save the old value using swap to avoid a string copy which // also will clear our m_value_str - std::string old_value_str; - old_value_str.swap (m_value_str); + if (m_value_str.empty()) + { + m_old_value_valid = false; + } + else + { + m_old_value_valid = true; + m_old_value_str.swap (m_value_str); + m_value_str.clear(); + } m_location_str.clear(); m_summary_str.clear(); @@ -97,22 +110,14 @@ ValueObject::UpdateValueIfNeeded (ExecutionContextScope *exe_scope) m_update_id = stop_id; bool success = m_error.Success(); SetValueIsValid (success); - // If the variable hasn't already been marked as changed do it - // by comparing the old any new value - if (!GetValueDidChange()) + + if (first_update) + SetValueDidChange (false); + else if (!m_value_did_change && success == false) { - if (success) - { - // The value was gotten successfully, so we consider the - // value as changed if the value string differs - SetValueDidChange (old_value_str != m_value_str); - } - else - { - // The value wasn't gotten successfully, so we mark this - // as changed if the value used to be valid and now isn't - SetValueDidChange (value_was_valid); - } + // The value wasn't gotten successfully, so we mark this + // as changed if the value used to be valid and now isn't + SetValueDidChange (value_was_valid); } } } @@ -202,31 +207,29 @@ ValueObject::GetValue() const } bool -ValueObject::GetValueIsValid () +ValueObject::GetValueIsValid () const { - return m_flags.IsSet(eValueIsValid); + return m_value_is_valid; } void ValueObject::SetValueIsValid (bool b) { - if (b) - m_flags.Set(eValueIsValid); - else - m_flags.Clear(eValueIsValid); + m_value_is_valid = b; } bool -ValueObject::GetValueDidChange () const +ValueObject::GetValueDidChange (ExecutionContextScope *exe_scope) { - return m_flags.IsSet(eValueChanged); + GetValueAsCString (exe_scope); + return m_value_did_change; } void ValueObject::SetValueDidChange (bool value_changed) { - m_flags.Set(eValueChanged); + m_value_did_change = value_changed; } ValueObjectSP @@ -301,7 +304,7 @@ ValueObject::GetChildMemberWithName (const ConstString &name, bool can_create) uint32_t ValueObject::GetNumChildren () { - if (m_flags.IsClear(eNumChildrenHasBeenSet)) + if (!m_children_count_valid) { SetNumChildren (CalculateNumChildren()); } @@ -310,7 +313,7 @@ ValueObject::GetNumChildren () void ValueObject::SetNumChildren (uint32_t num_children) { - m_flags.Set(eNumChildrenHasBeenSet); + m_children_count_valid = true; m_children.resize(num_children); } @@ -552,6 +555,13 @@ ValueObject::GetValueAsCString (ExecutionContextScope *exe_scope) break; } } + + if (!m_value_did_change && m_old_value_valid) + { + // The value was gotten successfully, so we consider the + // value as changed if the value string differs + SetValueDidChange (m_old_value_str != m_value_str); + } } } if (m_value_str.empty()) |

