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 | |
| 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')
| -rw-r--r-- | lldb/source/Core/ValueObject.cpp | 78 | ||||
| -rw-r--r-- | lldb/source/Core/ValueObjectList.cpp | 27 | ||||
| -rw-r--r-- | lldb/source/Core/ValueObjectVariable.cpp | 2 |
3 files changed, 68 insertions, 39 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()) diff --git a/lldb/source/Core/ValueObjectList.cpp b/lldb/source/Core/ValueObjectList.cpp index 5feeae7309a..8913d4da18d 100644 --- a/lldb/source/Core/ValueObjectList.cpp +++ b/lldb/source/Core/ValueObjectList.cpp @@ -57,6 +57,12 @@ ValueObjectList::GetSize() const return m_value_objects.size(); } +void +ValueObjectList::Resize (uint32_t size) +{ + m_value_objects.resize (size); +} + lldb::ValueObjectSP ValueObjectList::GetValueObjectAtIndex (uint32_t idx) { @@ -66,6 +72,14 @@ ValueObjectList::GetValueObjectAtIndex (uint32_t idx) return valobj_sp; } +void +ValueObjectList::SetValueObjectAtIndex (uint32_t idx, const ValueObjectSP &valobj_sp) +{ + if (idx >= m_value_objects.size()) + m_value_objects.resize (idx + 1); + m_value_objects[idx] = valobj_sp; +} + ValueObjectSP ValueObjectList::FindValueObjectByValueName (const char *name) { @@ -74,7 +88,8 @@ ValueObjectList::FindValueObjectByValueName (const char *name) collection::iterator pos, end = m_value_objects.end(); for (pos = m_value_objects.begin(); pos != end; ++pos) { - if ((*pos)->GetName() == name_const_str) + ValueObject *valobj = (*pos).get(); + if (valobj && valobj->GetName() == name_const_str) { val_obj_sp = *pos; break; @@ -91,7 +106,10 @@ ValueObjectList::FindValueObjectByUID (lldb::user_id_t uid) for (pos = m_value_objects.begin(); pos != end; ++pos) { - if ((*pos)->GetID() == uid) + // Watch out for NULL objects in our list as the list + // might get resized to a specific size and lazily filled in + ValueObject *valobj = (*pos).get(); + if (valobj && valobj->GetID() == uid) { valobj_sp = *pos; break; @@ -102,14 +120,15 @@ ValueObjectList::FindValueObjectByUID (lldb::user_id_t uid) ValueObjectSP -ValueObjectList::FindValueObjectByPointer (ValueObject *valobj) +ValueObjectList::FindValueObjectByPointer (ValueObject *find_valobj) { ValueObjectSP valobj_sp; collection::iterator pos, end = m_value_objects.end(); for (pos = m_value_objects.begin(); pos != end; ++pos) { - if ((*pos).get() == valobj) + ValueObject *valobj = (*pos).get(); + if (valobj && valobj == find_valobj) { valobj_sp = *pos; break; diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp index c15bbef798d..cbd583f609c 100644 --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -32,7 +32,7 @@ using namespace lldb_private; -ValueObjectVariable::ValueObjectVariable (lldb::VariableSP &var_sp) : +ValueObjectVariable::ValueObjectVariable (const lldb::VariableSP &var_sp) : ValueObject(), m_variable_sp(var_sp) { |

