Files
clang-p2996/lldb/source/Symbol/VariableList.cpp
Greg Clayton 288bdf9c1d 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
2010-09-02 02:59:18 +00:00

131 lines
2.9 KiB
C++

//===-- VariableList.cpp ----------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/VariableList.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/CompileUnit.h"
using namespace lldb;
using namespace lldb_private;
//----------------------------------------------------------------------
// VariableList constructor
//----------------------------------------------------------------------
VariableList::VariableList() :
m_variables()
{
}
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
VariableList::~VariableList()
{
}
void
VariableList::AddVariable(const VariableSP &variable_sp)
{
m_variables.push_back(variable_sp);
}
void
VariableList::AddVariables(VariableList *variable_list)
{
std::copy( variable_list->m_variables.begin(), // source begin
variable_list->m_variables.end(), // source end
back_inserter(m_variables)); // destination
}
void
VariableList::Clear()
{
m_variables.clear();
}
VariableSP
VariableList::GetVariableAtIndex(uint32_t idx)
{
VariableSP variable_sp;
if (idx < m_variables.size())
variable_sp = m_variables[idx];
return variable_sp;
}
VariableSP
VariableList::FindVariable(const ConstString& name)
{
VariableSP var_sp;
iterator pos, end = m_variables.end();
for (pos = m_variables.begin(); pos != end; ++pos)
{
if ((*pos)->GetName() == name)
{
var_sp = (*pos);
break;
}
}
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
{
size_t mem_size = sizeof(VariableList);
const_iterator pos, end = m_variables.end();
for (pos = m_variables.begin(); pos != end; ++pos)
mem_size += (*pos)->MemorySize();
return mem_size;
}
size_t
VariableList::GetSize() const
{
return m_variables.size();
}
void
VariableList::Dump(Stream *s, bool show_context) const
{
// s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
// s.Indent();
// s << "VariableList\n";
const_iterator pos, end = m_variables.end();
for (pos = m_variables.begin(); pos != end; ++pos)
{
(*pos)->Dump(s, show_context);
}
}