mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 13:35:38 +08:00
- 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
340 lines
8.9 KiB
C++
340 lines
8.9 KiB
C++
//===-- ValueObjectConstResult.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/ValueObjectConstResult.h"
|
|
|
|
#include "lldb/Core/ValueObjectChild.h"
|
|
#include "lldb/Core/ValueObjectConstResultChild.h"
|
|
#include "lldb/Core/DataExtractor.h"
|
|
#include "lldb/Core/Module.h"
|
|
#include "lldb/Core/ValueObjectList.h"
|
|
|
|
#include "lldb/Symbol/ClangASTType.h"
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
#include "lldb/Symbol/SymbolContext.h"
|
|
#include "lldb/Symbol/Type.h"
|
|
#include "lldb/Symbol/Variable.h"
|
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
#include "lldb/Target/Process.h"
|
|
#include "lldb/Target/Target.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
ValueObjectSP
|
|
ValueObjectConstResult::Create
|
|
(
|
|
ExecutionContextScope *exe_scope,
|
|
ByteOrder byte_order,
|
|
uint32_t addr_byte_size,
|
|
lldb::addr_t address
|
|
)
|
|
{
|
|
return (new ValueObjectConstResult (exe_scope,
|
|
byte_order,
|
|
addr_byte_size,
|
|
address))->GetSP();
|
|
}
|
|
|
|
ValueObjectConstResult::ValueObjectConstResult
|
|
(
|
|
ExecutionContextScope *exe_scope,
|
|
ByteOrder byte_order,
|
|
uint32_t addr_byte_size,
|
|
lldb::addr_t address
|
|
) :
|
|
ValueObject (exe_scope),
|
|
m_clang_ast (NULL),
|
|
m_type_name (),
|
|
m_byte_size (0),
|
|
m_impl(this, address)
|
|
{
|
|
SetIsConstant ();
|
|
SetValueIsValid(true);
|
|
m_data.SetByteOrder(byte_order);
|
|
m_data.SetAddressByteSize(addr_byte_size);
|
|
SetAddressTypeOfChildren(eAddressTypeLoad);
|
|
}
|
|
|
|
ValueObjectSP
|
|
ValueObjectConstResult::Create
|
|
(
|
|
ExecutionContextScope *exe_scope,
|
|
clang::ASTContext *clang_ast,
|
|
void *clang_type,
|
|
const ConstString &name,
|
|
const DataExtractor &data,
|
|
lldb::addr_t address
|
|
)
|
|
{
|
|
return (new ValueObjectConstResult (exe_scope,
|
|
clang_ast,
|
|
clang_type,
|
|
name,
|
|
data,
|
|
address))->GetSP();
|
|
}
|
|
|
|
ValueObjectConstResult::ValueObjectConstResult
|
|
(
|
|
ExecutionContextScope *exe_scope,
|
|
clang::ASTContext *clang_ast,
|
|
void *clang_type,
|
|
const ConstString &name,
|
|
const DataExtractor &data,
|
|
lldb::addr_t address
|
|
) :
|
|
ValueObject (exe_scope),
|
|
m_clang_ast (clang_ast),
|
|
m_type_name (),
|
|
m_byte_size (0),
|
|
m_impl(this, address)
|
|
{
|
|
m_data = data;
|
|
m_value.GetScalar() = (uintptr_t)m_data.GetDataStart();
|
|
m_value.SetValueType(Value::eValueTypeHostAddress);
|
|
m_value.SetContext(Value::eContextTypeClangType, clang_type);
|
|
m_name = name;
|
|
SetIsConstant ();
|
|
SetValueIsValid(true);
|
|
SetAddressTypeOfChildren(eAddressTypeLoad);
|
|
}
|
|
|
|
ValueObjectSP
|
|
ValueObjectConstResult::Create
|
|
(
|
|
ExecutionContextScope *exe_scope,
|
|
clang::ASTContext *clang_ast,
|
|
void *clang_type,
|
|
const ConstString &name,
|
|
const lldb::DataBufferSP &data_sp,
|
|
lldb::ByteOrder data_byte_order,
|
|
uint8_t data_addr_size,
|
|
lldb::addr_t address
|
|
)
|
|
{
|
|
return (new ValueObjectConstResult (exe_scope,
|
|
clang_ast,
|
|
clang_type,
|
|
name,
|
|
data_sp,
|
|
data_byte_order,
|
|
data_addr_size,
|
|
address))->GetSP();
|
|
}
|
|
|
|
ValueObjectConstResult::ValueObjectConstResult
|
|
(
|
|
ExecutionContextScope *exe_scope,
|
|
clang::ASTContext *clang_ast,
|
|
void *clang_type,
|
|
const ConstString &name,
|
|
const lldb::DataBufferSP &data_sp,
|
|
lldb::ByteOrder data_byte_order,
|
|
uint8_t data_addr_size,
|
|
lldb::addr_t address
|
|
) :
|
|
ValueObject (exe_scope),
|
|
m_clang_ast (clang_ast),
|
|
m_type_name (),
|
|
m_byte_size (0),
|
|
m_impl(this, address)
|
|
{
|
|
m_data.SetByteOrder(data_byte_order);
|
|
m_data.SetAddressByteSize(data_addr_size);
|
|
m_data.SetData(data_sp);
|
|
m_value.GetScalar() = (uintptr_t)data_sp->GetBytes();
|
|
m_value.SetValueType(Value::eValueTypeHostAddress);
|
|
m_value.SetContext(Value::eContextTypeClangType, clang_type);
|
|
m_name = name;
|
|
SetIsConstant ();
|
|
SetValueIsValid(true);
|
|
SetAddressTypeOfChildren(eAddressTypeLoad);
|
|
}
|
|
|
|
ValueObjectSP
|
|
ValueObjectConstResult::Create
|
|
(
|
|
ExecutionContextScope *exe_scope,
|
|
clang::ASTContext *clang_ast,
|
|
void *clang_type,
|
|
const ConstString &name,
|
|
lldb::addr_t address,
|
|
AddressType address_type,
|
|
uint8_t addr_byte_size
|
|
)
|
|
{
|
|
return (new ValueObjectConstResult (exe_scope,
|
|
clang_ast,
|
|
clang_type,
|
|
name,
|
|
address,
|
|
address_type,
|
|
addr_byte_size))->GetSP();
|
|
}
|
|
|
|
ValueObjectConstResult::ValueObjectConstResult
|
|
(
|
|
ExecutionContextScope *exe_scope,
|
|
clang::ASTContext *clang_ast,
|
|
void *clang_type,
|
|
const ConstString &name,
|
|
lldb::addr_t address,
|
|
AddressType address_type,
|
|
uint8_t addr_byte_size
|
|
) :
|
|
ValueObject (exe_scope),
|
|
m_clang_ast (clang_ast),
|
|
m_type_name (),
|
|
m_byte_size (0),
|
|
m_impl(this, address)
|
|
{
|
|
m_value.GetScalar() = address;
|
|
m_data.SetAddressByteSize(addr_byte_size);
|
|
m_value.GetScalar().GetData (m_data, addr_byte_size);
|
|
//m_value.SetValueType(Value::eValueTypeHostAddress);
|
|
switch (address_type)
|
|
{
|
|
default:
|
|
case eAddressTypeInvalid: m_value.SetValueType(Value::eValueTypeScalar); break;
|
|
case eAddressTypeFile: m_value.SetValueType(Value::eValueTypeFileAddress); break;
|
|
case eAddressTypeLoad: m_value.SetValueType(Value::eValueTypeLoadAddress); break;
|
|
case eAddressTypeHost: m_value.SetValueType(Value::eValueTypeHostAddress); break;
|
|
}
|
|
m_value.SetContext(Value::eContextTypeClangType, clang_type);
|
|
m_name = name;
|
|
SetIsConstant ();
|
|
SetValueIsValid(true);
|
|
SetAddressTypeOfChildren(eAddressTypeLoad);
|
|
}
|
|
|
|
ValueObjectSP
|
|
ValueObjectConstResult::Create
|
|
(
|
|
ExecutionContextScope *exe_scope,
|
|
const Error& error
|
|
)
|
|
{
|
|
return (new ValueObjectConstResult (exe_scope,
|
|
error))->GetSP();
|
|
}
|
|
|
|
ValueObjectConstResult::ValueObjectConstResult (
|
|
ExecutionContextScope *exe_scope,
|
|
const Error& error) :
|
|
ValueObject (exe_scope),
|
|
m_clang_ast (NULL),
|
|
m_type_name (),
|
|
m_byte_size (0),
|
|
m_impl(this)
|
|
{
|
|
m_error = error;
|
|
SetIsConstant ();
|
|
}
|
|
|
|
ValueObjectConstResult::~ValueObjectConstResult()
|
|
{
|
|
}
|
|
|
|
lldb::clang_type_t
|
|
ValueObjectConstResult::GetClangType()
|
|
{
|
|
return m_value.GetClangType();
|
|
}
|
|
|
|
lldb::ValueType
|
|
ValueObjectConstResult::GetValueType() const
|
|
{
|
|
return eValueTypeConstResult;
|
|
}
|
|
|
|
size_t
|
|
ValueObjectConstResult::GetByteSize()
|
|
{
|
|
if (m_byte_size == 0)
|
|
m_byte_size = ClangASTType::GetTypeByteSize(GetClangAST(), GetClangType());
|
|
return m_byte_size;
|
|
}
|
|
|
|
void
|
|
ValueObjectConstResult::SetByteSize (size_t size)
|
|
{
|
|
m_byte_size = size;
|
|
}
|
|
|
|
uint32_t
|
|
ValueObjectConstResult::CalculateNumChildren()
|
|
{
|
|
return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true);
|
|
}
|
|
|
|
clang::ASTContext *
|
|
ValueObjectConstResult::GetClangAST ()
|
|
{
|
|
return m_clang_ast;
|
|
}
|
|
|
|
ConstString
|
|
ValueObjectConstResult::GetTypeName()
|
|
{
|
|
if (m_type_name.IsEmpty())
|
|
m_type_name = ClangASTType::GetConstTypeName (GetClangType());
|
|
return m_type_name;
|
|
}
|
|
|
|
bool
|
|
ValueObjectConstResult::UpdateValue ()
|
|
{
|
|
// Const value is always valid
|
|
SetValueIsValid (true);
|
|
return true;
|
|
}
|
|
|
|
|
|
bool
|
|
ValueObjectConstResult::IsInScope ()
|
|
{
|
|
// A const result value is always in scope since it serializes all
|
|
// information needed to contain the constant value.
|
|
return true;
|
|
}
|
|
|
|
lldb::ValueObjectSP
|
|
ValueObjectConstResult::Dereference (Error &error)
|
|
{
|
|
return m_impl.Dereference(error);
|
|
}
|
|
|
|
lldb::ValueObjectSP
|
|
ValueObjectConstResult::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type, bool can_create)
|
|
{
|
|
return m_impl.GetSyntheticChildAtOffset(offset, type, can_create);
|
|
}
|
|
|
|
lldb::ValueObjectSP
|
|
ValueObjectConstResult::AddressOf (Error &error)
|
|
{
|
|
return m_impl.AddressOf(error);
|
|
}
|
|
|
|
ValueObject *
|
|
ValueObjectConstResult::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int32_t synthetic_index)
|
|
{
|
|
return m_impl.CreateChildAtIndex(idx, synthetic_array_member, synthetic_index);
|
|
}
|
|
|
|
size_t
|
|
ValueObjectConstResult::GetPointeeData (DataExtractor& data,
|
|
uint32_t item_idx,
|
|
uint32_t item_count)
|
|
{
|
|
return m_impl.GetPointeeData(data, item_idx, item_count);
|
|
}
|