[Lldb-commits] [lldb] r112800 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Core/ include/lldb/Symbol/ include/lldb/Target/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Symbol/ source/Target/
Greg Clayton
gclayton at apple.com
Wed Sep 1 19:59:19 PDT 2010
Author: gclayton
Date: Wed Sep 1 21:59:18 2010
New Revision: 112800
URL: http://llvm.org/viewvc/llvm-project?rev=112800&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/API/SBValue.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Core/ValueObjectList.h
lldb/trunk/include/lldb/Core/ValueObjectVariable.h
lldb/trunk/include/lldb/Symbol/VariableList.h
lldb/trunk/include/lldb/Target/StackFrame.h
lldb/trunk/include/lldb/lldb-forward-rtti.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/API/SBFrame.cpp
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Commands/CommandObjectFrame.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectList.cpp
lldb/trunk/source/Core/ValueObjectVariable.cpp
lldb/trunk/source/Symbol/VariableList.cpp
lldb/trunk/source/Target/StackFrame.cpp
Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Wed Sep 1 21:59:18 2010
@@ -45,7 +45,7 @@
GetValue (const lldb::SBFrame &frame);
bool
- GetValueDidChange ();
+ GetValueDidChange (const lldb::SBFrame &frame);
const char *
GetSummary (const lldb::SBFrame &frame);
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Wed Sep 1 21:59:18 2010
@@ -145,10 +145,10 @@
GetUpdateID() const;
bool
- GetValueIsValid ();
+ GetValueIsValid () const;
bool
- GetValueDidChange () const;
+ GetValueDidChange (ExecutionContextScope *exe_scope);
bool
UpdateValueIfNeeded (ExecutionContextScope *exe_scope);
@@ -173,11 +173,6 @@
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 @@
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
//------------------------------------------------------------------
Modified: lldb/trunk/include/lldb/Core/ValueObjectList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectList.h?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectList.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectList.h Wed Sep 1 21:59:18 2010
@@ -48,11 +48,18 @@
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);
Modified: lldb/trunk/include/lldb/Core/ValueObjectVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectVariable.h?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectVariable.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectVariable.h Wed Sep 1 21:59:18 2010
@@ -25,7 +25,7 @@
class ValueObjectVariable : public ValueObject
{
public:
- ValueObjectVariable (lldb::VariableSP &var_sp);
+ ValueObjectVariable (const lldb::VariableSP &var_sp);
virtual
~ValueObjectVariable();
Modified: lldb/trunk/include/lldb/Symbol/VariableList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/VariableList.h?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/VariableList.h (original)
+++ lldb/trunk/include/lldb/Symbol/VariableList.h Wed Sep 1 21:59:18 2010
@@ -27,7 +27,7 @@
virtual ~VariableList();
void
- AddVariable (lldb::VariableSP &var_sp);
+ AddVariable (const lldb::VariableSP &var_sp);
void
AddVariables(VariableList *variable_list);
@@ -42,14 +42,11 @@
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;
Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrame.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrame.h Wed Sep 1 21:59:18 2010
@@ -91,14 +91,11 @@
}
VariableList *
- GetVariableList ();
+ GetVariableList (bool get_file_globals);
bool
HasDebugInformation ();
- ValueObjectList &
- GetValueObjectList();
-
const char *
Disassemble ();
@@ -120,6 +117,12 @@
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 @@
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);
};
Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward-rtti.h (original)
+++ lldb/trunk/include/lldb/lldb-forward-rtti.h Wed Sep 1 21:59:18 2010
@@ -62,6 +62,7 @@
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
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 1 21:59:18 2010
@@ -2310,6 +2310,7 @@
isa = PBXProject;
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Wed Sep 1 21:59:18 2010
@@ -304,7 +304,7 @@
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 @@
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;
}
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Wed Sep 1 21:59:18 2010
@@ -172,15 +172,15 @@
{
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;
}
Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Wed Sep 1 21:59:18 2010
@@ -584,13 +584,12 @@
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 @@
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
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Wed Sep 1 21:59:18 2010
@@ -44,12 +44,16 @@
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 @@
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 @@
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 @@
}
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 @@
uint32_t
ValueObject::GetNumChildren ()
{
- if (m_flags.IsClear(eNumChildrenHasBeenSet))
+ if (!m_children_count_valid)
{
SetNumChildren (CalculateNumChildren());
}
@@ -310,7 +313,7 @@
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 @@
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())
Modified: lldb/trunk/source/Core/ValueObjectList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectList.cpp?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectList.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectList.cpp Wed Sep 1 21:59:18 2010
@@ -57,6 +57,12 @@
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 @@
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 @@
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 @@
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 @@
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;
Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Wed Sep 1 21:59:18 2010
@@ -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)
{
Modified: lldb/trunk/source/Symbol/VariableList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/VariableList.cpp?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/VariableList.cpp (original)
+++ lldb/trunk/source/Symbol/VariableList.cpp Wed Sep 1 21:59:18 2010
@@ -32,7 +32,7 @@
void
-VariableList::AddVariable(VariableSP &variable_sp)
+VariableList::AddVariable(const VariableSP &variable_sp)
{
m_variables.push_back(variable_sp);
}
@@ -82,6 +82,20 @@
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
Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=112800&r1=112799&r2=112800&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Wed Sep 1 21:59:18 2010
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
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());
More information about the lldb-commits
mailing list