summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/StackFrame.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-09-02 02:59:18 +0000
committerGreg Clayton <gclayton@apple.com>2010-09-02 02:59:18 +0000
commit288bdf9c1df39ae2be88dac6ca80adb9d123e9c9 (patch)
tree6705032b3965a864f2ec3f2560a52e8277702c85 /lldb/source/Target/StackFrame.cpp
parent6a7f63448702860ec23d2d98a2a78d1c85cc7a50 (diff)
downloadbcm5719-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/Target/StackFrame.cpp')
-rw-r--r--lldb/source/Target/StackFrame.cpp76
1 files changed, 66 insertions, 10 deletions
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());
OpenPOWER on IntegriCloud