mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-14 12:22:27 +00:00

debug information and you evaluated an expression, a crash would occur as a result of an unchecked pointer. Added the ability to get the expression path for a ValueObject. For a rectangle point child "x" the expression path would be something like: "rect.top_left.x". This will allow GUI and command lines to get ahold of the expression path for a value object without having to explicitly know about the hierarchy. This means the ValueObject base class now has a "ValueObject *m_parent;" member. All ValueObject subclasses now correctly track their lineage and are able to provide value expression paths as well. Added a new "--flat" option to the "frame variable" to allow for flat variable output. An example of the current and new outputs: (lldb) frame variable argc = 1 argv = 0x00007fff5fbffe80 pt = { x = 2 y = 3 } rect = { bottom_left = { x = 1 y = 2 } top_right = { x = 3 y = 4 } } (lldb) frame variable --flat argc = 1 argv = 0x00007fff5fbffe80 pt.x = 2 pt.y = 3 rect.bottom_left.x = 1 rect.bottom_left.y = 2 rect.top_right.x = 3 rect.top_right.y = 4 As you can see when there is a lot of hierarchy it can help flatten things out. Also if you want to use a member in an expression, you can copy the text from the "--flat" output and not have to piece it together manually. This can help when you want to use parts of the STL in expressions: (lldb) frame variable --flat argc = 1 argv = 0x00007fff5fbffea8 hello_world._M_dataplus._M_p = 0x0000000000000000 (lldb) expr hello_world._M_dataplus._M_p[0] == '\0' llvm-svn: 116532
120 lines
2.8 KiB
C++
120 lines
2.8 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/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;
|
|
|
|
ValueObjectConstResult::ValueObjectConstResult
|
|
(
|
|
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
|
|
) :
|
|
ValueObject (NULL),
|
|
m_clang_ast (clang_ast),
|
|
m_type_name ()
|
|
{
|
|
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::eContextTypeOpaqueClangQualType, clang_type);
|
|
m_name = name;
|
|
SetIsConstant ();
|
|
}
|
|
|
|
ValueObjectConstResult::ValueObjectConstResult (const Error& error) :
|
|
ValueObject (NULL),
|
|
m_clang_ast (NULL),
|
|
m_type_name ()
|
|
{
|
|
m_error = error;
|
|
SetIsConstant ();
|
|
}
|
|
|
|
ValueObjectConstResult::~ValueObjectConstResult()
|
|
{
|
|
}
|
|
|
|
void *
|
|
ValueObjectConstResult::GetClangType()
|
|
{
|
|
return m_value.GetClangType();
|
|
}
|
|
|
|
lldb::ValueType
|
|
ValueObjectConstResult::GetValueType() const
|
|
{
|
|
return eValueTypeConstResult;
|
|
}
|
|
|
|
size_t
|
|
ValueObjectConstResult::GetByteSize()
|
|
{
|
|
// We stored all the data for this const object in our data
|
|
return m_data.GetByteSize();
|
|
}
|
|
|
|
uint32_t
|
|
ValueObjectConstResult::CalculateNumChildren()
|
|
{
|
|
return ClangASTContext::GetNumChildren (GetClangType(), true);
|
|
}
|
|
|
|
clang::ASTContext *
|
|
ValueObjectConstResult::GetClangAST ()
|
|
{
|
|
return m_clang_ast;
|
|
}
|
|
|
|
ConstString
|
|
ValueObjectConstResult::GetTypeName()
|
|
{
|
|
if (m_type_name.IsEmpty())
|
|
m_type_name = ClangASTType::GetClangTypeName (GetClangType());
|
|
return m_type_name;
|
|
}
|
|
|
|
void
|
|
ValueObjectConstResult::UpdateValue (ExecutionContextScope *exe_scope)
|
|
{
|
|
m_error.Clear();
|
|
// Const value is always valid
|
|
SetValueIsValid (true);
|
|
}
|
|
|
|
|
|
bool
|
|
ValueObjectConstResult::IsInScope (StackFrame *frame)
|
|
{
|
|
// A const result value is always in scope since it serializes all
|
|
// information needed to contain the constant value.
|
|
return true;
|
|
}
|