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 | |
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')
-rw-r--r-- | lldb/include/lldb/API/SBValue.h | 2 | ||||
-rw-r--r-- | lldb/include/lldb/Core/ValueObject.h | 16 | ||||
-rw-r--r-- | lldb/include/lldb/Core/ValueObjectList.h | 11 | ||||
-rw-r--r-- | lldb/include/lldb/Core/ValueObjectVariable.h | 2 | ||||
-rw-r--r-- | lldb/include/lldb/Symbol/VariableList.h | 13 | ||||
-rw-r--r-- | lldb/include/lldb/Target/StackFrame.h | 13 | ||||
-rw-r--r-- | lldb/include/lldb/lldb-forward-rtti.h | 1 | ||||
-rw-r--r-- | lldb/lldb.xcodeproj/project.pbxproj | 1 | ||||
-rw-r--r-- | lldb/source/API/SBFrame.cpp | 32 | ||||
-rw-r--r-- | lldb/source/API/SBValue.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectFrame.cpp | 18 | ||||
-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 | ||||
-rw-r--r-- | lldb/source/Symbol/VariableList.cpp | 16 | ||||
-rw-r--r-- | lldb/source/Target/StackFrame.cpp | 76 |
16 files changed, 192 insertions, 122 deletions
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index b5ac5efb0e0..032f1db78f1 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -45,7 +45,7 @@ public: GetValue (const lldb::SBFrame &frame); bool - GetValueDidChange (); + GetValueDidChange (const lldb::SBFrame &frame); const char * GetSummary (const lldb::SBFrame &frame); diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 75ae31bdffb..0e805f4e77f 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -145,10 +145,10 @@ public: GetUpdateID() const; bool - GetValueIsValid (); + GetValueIsValid () const; bool - GetValueDidChange () const; + GetValueDidChange (ExecutionContextScope *exe_scope); bool UpdateValueIfNeeded (ExecutionContextScope *exe_scope); @@ -173,11 +173,6 @@ public: GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create); protected: - enum { - eValueChanged = (1 << 0), - eNumChildrenHasBeenSet = (1 << 1), - eValueIsValid = (1 << 2) - }; //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these //------------------------------------------------------------------ @@ -191,12 +186,17 @@ protected: DataExtractor m_data; // A data extractor that can be used to extract the value. Value m_value; Error m_error; // An error object that can describe any errors that occur when updating values. - Flags m_flags; // A boolean that indicates this value has changed std::string m_value_str; // Cached value string that will get cleared if/when the value is updated. + std::string m_old_value_str;// Cached old value string from the last time the value was gotten std::string m_location_str; // Cached location string that will get cleared if/when the value is updated. std::string m_summary_str; // Cached summary string that will get cleared if/when the value is updated. std::vector<lldb::ValueObjectSP> m_children; std::map<ConstString, lldb::ValueObjectSP> m_synthetic_children; + bool m_value_is_valid:1, + m_value_did_change:1, + m_children_count_valid:1, + m_old_value_valid:1; + //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Core/ValueObjectList.h b/lldb/include/lldb/Core/ValueObjectList.h index 1b310289082..9c5cde647fd 100644 --- a/lldb/include/lldb/Core/ValueObjectList.h +++ b/lldb/include/lldb/Core/ValueObjectList.h @@ -48,11 +48,18 @@ public: FindValueObjectByPointer (ValueObject *valobj); uint32_t - GetSize() const; + GetSize () const; + + void + Resize (uint32_t size); lldb::ValueObjectSP - GetValueObjectAtIndex (uint32_t); + GetValueObjectAtIndex (uint32_t idx); + void + SetValueObjectAtIndex (uint32_t idx, + const lldb::ValueObjectSP &valobj_sp); + lldb::ValueObjectSP FindValueObjectByValueName (const char *name); diff --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h index 80e0d05272e..f3d91dde39d 100644 --- a/lldb/include/lldb/Core/ValueObjectVariable.h +++ b/lldb/include/lldb/Core/ValueObjectVariable.h @@ -25,7 +25,7 @@ namespace lldb_private { class ValueObjectVariable : public ValueObject { public: - ValueObjectVariable (lldb::VariableSP &var_sp); + ValueObjectVariable (const lldb::VariableSP &var_sp); virtual ~ValueObjectVariable(); diff --git a/lldb/include/lldb/Symbol/VariableList.h b/lldb/include/lldb/Symbol/VariableList.h index 53d21e659f8..cadd2182148 100644 --- a/lldb/include/lldb/Symbol/VariableList.h +++ b/lldb/include/lldb/Symbol/VariableList.h @@ -27,7 +27,7 @@ public: virtual ~VariableList(); void - AddVariable (lldb::VariableSP &var_sp); + AddVariable (const lldb::VariableSP &var_sp); void AddVariables(VariableList *variable_list); @@ -42,14 +42,11 @@ public: GetVariableAtIndex(uint32_t idx); lldb::VariableSP - FindVariable(const ConstString& name); + FindVariable (const ConstString& name); + + uint32_t + FindIndexForVariable (Variable* variable); -// const SymbolContext& -// GetSymbolContext() const -// { -// return m_symbol_context; -// } -// size_t MemorySize() const; diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h index 2732708dd4c..c8b482aeea3 100644 --- a/lldb/include/lldb/Target/StackFrame.h +++ b/lldb/include/lldb/Target/StackFrame.h @@ -91,14 +91,11 @@ public: } VariableList * - GetVariableList (); + GetVariableList (bool get_file_globals); bool HasDebugInformation (); - ValueObjectList & - GetValueObjectList(); - const char * Disassemble (); @@ -120,6 +117,12 @@ public: return m_unwind_frame_index; } + lldb::ValueObjectSP + GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp); + + lldb::ValueObjectSP + TrackGlobalVariable (const lldb::VariableSP &variable_sp); + //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions //------------------------------------------------------------------ @@ -165,7 +168,7 @@ private: Scalar m_frame_base; Error m_frame_base_error; lldb::VariableListSP m_variable_list_sp; - ValueObjectList m_value_object_list; + ValueObjectList m_variable_list_value_objects; // Value objects for each variable in m_variable_list_sp StreamString m_disassembly; DISALLOW_COPY_AND_ASSIGN (StackFrame); }; diff --git a/lldb/include/lldb/lldb-forward-rtti.h b/lldb/include/lldb/lldb-forward-rtti.h index 8841322a156..aca620c5ed8 100644 --- a/lldb/include/lldb/lldb-forward-rtti.h +++ b/lldb/include/lldb/lldb-forward-rtti.h @@ -62,6 +62,7 @@ namespace lldb { typedef SharedPtr<lldb_private::ValueObject>::Type ValueObjectSP; typedef SharedPtr<lldb_private::Variable>::Type VariableSP; typedef SharedPtr<lldb_private::VariableList>::Type VariableListSP; + typedef SharedPtr<lldb_private::ValueObjectList>::Type ValueObjectListSP; } // namespace lldb diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 6c23d00e0b6..71c4d6eda8d 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -2310,6 +2310,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index b2d591d8507..ce294cafa7b 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -304,7 +304,7 @@ SBFrame::GetVariables (bool arguments, if (m_opaque_sp) { size_t i; - VariableList *variable_list = m_opaque_sp->GetVariableList(); + VariableList *variable_list = m_opaque_sp->GetVariableList(true); if (variable_list) { const size_t num_variables = variable_list->GetSize(); @@ -339,38 +339,12 @@ SBFrame::GetVariables (bool arguments, if (in_scope_only && !variable_sp->IsInScope(m_opaque_sp.get())) continue; - value_list.Append(ValueObjectSP (new ValueObjectVariable (variable_sp))); + value_list.Append(m_opaque_sp->GetValueObjectForFrameVariable (variable_sp)); } } } } - } - - if (statics) - { - CompileUnit *frame_comp_unit = m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit; - - if (frame_comp_unit) - { - variable_list = frame_comp_unit->GetVariableList(true).get(); - - if (variable_list) - { - const size_t num_variables = variable_list->GetSize(); - if (num_variables) - { - for (i = 0; i < num_variables; ++i) - { - VariableSP variable_sp (variable_list->GetVariableAtIndex(i)); - if (variable_sp) - { - value_list.Append(ValueObjectSP (new ValueObjectVariable (variable_sp))); - } - } - } - } - } - } + } } return value_list; } diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index c7839cbee46..f92be9f1037 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -172,15 +172,15 @@ SBValue::GetValue (const SBFrame &frame) { const char *value_string = NULL; if ( m_opaque_sp) - value_string = m_opaque_sp->GetValueAsCString(frame.get()); + value_string = m_opaque_sp->GetValueAsCString (frame.get()); return value_string; } bool -SBValue::GetValueDidChange () +SBValue::GetValueDidChange (const SBFrame &frame) { if (IsValid()) - return m_opaque_sp->GetValueDidChange(); + return m_opaque_sp->GetValueDidChange (frame.get()); return false; } diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index f78f8cb5e47..30287e21210 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -584,13 +584,12 @@ public: var_sp = global_var_list.GetVariableAtIndex(global_idx); if (var_sp) { - valobj_sp = exe_ctx.frame->GetValueObjectList().FindValueObjectByValueName (m_options.globals[idx].AsCString()); + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); if (!valobj_sp) - valobj_sp.reset (new ValueObjectVariable (var_sp)); + valobj_sp = exe_ctx.frame->TrackGlobalVariable (var_sp); if (valobj_sp) { - exe_ctx.frame->GetValueObjectList().Append (valobj_sp); DumpValueObject (result, exe_ctx.frame, valobj_sp.get(), name_cstr, m_options.ptr_depth, 0, m_options.max_depth, false); result.GetOutputStream().EOL(); } @@ -631,18 +630,7 @@ public: var_sp = variable_list.FindVariable(name_const_string); if (var_sp) { - //DumpVariable (result, &exe_ctx, var_sp.get()); - // TODO: redo history variables using a different map -// if (var_path[0] == '$') -// valobj_sp = valobj_list.FindValueObjectByValueObjectName (name_const_string.GetCString()); -// else - valobj_sp = exe_ctx.frame->GetValueObjectList().FindValueObjectByValueName (name_const_string.GetCString()); - - if (!valobj_sp) - { - valobj_sp.reset (new ValueObjectVariable (var_sp)); - exe_ctx.frame->GetValueObjectList().Append (valobj_sp); - } + valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); var_path.erase (0, name_const_string.GetLength ()); // We are dumping at least one child 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) { diff --git a/lldb/source/Symbol/VariableList.cpp b/lldb/source/Symbol/VariableList.cpp index 7f864f287ea..5ee5299d62b 100644 --- a/lldb/source/Symbol/VariableList.cpp +++ b/lldb/source/Symbol/VariableList.cpp @@ -32,7 +32,7 @@ VariableList::~VariableList() void -VariableList::AddVariable(VariableSP &variable_sp) +VariableList::AddVariable(const VariableSP &variable_sp) { m_variables.push_back(variable_sp); } @@ -82,6 +82,20 @@ VariableList::FindVariable(const ConstString& name) return var_sp; } +uint32_t +VariableList::FindIndexForVariable (Variable* variable) +{ + VariableSP var_sp; + iterator pos; + const iterator begin = m_variables.begin(); + const iterator end = m_variables.end(); + for (pos = m_variables.begin(); pos != end; ++pos) + { + if ((*pos).get() == variable) + return std::distance (begin, pos); + } + return UINT32_MAX; +} size_t VariableList::MemorySize() const diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 4aef251c297..f812285e775 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -16,7 +16,9 @@ #include "lldb/Core/Module.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Value.h" +#include "lldb/Core/ValueObjectVariable.h" #include "lldb/Symbol/Function.h" +#include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -55,7 +57,7 @@ StackFrame::StackFrame m_frame_base (), m_frame_base_error (), m_variable_list_sp (), - m_value_object_list () + m_variable_list_value_objects () { if (sc_ptr != NULL) { @@ -85,7 +87,7 @@ StackFrame::StackFrame m_frame_base (), m_frame_base_error (), m_variable_list_sp (), - m_value_object_list () + m_variable_list_value_objects () { if (sc_ptr != NULL) { @@ -121,7 +123,7 @@ StackFrame::StackFrame m_frame_base (), m_frame_base_error (), m_variable_list_sp (), - m_value_object_list () + m_variable_list_value_objects () { if (sc_ptr != NULL) { @@ -450,18 +452,31 @@ StackFrame::GetSymbolContext (uint32_t resolve_scope) VariableList * -StackFrame::GetVariableList () +StackFrame::GetVariableList (bool get_file_globals) { if (m_flags.IsClear(RESOLVED_VARIABLES)) { m_flags.Set(RESOLVED_VARIABLES); - if (GetSymbolContext (eSymbolContextFunction).function) + GetSymbolContext (eSymbolContextCompUnit | + eSymbolContextFunction | + eSymbolContextBlock); + + if (m_sc.block) { bool get_child_variables = true; bool can_create = true; m_variable_list_sp = m_sc.function->GetBlock (can_create).GetVariableList (get_child_variables, can_create); } + + if (get_file_globals && m_sc.comp_unit) + { + VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true)); + if (m_variable_list_sp) + m_variable_list_sp->AddVariables (global_variable_list_sp.get()); + else + m_variable_list_sp = global_variable_list_sp; + } } return m_variable_list_sp.get(); } @@ -521,10 +536,52 @@ StackFrame::HasDebugInformation () return m_sc.line_entry.IsValid(); } -ValueObjectList & -StackFrame::GetValueObjectList() + +ValueObjectSP +StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp) { - return m_value_object_list; + ValueObjectSP valobj_sp; + VariableList *var_list = GetVariableList (true); + if (var_list) + { + // Make sure the variable is a frame variable + const uint32_t var_idx = var_list->FindIndexForVariable (variable_sp.get()); + const uint32_t num_variables = var_list->GetSize(); + if (var_idx < num_variables) + { + valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx); + if (valobj_sp.get() == NULL) + { + if (m_variable_list_value_objects.GetSize() < num_variables) + m_variable_list_value_objects.Resize(num_variables); + valobj_sp.reset (new ValueObjectVariable (variable_sp)); + m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp); + } + } + } + return valobj_sp; +} + +ValueObjectSP +StackFrame::TrackGlobalVariable (const VariableSP &variable_sp) +{ + // Check to make sure we aren't already tracking this variable? + ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp)); + if (!valobj_sp) + { + // We aren't already tracking this global + VariableList *var_list = GetVariableList (true); + // If this frame has no variables, create a new list + if (var_list == NULL) + m_variable_list_sp.reset (new VariableList()); + + // Add the global/static variable to this frame + m_variable_list_sp->AddVariable (variable_sp); + + // Now make a value object for it so we can track its changes + valobj_sp = GetValueObjectForFrameVariable (variable_sp); + } + return valobj_sp; } bool @@ -591,7 +648,7 @@ StackFrame::UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame) { assert (GetStackID() == prev_frame.GetStackID()); // TODO: remove this after some testing m_variable_list_sp = prev_frame.m_variable_list_sp; - m_value_object_list.Swap (prev_frame.m_value_object_list); + m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects); if (!m_disassembly.GetString().empty()) m_disassembly.GetString().swap (m_disassembly.GetString()); } @@ -610,7 +667,6 @@ StackFrame::UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame) assert (m_sc.module_sp.get() == NULL || curr_frame.m_sc.module_sp.get() == NULL || m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get()); assert (m_sc.comp_unit == NULL || curr_frame.m_sc.comp_unit == NULL || m_sc.comp_unit == curr_frame.m_sc.comp_unit); assert (m_sc.function == NULL || curr_frame.m_sc.function == NULL || m_sc.function == curr_frame.m_sc.function); - assert (m_sc.symbol == NULL || curr_frame.m_sc.symbol == NULL || m_sc.symbol == curr_frame.m_sc.symbol); m_sc = curr_frame.m_sc; m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything); m_flags.Set (m_sc.GetResolvedMask()); |