2010-06-09 00:52:24 +08:00
|
|
|
//===-- ValueObjectVariable.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/Core/ValueObjectVariable.h"
|
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
|
|
|
#include "lldb/Core/Module.h"
|
|
|
|
#include "lldb/Core/ValueObjectList.h"
|
|
|
|
#include "lldb/Core/Value.h"
|
|
|
|
|
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
|
|
|
#include "lldb/Symbol/Function.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
2011-07-07 09:59:51 +08:00
|
|
|
#include "lldb/Symbol/SymbolContextScope.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/Type.h"
|
|
|
|
#include "lldb/Symbol/Variable.h"
|
|
|
|
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/RegisterContext.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
|
|
|
#include "lldb/Target/Thread.h"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2011-04-23 07:53:53 +08:00
|
|
|
lldb::ValueObjectSP
|
|
|
|
ValueObjectVariable::Create (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
|
|
|
|
{
|
|
|
|
return (new ValueObjectVariable (exe_scope, var_sp))->GetSP();
|
|
|
|
}
|
|
|
|
|
2011-03-31 08:19:25 +08:00
|
|
|
ValueObjectVariable::ValueObjectVariable (ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp) :
|
|
|
|
ValueObject(exe_scope),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_variable_sp(var_sp)
|
|
|
|
{
|
|
|
|
// Do not attempt to construct one of these objects with no variable!
|
|
|
|
assert (m_variable_sp.get() != NULL);
|
|
|
|
m_name = var_sp->GetName();
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueObjectVariable::~ValueObjectVariable()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
lldb::clang_type_t
|
2012-02-23 07:57:45 +08:00
|
|
|
ValueObjectVariable::GetClangTypeImpl ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
Type *var_type = m_variable_sp->GetType();
|
|
|
|
if (var_type)
|
A few of the issue I have been trying to track down and fix have been due to
the way LLDB lazily gets complete definitions for types within the debug info.
When we run across a class/struct/union definition in the DWARF, we will only
parse the full definition if we need to. This works fine for top level types
that are assigned directly to variables and arguments, but when we have a
variable with a class, lets say "A" for this example, that has a member:
"B *m_b". Initially we don't need to hunt down a definition for this class
unless we are ever asked to do something with it ("expr m_b->getDecl()" for
example). With my previous approach to lazy type completion, we would be able
to take a "A *a" and get a complete type for it, but we wouldn't be able to
then do an "a->m_b->getDecl()" unless we always expanded all types within a
class prior to handing out the type. Expanding everything is very costly and
it would be great if there were a better way.
A few months ago I worked with the llvm/clang folks to have the
ExternalASTSource class be able to complete classes if there weren't completed
yet:
class ExternalASTSource {
....
virtual void
CompleteType (clang::TagDecl *Tag);
virtual void
CompleteType (clang::ObjCInterfaceDecl *Class);
};
This was great, because we can now have the class that is producing the AST
(SymbolFileDWARF and SymbolFileDWARFDebugMap) sign up as external AST sources
and the object that creates the forward declaration types can now also
complete them anywhere within the clang type system.
This patch makes a few major changes:
- lldb_private::Module classes now own the AST context. Previously the TypeList
objects did.
- The DWARF parsers now sign up as an external AST sources so they can complete
types.
- All of the pure clang type system wrapper code we have in LLDB (ClangASTContext,
ClangASTType, and more) can now be iterating through children of any type,
and if a class/union/struct type (clang::RecordType or ObjC interface)
is found that is incomplete, we can ask the AST to get the definition.
- The SymbolFileDWARFDebugMap class now will create and use a single AST that
all child SymbolFileDWARF classes will share (much like what happens when
we have a complete linked DWARF for an executable).
We will need to modify some of the ClangUserExpression code to take more
advantage of this completion ability in the near future. Meanwhile we should
be better off now that we can be accessing any children of variables through
pointers and always be able to resolve the clang type if needed.
llvm-svn: 123613
2011-01-17 11:46:26 +08:00
|
|
|
return var_type->GetClangForwardType();
|
2010-06-09 00:52:24 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstString
|
|
|
|
ValueObjectVariable::GetTypeName()
|
|
|
|
{
|
|
|
|
Type * var_type = m_variable_sp->GetType();
|
|
|
|
if (var_type)
|
|
|
|
return var_type->GetName();
|
2012-03-27 07:03:23 +08:00
|
|
|
return ConstString();
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstString
|
|
|
|
ValueObjectVariable::GetQualifiedTypeName()
|
|
|
|
{
|
|
|
|
Type * var_type = m_variable_sp->GetType();
|
|
|
|
if (var_type)
|
|
|
|
return var_type->GetQualifiedName();
|
|
|
|
return ConstString();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
ValueObjectVariable::CalculateNumChildren()
|
2012-02-23 07:57:45 +08:00
|
|
|
{
|
|
|
|
ClangASTType type(GetClangAST(),
|
|
|
|
GetClangType());
|
|
|
|
|
|
|
|
if (!type.IsValid())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
const bool omit_empty_base_classes = true;
|
|
|
|
return ClangASTContext::GetNumChildren(type.GetASTContext(), type.GetOpaqueQualType(), omit_empty_base_classes);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
clang::ASTContext *
|
2012-02-23 07:57:45 +08:00
|
|
|
ValueObjectVariable::GetClangASTImpl ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-11-01 07:06:45 +08:00
|
|
|
Type *var_type = m_variable_sp->GetType();
|
|
|
|
if (var_type)
|
|
|
|
return var_type->GetClangAST();
|
|
|
|
return 0;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t
|
|
|
|
ValueObjectVariable::GetByteSize()
|
|
|
|
{
|
2012-02-23 07:57:45 +08:00
|
|
|
ClangASTType type(GetClangAST(),
|
|
|
|
GetClangType());
|
|
|
|
|
|
|
|
if (!type.IsValid())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (ClangASTType::GetClangTypeBitWidth(type.GetASTContext(), type.GetOpaqueQualType()) + 7) / 8;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
lldb::ValueType
|
|
|
|
ValueObjectVariable::GetValueType() const
|
|
|
|
{
|
|
|
|
if (m_variable_sp)
|
|
|
|
return m_variable_sp->GetScope();
|
|
|
|
return lldb::eValueTypeInvalid;
|
|
|
|
}
|
|
|
|
|
2011-03-31 08:19:25 +08:00
|
|
|
bool
|
|
|
|
ValueObjectVariable::UpdateValue ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SetValueIsValid (false);
|
|
|
|
m_error.Clear();
|
|
|
|
|
|
|
|
Variable *variable = m_variable_sp.get();
|
|
|
|
DWARFExpression &expr = variable->LocationExpression();
|
2010-09-18 12:00:06 +08:00
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
if (variable->GetLocationIsConstantValueData())
|
2010-09-14 10:20:48 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
// expr doesn't contain DWARF bytes, it contains the constant variable
|
|
|
|
// value bytes themselves...
|
|
|
|
if (expr.GetExpressionData(m_data))
|
|
|
|
m_value.SetContext(Value::eContextTypeVariable, variable);
|
|
|
|
else
|
|
|
|
m_error.SetErrorString ("empty constant data");
|
2010-09-14 10:20:48 +08:00
|
|
|
}
|
2011-05-30 08:49:24 +08:00
|
|
|
else
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS;
|
2012-02-17 15:49:44 +08:00
|
|
|
ExecutionContext exe_ctx (GetExecutionContextRef());
|
2011-05-30 08:49:24 +08:00
|
|
|
|
2011-09-22 12:58:26 +08:00
|
|
|
Target *target = exe_ctx.GetTargetPtr();
|
|
|
|
if (target)
|
2011-05-30 08:49:24 +08:00
|
|
|
{
|
2011-09-22 12:58:26 +08:00
|
|
|
m_data.SetByteOrder(target->GetArchitecture().GetByteOrder());
|
|
|
|
m_data.SetAddressByteSize(target->GetArchitecture().GetAddressByteSize());
|
2011-05-30 08:49:24 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
if (expr.IsLocationList())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
SymbolContext sc;
|
|
|
|
variable->CalculateSymbolContext (&sc);
|
|
|
|
if (sc.function)
|
2011-09-22 12:58:26 +08:00
|
|
|
loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (target);
|
2011-05-30 08:49:24 +08:00
|
|
|
}
|
|
|
|
Value old_value(m_value);
|
|
|
|
if (expr.Evaluate (&exe_ctx, GetClangAST(), NULL, NULL, NULL, loclist_base_load_addr, NULL, m_value, &m_error))
|
|
|
|
{
|
|
|
|
m_value.SetContext(Value::eContextTypeVariable, variable);
|
|
|
|
|
|
|
|
Value::ValueType value_type = m_value.GetValueType();
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
|
|
|
|
|
|
|
switch (value_type)
|
|
|
|
{
|
|
|
|
case Value::eValueTypeFileAddress:
|
|
|
|
SetAddressTypeOfChildren(eAddressTypeFile);
|
|
|
|
break;
|
|
|
|
case Value::eValueTypeHostAddress:
|
|
|
|
SetAddressTypeOfChildren(eAddressTypeHost);
|
|
|
|
break;
|
|
|
|
case Value::eValueTypeLoadAddress:
|
|
|
|
case Value::eValueTypeScalar:
|
2011-10-01 09:53:20 +08:00
|
|
|
SetAddressTypeOfChildren(eAddressTypeLoad);
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
|
|
|
break;
|
|
|
|
}
|
2011-05-30 08:49:24 +08:00
|
|
|
|
|
|
|
switch (value_type)
|
2010-09-13 10:37:44 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
default:
|
|
|
|
assert(!"Unhandled expression result value kind...");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Value::eValueTypeScalar:
|
|
|
|
// The variable value is in the Scalar value inside the m_value.
|
|
|
|
// We can point our m_data right to it.
|
2012-02-24 09:59:29 +08:00
|
|
|
m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
|
2011-05-30 08:49:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Value::eValueTypeFileAddress:
|
|
|
|
case Value::eValueTypeLoadAddress:
|
|
|
|
case Value::eValueTypeHostAddress:
|
|
|
|
// The DWARF expression result was an address in the inferior
|
|
|
|
// process. If this variable is an aggregate type, we just need
|
|
|
|
// the address as the main value as all child variable objects
|
|
|
|
// will rely upon this location and add an offset and then read
|
|
|
|
// their own values as needed. If this variable is a simple
|
|
|
|
// type, we read all data for it into m_data.
|
|
|
|
// Make sure this type has a value before we try and read it
|
|
|
|
|
|
|
|
// If we have a file address, convert it to a load address if we can.
|
2011-09-22 12:58:26 +08:00
|
|
|
Process *process = exe_ctx.GetProcessPtr();
|
|
|
|
if (value_type == Value::eValueTypeFileAddress && process && process->IsAlive())
|
2010-09-13 10:37:44 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
lldb::addr_t file_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
|
|
|
|
if (file_addr != LLDB_INVALID_ADDRESS)
|
2010-09-13 10:37:44 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
SymbolContext var_sc;
|
|
|
|
variable->CalculateSymbolContext(&var_sc);
|
|
|
|
if (var_sc.module_sp)
|
2010-09-13 10:37:44 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
ObjectFile *objfile = var_sc.module_sp->GetObjectFile();
|
|
|
|
if (objfile)
|
2010-09-13 10:37:44 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
Address so_addr(file_addr, objfile->GetSectionList());
|
2011-09-22 12:58:26 +08:00
|
|
|
lldb::addr_t load_addr = so_addr.GetLoadAddress (target);
|
2011-05-30 08:49:24 +08:00
|
|
|
if (load_addr != LLDB_INVALID_ADDRESS)
|
|
|
|
{
|
|
|
|
m_value.SetValueType(Value::eValueTypeLoadAddress);
|
|
|
|
m_value.GetScalar() = load_addr;
|
|
|
|
}
|
2010-09-13 10:37:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
if (ClangASTContext::IsAggregateType (GetClangType()))
|
|
|
|
{
|
|
|
|
// this value object represents an aggregate type whose
|
|
|
|
// children have values, but this object does not. So we
|
|
|
|
// say we are changed if our location has changed.
|
|
|
|
SetValueDidChange (value_type != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Copy the Value and set the context to use our Variable
|
|
|
|
// so it can extract read its value into m_data appropriately
|
|
|
|
Value value(m_value);
|
|
|
|
value.SetContext(Value::eContextTypeVariable, variable);
|
2012-02-24 09:59:29 +08:00
|
|
|
m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
|
2011-05-30 08:49:24 +08:00
|
|
|
}
|
|
|
|
break;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
SetValueIsValid (m_error.Success());
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-03-31 08:19:25 +08:00
|
|
|
return m_error.Success();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2011-03-31 08:19:25 +08:00
|
|
|
ValueObjectVariable::IsInScope ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-17 15:49:44 +08:00
|
|
|
const ExecutionContextRef &exe_ctx_ref = GetExecutionContextRef();
|
|
|
|
if (exe_ctx_ref.HasFrameRef())
|
|
|
|
{
|
|
|
|
ExecutionContext exe_ctx (exe_ctx_ref);
|
|
|
|
StackFrame *frame = exe_ctx.GetFramePtr();
|
|
|
|
if (frame)
|
|
|
|
{
|
|
|
|
return m_variable_sp->IsInScope (frame);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// This ValueObject had a frame at one time, but now we
|
|
|
|
// can't locate it, so return false since we probably aren't
|
|
|
|
// in scope.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// We have a variable that wasn't tied to a frame, which
|
|
|
|
// means it is a global and is always in scope.
|
|
|
|
return true;
|
2011-03-31 08:19:25 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-24 09:59:29 +08:00
|
|
|
lldb::ModuleSP
|
2011-07-07 09:59:51 +08:00
|
|
|
ValueObjectVariable::GetModule()
|
|
|
|
{
|
|
|
|
if (m_variable_sp)
|
|
|
|
{
|
|
|
|
SymbolContextScope *sc_scope = m_variable_sp->GetSymbolContextScope();
|
|
|
|
if (sc_scope)
|
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
return sc_scope->CalculateSymbolContextModule();
|
2011-07-07 09:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
2012-02-24 09:59:29 +08:00
|
|
|
return lldb::ModuleSP();
|
2011-07-07 09:59:51 +08:00
|
|
|
}
|
|
|
|
|
Redesign of the interaction between Python and frozen objects:
- introduced two new classes ValueObjectConstResultChild and ValueObjectConstResultImpl: the first one is a ValueObjectChild obtained from
a ValueObjectConstResult, the second is a common implementation backend for VOCR and VOCRCh of method calls meant to read through pointers stored
in frozen objects ; now such reads transparently move from host to target as required
- as a consequence of the above, removed code that made target-memory copies of expression results in several places throughout LLDB, and also
removed code that enabled to recognize an expression result VO as such
- introduced a new GetPointeeData() method in ValueObject that lets you read a given amount of objects of type T from a VO
representing a T* or T[], and doing dereferences transparently
in private layer it returns a DataExtractor ; in public layer it returns an instance of a newly created lldb::SBData
- as GetPointeeData() does the right thing for both frozen and non-frozen ValueObject's, reimplemented ReadPointedString() to use it
en lieu of doing the raw read itself
- introduced a new GetData() method in ValueObject that lets you get a copy of the data that backs the ValueObject (for pointers,
this returns the address without any previous dereferencing steps ; for arrays it actually reads the whole chunk of memory)
in public layer this returns an SBData, just like GetPointeeData()
- introduced a new CreateValueFromData() method in SBValue that lets you create a new SBValue from a chunk of data wrapped in an SBData
the limitation to remember for this kind of SBValue is that they have no address: extracting the address-of for these objects (with any
of GetAddress(), GetLoadAddress() and AddressOf()) will return invalid values
- added several tests to check that "p"-ing objects (STL classes, char* and char[]) will do the right thing
Solved a bug where global pointers to global variables were not dereferenced correctly for display
New target setting "max-string-summary-length" gives the maximum number of characters to show in a string when summarizing it, instead of the hardcoded 128
Solved a bug where the summary for char[] and char* would not be shown if the ValueObject's were dumped via the "p" command
Removed m_pointers_point_to_load_addrs from ValueObject. Introduced a new m_address_type_of_children, which each ValueObject can set to tell the address type
of any pointers and/or references it creates. In the current codebase, this is load address most of the time (the only notable exception being file
addresses that generate file address children UNLESS we have a live process)
Updated help text for summary-string
Fixed an issue in STL formatters where std::stlcontainer::iterator would match the container's synthetic children providers
Edited the syntax and help for some commands to have proper argument types
llvm-svn: 139160
2011-09-07 03:20:51 +08:00
|
|
|
SymbolContextScope *
|
|
|
|
ValueObjectVariable::GetSymbolContextScope()
|
|
|
|
{
|
|
|
|
if (m_variable_sp)
|
|
|
|
return m_variable_sp->GetSymbolContextScope();
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-02-04 10:27:34 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
ValueObjectVariable::GetDeclaration (Declaration &decl)
|
|
|
|
{
|
|
|
|
if (m_variable_sp)
|
|
|
|
{
|
|
|
|
decl = m_variable_sp->GetDeclaration();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|