[Lldb-commits] [lldb] r227274 - Preparatory infrastructural work to support dynamically determining sizes of ObjC types via the runtime
Enrico Granata
egranata at apple.com
Tue Jan 27 16:07:52 PST 2015
Author: enrico
Date: Tue Jan 27 18:07:51 2015
New Revision: 227274
URL: http://llvm.org/viewvc/llvm-project?rev=227274&view=rev
Log:
Preparatory infrastructural work to support dynamically determining sizes of ObjC types via the runtime
This is necessary because the byte size of an ObjC class type is not reliably statically knowable (e.g. because superclasses sit deep in frameworks that we have no debug info for)
The lack of reliable size info is a problem when trying to freeze-dry an ObjC instance (not the pointer, the pointee)
This commit lays the foundation for having language runtimes help in figuring out byte sizes, and having ClangASTType ask for runtime help
No feature change as no runtime actually implements the logic, and nowhere is an ExecutionContext passed in yet
Modified:
lldb/trunk/include/lldb/Symbol/ClangASTType.h
lldb/trunk/include/lldb/Target/LanguageRuntime.h
lldb/trunk/include/lldb/Utility/ProcessStructReader.h
lldb/trunk/source/API/SBType.cpp
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Core/Value.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectConstResult.cpp
lldb/trunk/source/Core/ValueObjectMemory.cpp
lldb/trunk/source/Core/ValueObjectVariable.cpp
lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
lldb/trunk/source/DataFormatters/LibCxx.cpp
lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp
lldb/trunk/source/DataFormatters/LibCxxVector.cpp
lldb/trunk/source/Expression/IRForTarget.cpp
lldb/trunk/source/Expression/Materializer.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Symbol/ClangASTType.cpp
lldb/trunk/source/Symbol/Type.cpp
Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Tue Jan 27 18:07:51 2015
@@ -347,10 +347,10 @@ public:
//----------------------------------------------------------------------
uint64_t
- GetByteSize () const;
+ GetByteSize (ExecutionContext *exe_ctx) const;
uint64_t
- GetBitSize () const;
+ GetBitSize (ExecutionContext *exe_ctx) const;
lldb::Encoding
GetEncoding (uint64_t &count) const;
Modified: lldb/trunk/include/lldb/Target/LanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/LanguageRuntime.h?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/LanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/LanguageRuntime.h Tue Jan 27 18:07:51 2015
@@ -102,6 +102,13 @@ public:
virtual lldb::SearchFilterSP
CreateExceptionSearchFilter ();
+
+ virtual bool
+ GetTypeBitSize (const ClangASTType& clang_type,
+ uint64_t &size)
+ {
+ return false;
+ }
protected:
//------------------------------------------------------------------
Modified: lldb/trunk/include/lldb/Utility/ProcessStructReader.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ProcessStructReader.h?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/ProcessStructReader.h (original)
+++ lldb/trunk/include/lldb/Utility/ProcessStructReader.h Tue Jan 27 18:07:51 2015
@@ -59,7 +59,7 @@ namespace lldb_private {
// no support for bitfields in here (yet)
if (is_bitfield)
return;
- auto size = field_type.GetByteSize();
+ auto size = field_type.GetByteSize(nullptr);
// no support for things larger than a uint64_t (yet)
if (size > 8)
return;
@@ -67,7 +67,7 @@ namespace lldb_private {
size_t byte_index = static_cast<size_t>(bit_offset / 8);
m_fields[const_name] = FieldImpl{field_type, byte_index, static_cast<size_t>(size)};
}
- size_t total_size = struct_type.GetByteSize();
+ size_t total_size = struct_type.GetByteSize(nullptr);
lldb::DataBufferSP buffer_sp(new DataBufferHeap(total_size,0));
Error error;
process->ReadMemoryFromInferior(base_addr,
Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Tue Jan 27 18:07:51 2015
@@ -143,7 +143,7 @@ SBType::GetByteSize()
if (!IsValid())
return 0;
- return m_opaque_sp->GetClangASTType(false).GetByteSize();
+ return m_opaque_sp->GetClangASTType(false).GetByteSize(nullptr);
}
Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Jan 27 18:07:51 2015
@@ -567,7 +567,7 @@ protected:
--pointer_count;
}
- m_format_options.GetByteSizeValue() = clang_ast_type.GetByteSize();
+ m_format_options.GetByteSizeValue() = clang_ast_type.GetByteSize(nullptr);
if (m_format_options.GetByteSizeValue() == 0)
{
@@ -690,7 +690,7 @@ protected:
if (m_format_options.GetFormatValue().OptionWasSet() == false)
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
- bytes_read = clang_ast_type.GetByteSize() * m_format_options.GetCountValue().GetCurrentValue();
+ bytes_read = clang_ast_type.GetByteSize(nullptr) * m_format_options.GetCountValue().GetCurrentValue();
}
else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString)
{
@@ -1114,7 +1114,7 @@ protected:
if (process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp) && result_sp.get())
{
uint64_t value = result_sp->GetValueAsUnsigned(0);
- switch (result_sp->GetClangType().GetByteSize())
+ switch (result_sp->GetClangType().GetByteSize(nullptr))
{
case 1: {
uint8_t byte = (uint8_t)value;
Modified: lldb/trunk/source/Core/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Core/Value.cpp (original)
+++ lldb/trunk/source/Core/Value.cpp Tue Jan 27 18:07:51 2015
@@ -277,7 +277,7 @@ Value::GetValueByteSize (Error *error_pt
{
const ClangASTType &ast_type = GetClangType();
if (ast_type.IsValid())
- byte_size = ast_type.GetByteSize();
+ byte_size = ast_type.GetByteSize(nullptr);
}
break;
}
@@ -434,7 +434,7 @@ Value::GetValueAsData (ExecutionContext
lldb::Encoding type_encoding = ast_type.GetEncoding(type_encoding_count);
if (type_encoding == eEncodingUint || type_encoding == eEncodingSint)
- limit_byte_size = ast_type.GetByteSize();
+ limit_byte_size = ast_type.GetByteSize(nullptr);
}
if (m_value.GetData (data, limit_byte_size))
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Tue Jan 27 18:07:51 2015
@@ -971,7 +971,7 @@ ValueObject::GetPointeeData (DataExtract
if (item_count == 0)
return 0;
- const uint64_t item_type_size = pointee_or_element_clang_type.GetByteSize();
+ const uint64_t item_type_size = pointee_or_element_clang_type.GetByteSize(nullptr);
const uint64_t bytes = item_count * item_type_size;
const uint64_t offset = item_idx * item_type_size;
@@ -1047,7 +1047,7 @@ ValueObject::GetPointeeData (DataExtract
break;
case eAddressTypeHost:
{
- const uint64_t max_bytes = GetClangType().GetByteSize();
+ const uint64_t max_bytes = GetClangType().GetByteSize(nullptr);
if (max_bytes > offset)
{
size_t bytes_read = std::min<uint64_t>(max_bytes - offset, bytes);
@@ -2225,7 +2225,7 @@ ValueObject::GetSyntheticChildAtOffset(u
ValueObjectChild *synthetic_child = new ValueObjectChild(*this,
type,
name_const_str,
- type.GetByteSize(),
+ type.GetByteSize(nullptr),
offset,
0,
0,
@@ -2266,7 +2266,7 @@ ValueObject::GetSyntheticBase (uint32_t
ValueObjectChild *synthetic_child = new ValueObjectChild(*this,
type,
name_const_str,
- type.GetByteSize(),
+ type.GetByteSize(nullptr),
offset,
0,
0,
Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Tue Jan 27 18:07:51 2015
@@ -257,7 +257,7 @@ uint64_t
ValueObjectConstResult::GetByteSize()
{
if (m_byte_size == 0)
- m_byte_size = GetClangType().GetByteSize();
+ m_byte_size = GetClangType().GetByteSize(nullptr);
return m_byte_size;
}
Modified: lldb/trunk/source/Core/ValueObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectMemory.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectMemory.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectMemory.cpp Tue Jan 27 18:07:51 2015
@@ -169,7 +169,7 @@ ValueObjectMemory::GetByteSize()
{
if (m_type_sp)
return m_type_sp->GetByteSize();
- return m_clang_type.GetByteSize ();
+ return m_clang_type.GetByteSize (nullptr);
}
lldb::ValueType
Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Tue Jan 27 18:07:51 2015
@@ -110,7 +110,7 @@ ValueObjectVariable::GetByteSize()
if (!type.IsValid())
return 0;
- return type.GetByteSize();
+ return type.GetByteSize(nullptr);
}
lldb::ValueType
Modified: lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp Tue Jan 27 18:07:51 2015
@@ -317,7 +317,7 @@ lldb_private::formatters::WCharStringSum
return false;
ClangASTType wchar_clang_type = ClangASTContext::GetBasicType(ast, lldb::eBasicTypeWChar);
- const uint32_t wchar_size = wchar_clang_type.GetBitSize();
+ const uint32_t wchar_size = wchar_clang_type.GetBitSize(nullptr);
ReadStringAndDumpToStreamOptions options(valobj);
options.SetLocation(data_addr);
Modified: lldb/trunk/source/DataFormatters/LibCxx.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxx.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxx.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxx.cpp Tue Jan 27 18:07:51 2015
@@ -139,7 +139,7 @@ lldb_private::formatters::LibcxxVectorBo
return ValueObjectSP();
}
bool bit_set = ((byte & mask) != 0);
- DataBufferSP buffer_sp(new DataBufferHeap(m_bool_type.GetByteSize(),0));
+ DataBufferSP buffer_sp(new DataBufferHeap(m_bool_type.GetByteSize(nullptr),0));
if (bit_set && buffer_sp && buffer_sp->GetBytes())
*(buffer_sp->GetBytes()) = 1; // regardless of endianness, anything non-zero is true
StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx);
Modified: lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxInitializerList.cpp Tue Jan 27 18:07:51 2015
@@ -107,7 +107,7 @@ lldb_private::formatters::LibcxxInitiali
if (kind != lldb::eTemplateArgumentKindType || false == m_element_type.IsValid())
return false;
- m_element_size = m_element_type.GetByteSize();
+ m_element_size = m_element_type.GetByteSize(nullptr);
if (m_element_size > 0)
m_start = m_backend.GetChildMemberWithName(g___begin_,true).get(); // store raw pointers or end up with a circular dependency
Modified: lldb/trunk/source/DataFormatters/LibCxxVector.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxVector.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxVector.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxVector.cpp Tue Jan 27 18:07:51 2015
@@ -115,7 +115,7 @@ lldb_private::formatters::LibcxxStdVecto
if (!data_type_finder_sp)
return false;
m_element_type = data_type_finder_sp->GetClangType().GetPointeeType();
- m_element_size = m_element_type.GetByteSize();
+ m_element_size = m_element_type.GetByteSize(nullptr);
if (m_element_size > 0)
{
Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Jan 27 18:07:51 2015
@@ -590,7 +590,7 @@ IRForTarget::CreateResultVariable (llvm:
&result_decl->getASTContext());
}
- if (m_result_type.GetBitSize() == 0)
+ if (m_result_type.GetBitSize(nullptr) == 0)
{
lldb_private::StreamString type_desc_stream;
m_result_type.DumpTypeDescription(&type_desc_stream);
@@ -617,7 +617,7 @@ IRForTarget::CreateResultVariable (llvm:
if (log)
log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64,
m_result_name.GetCString(),
- m_result_type.GetByteSize());
+ m_result_type.GetByteSize(nullptr));
// Construct a new result global and set up its metadata
@@ -1518,7 +1518,7 @@ IRForTarget::MaybeHandleVariable (Value
value_type = global_variable->getType();
}
- const uint64_t value_size = clang_type.GetByteSize();
+ const uint64_t value_size = clang_type.GetByteSize(nullptr);
lldb::offset_t value_alignment = (clang_type.GetTypeBitAlign() + 7ull) / 8ull;
if (log)
Modified: lldb/trunk/source/Expression/Materializer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Expression/Materializer.cpp (original)
+++ lldb/trunk/source/Expression/Materializer.cpp Tue Jan 27 18:07:51 2015
@@ -49,7 +49,7 @@ Materializer::AddStructMember (Entity &e
void
Materializer::Entity::SetSizeAndAlignmentFromType (ClangASTType &type)
{
- m_size = type.GetByteSize();
+ m_size = type.GetByteSize(nullptr);
uint32_t bit_alignment = type.GetTypeBitAlign();
@@ -780,7 +780,7 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
- size_t byte_size = m_type.GetByteSize();
+ size_t byte_size = m_type.GetByteSize(nullptr);
size_t bit_align = m_type.GetTypeBitAlign();
size_t byte_align = (bit_align + 7) / 8;
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Tue Jan 27 18:07:51 2015
@@ -334,11 +334,11 @@ ABIMacOSX_arm::GetArgumentValues (Thread
size_t bit_width = 0;
if (clang_type.IsIntegerType (is_signed))
{
- bit_width = clang_type.GetBitSize();
+ bit_width = clang_type.GetBitSize(nullptr);
}
else if (clang_type.IsPointerOrReferenceType ())
{
- bit_width = clang_type.GetBitSize();
+ bit_width = clang_type.GetBitSize(nullptr);
}
else
{
@@ -437,7 +437,7 @@ ABIMacOSX_arm::GetReturnValueObjectImpl
const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0);
if (clang_type.IsIntegerType (is_signed))
{
- size_t bit_width = clang_type.GetBitSize();
+ size_t bit_width = clang_type.GetBitSize(nullptr);
switch (bit_width)
{
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp Tue Jan 27 18:07:51 2015
@@ -322,11 +322,11 @@ ABIMacOSX_arm64::GetArgumentValues (Thre
size_t bit_width = 0;
if (value_type.IsIntegerType (is_signed))
{
- bit_width = value_type.GetBitSize();
+ bit_width = value_type.GetBitSize(nullptr);
}
else if (value_type.IsPointerOrReferenceType ())
{
- bit_width = value_type.GetBitSize();
+ bit_width = value_type.GetBitSize(nullptr);
}
else
{
@@ -709,7 +709,7 @@ LoadValueFromConsecutiveGPRRegisters (Ex
uint32_t &NSRN, // NSRN (see ABI documentation)
DataExtractor &data)
{
- const size_t byte_size = value_type.GetByteSize();
+ const size_t byte_size = value_type.GetByteSize(nullptr);
if (byte_size == 0)
return false;
@@ -728,7 +728,7 @@ LoadValueFromConsecutiveGPRRegisters (Ex
{
if (!base_type)
return false;
- const size_t base_byte_size = base_type.GetByteSize();
+ const size_t base_byte_size = base_type.GetByteSize(nullptr);
printf ("ClangASTContext::IsHomogeneousAggregate() => base_byte_size = %" PRIu64 "\n", (uint64_t) base_byte_size);
uint32_t data_offset = 0;
@@ -871,7 +871,7 @@ ABIMacOSX_arm64::GetReturnValueObjectImp
if (!reg_ctx)
return return_valobj_sp;
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
const uint32_t type_flags = return_clang_type.GetTypeInfo (NULL);
if (type_flags & eTypeIsScalar ||
Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Tue Jan 27 18:07:51 2015
@@ -552,7 +552,7 @@ ABIMacOSX_i386::GetArgumentValues (Threa
if (clang_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(),
+ clang_type.GetBitSize(nullptr),
is_signed,
thread.GetProcess().get(),
current_stack_argument);
@@ -560,7 +560,7 @@ ABIMacOSX_i386::GetArgumentValues (Threa
else if (clang_type.IsPointerType())
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(),
+ clang_type.GetBitSize(nullptr),
false,
thread.GetProcess().get(),
current_stack_argument);
@@ -672,7 +672,7 @@ ABIMacOSX_i386::GetReturnValueObjectImpl
if (clang_type.IsIntegerType (is_signed))
{
- size_t bit_width = clang_type.GetBitSize();
+ size_t bit_width = clang_type.GetBitSize(nullptr);
unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB];
Modified: lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp Tue Jan 27 18:07:51 2015
@@ -444,7 +444,7 @@ ABISysV_ppc::GetArgumentValues (Thread &
if (clang_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(),
+ clang_type.GetBitSize(nullptr),
is_signed,
thread,
argument_register_ids,
@@ -454,7 +454,7 @@ ABISysV_ppc::GetArgumentValues (Thread &
else if (clang_type.IsPointerType ())
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(),
+ clang_type.GetBitSize(nullptr),
false,
thread,
argument_register_ids,
@@ -524,7 +524,7 @@ ABISysV_ppc::SetReturnValueObject(lldb::
error.SetErrorString ("We don't support returning complex values at present");
else
{
- size_t bit_width = clang_type.GetBitSize();
+ size_t bit_width = clang_type.GetBitSize(nullptr);
if (bit_width <= 64)
{
DataExtractor data;
@@ -588,7 +588,7 @@ ABISysV_ppc::GetReturnValueObjectSimple
{
// Extract the register context so we can read arguments from registers
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r3", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
switch (byte_size)
@@ -637,7 +637,7 @@ ABISysV_ppc::GetReturnValueObjectSimple
}
else
{
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
if (byte_size <= sizeof(long double))
{
const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
@@ -681,7 +681,7 @@ ABISysV_ppc::GetReturnValueObjectSimple
}
else if (type_flags & eTypeIsVector)
{
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
if (byte_size > 0)
{
@@ -742,7 +742,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (T
if (!reg_ctx_sp)
return return_valobj_sp;
- const size_t bit_width = return_clang_type.GetBitSize();
+ const size_t bit_width = return_clang_type.GetBitSize(nullptr);
if (return_clang_type.IsAggregateType())
{
Target *target = exe_ctx.GetTargetPtr();
@@ -784,7 +784,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (T
uint32_t count;
ClangASTType field_clang_type = return_clang_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
- const size_t field_bit_width = field_clang_type.GetBitSize();
+ const size_t field_bit_width = field_clang_type.GetBitSize(nullptr);
// If there are any unaligned fields, this is stored in memory.
if (field_bit_offset % field_bit_width != 0)
Modified: lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp Tue Jan 27 18:07:51 2015
@@ -444,7 +444,7 @@ ABISysV_ppc64::GetArgumentValues (Thread
if (clang_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(),
+ clang_type.GetBitSize(nullptr),
is_signed,
thread,
argument_register_ids,
@@ -454,7 +454,7 @@ ABISysV_ppc64::GetArgumentValues (Thread
else if (clang_type.IsPointerType ())
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(),
+ clang_type.GetBitSize(nullptr),
false,
thread,
argument_register_ids,
@@ -524,7 +524,7 @@ ABISysV_ppc64::SetReturnValueObject(lldb
error.SetErrorString ("We don't support returning complex values at present");
else
{
- size_t bit_width = clang_type.GetBitSize();
+ size_t bit_width = clang_type.GetBitSize(nullptr);
if (bit_width <= 64)
{
DataExtractor data;
@@ -588,7 +588,7 @@ ABISysV_ppc64::GetReturnValueObjectSimpl
{
// Extract the register context so we can read arguments from registers
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r3", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
switch (byte_size)
@@ -637,7 +637,7 @@ ABISysV_ppc64::GetReturnValueObjectSimpl
}
else
{
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
if (byte_size <= sizeof(long double))
{
const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
@@ -681,7 +681,7 @@ ABISysV_ppc64::GetReturnValueObjectSimpl
}
else if (type_flags & eTypeIsVector)
{
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
if (byte_size > 0)
{
@@ -742,7 +742,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl
if (!reg_ctx_sp)
return return_valobj_sp;
- const size_t bit_width = return_clang_type.GetBitSize();
+ const size_t bit_width = return_clang_type.GetBitSize(nullptr);
if (return_clang_type.IsAggregateType())
{
Target *target = exe_ctx.GetTargetPtr();
@@ -784,7 +784,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl
uint32_t count;
ClangASTType field_clang_type = return_clang_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
- const size_t field_bit_width = field_clang_type.GetBitSize();
+ const size_t field_bit_width = field_clang_type.GetBitSize(nullptr);
// If there are any unaligned fields, this is stored in memory.
if (field_bit_offset % field_bit_width != 0)
Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Tue Jan 27 18:07:51 2015
@@ -510,7 +510,7 @@ ABISysV_x86_64::GetArgumentValues (Threa
if (clang_type.IsIntegerType (is_signed))
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(),
+ clang_type.GetBitSize(nullptr),
is_signed,
thread,
argument_register_ids,
@@ -520,7 +520,7 @@ ABISysV_x86_64::GetArgumentValues (Threa
else if (clang_type.IsPointerType ())
{
ReadIntegerArgument(value->GetScalar(),
- clang_type.GetBitSize(),
+ clang_type.GetBitSize(nullptr),
false,
thread,
argument_register_ids,
@@ -590,7 +590,7 @@ ABISysV_x86_64::SetReturnValueObject(lld
error.SetErrorString ("We don't support returning complex values at present");
else
{
- size_t bit_width = clang_type.GetBitSize();
+ size_t bit_width = clang_type.GetBitSize(nullptr);
if (bit_width <= 64)
{
const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
@@ -658,7 +658,7 @@ ABISysV_x86_64::GetReturnValueObjectSimp
{
// Extract the register context so we can read arguments from registers
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("rax", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
switch (byte_size)
@@ -707,7 +707,7 @@ ABISysV_x86_64::GetReturnValueObjectSimp
}
else
{
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
if (byte_size <= sizeof(long double))
{
const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
@@ -755,7 +755,7 @@ ABISysV_x86_64::GetReturnValueObjectSimp
}
else if (type_flags & eTypeIsVector)
{
- const size_t byte_size = return_clang_type.GetByteSize();
+ const size_t byte_size = return_clang_type.GetByteSize(nullptr);
if (byte_size > 0)
{
@@ -821,7 +821,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl
if (!reg_ctx_sp)
return return_valobj_sp;
- const size_t bit_width = return_clang_type.GetBitSize();
+ const size_t bit_width = return_clang_type.GetBitSize(nullptr);
if (return_clang_type.IsAggregateType())
{
Target *target = exe_ctx.GetTargetPtr();
@@ -869,7 +869,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl
uint32_t count;
ClangASTType field_clang_type = return_clang_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
- const size_t field_bit_width = field_clang_type.GetBitSize();
+ const size_t field_bit_width = field_clang_type.GetBitSize(nullptr);
// If there are any unaligned fields, this is stored in memory.
if (field_bit_offset % field_bit_width != 0)
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Jan 27 18:07:51 2015
@@ -6984,7 +6984,7 @@ SymbolFileDWARF::ParseType (const Symbol
clang_type = pointee_clang_type.CreateMemberPointerType(class_clang_type);
- byte_size = clang_type.GetByteSize();
+ byte_size = clang_type.GetByteSize(nullptr);
type_sp.reset( new Type (MakeUserID(die->GetOffset()),
this,
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Jan 27 18:07:51 2015
@@ -708,7 +708,7 @@ uint32_t
ClangASTContext::GetPointerByteSize ()
{
if (m_pointer_byte_size == 0)
- m_pointer_byte_size = GetBasicType(lldb::eBasicTypeVoid).GetPointerType().GetByteSize();
+ m_pointer_byte_size = GetBasicType(lldb::eBasicTypeVoid).GetPointerType().GetByteSize(nullptr);
return m_pointer_byte_size;
}
Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Tue Jan 27 18:07:51 2015
@@ -1663,7 +1663,7 @@ ClangASTType::GetArrayElementType (uint6
// TODO: the real stride will be >= this value.. find the real one!
if (stride)
- *stride = element_type.GetByteSize();
+ *stride = element_type.GetByteSize(nullptr);
return element_type;
@@ -2062,28 +2062,45 @@ ClangASTType::GetBasicTypeFromAST (lldb:
//----------------------------------------------------------------------
uint64_t
-ClangASTType::GetBitSize () const
+ClangASTType::GetBitSize (ExecutionContext *exe_ctx) const
{
if (GetCompleteType ())
{
clang::QualType qual_type(GetCanonicalQualType());
- const uint32_t bit_size = m_ast->getTypeSize (qual_type);
- if (bit_size == 0)
+ switch (qual_type->getTypeClass())
{
- if (qual_type->isIncompleteArrayType())
- return m_ast->getTypeSize (qual_type->getArrayElementTypeNoTypeQual()->getCanonicalTypeUnqualified());
+ case clang::Type::ObjCInterface:
+ case clang::Type::ObjCObject:
+ if (exe_ctx && exe_ctx->GetProcessPtr())
+ {
+ ObjCLanguageRuntime *objc_runtime = exe_ctx->GetProcessPtr()->GetObjCLanguageRuntime();
+ if (objc_runtime)
+ {
+ uint64_t bit_size = 0;
+ if (objc_runtime->GetTypeBitSize(*this, bit_size))
+ return bit_size;
+ }
+ }
+ // fallthrough
+ default:
+ const uint32_t bit_size = m_ast->getTypeSize (qual_type);
+ if (bit_size == 0)
+ {
+ if (qual_type->isIncompleteArrayType())
+ return m_ast->getTypeSize (qual_type->getArrayElementTypeNoTypeQual()->getCanonicalTypeUnqualified());
+ }
+ if (qual_type->isObjCObjectOrInterfaceType())
+ return bit_size + m_ast->getTypeSize(m_ast->ObjCBuiltinClassTy);
+ return bit_size;
}
- if (qual_type->isObjCObjectOrInterfaceType())
- return bit_size + m_ast->getTypeSize(m_ast->ObjCBuiltinClassTy);
- return bit_size;
}
return 0;
}
uint64_t
-ClangASTType::GetByteSize () const
+ClangASTType::GetByteSize (ExecutionContext *exe_ctx) const
{
- return (GetBitSize () + 7) / 8;
+ return (GetBitSize (exe_ctx) + 7) / 8;
}
size_t
@@ -3416,7 +3433,7 @@ ClangASTType::GetChildClangTypeAtIndex (
child_byte_offset = bit_offset/8;
ClangASTType base_class_clang_type(m_ast, base_class->getType());
child_name = base_class_clang_type.GetTypeName().AsCString("");
- uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize();
+ uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize(nullptr);
// Base classes bit sizes should be a multiple of 8 bits in size
assert (base_class_clang_type_bit_size % 8 == 0);
@@ -3444,7 +3461,7 @@ ClangASTType::GetChildClangTypeAtIndex (
// alignment (field_type_info.second) from the AST context.
ClangASTType field_clang_type (m_ast, field->getType());
assert(field_idx < record_layout.getFieldCount());
- child_byte_size = field_clang_type.GetByteSize();
+ child_byte_size = field_clang_type.GetByteSize(nullptr);
// Figure out the field offset within the current struct/union/class type
bit_offset = record_layout.getFieldOffset (field_idx);
@@ -3609,7 +3626,7 @@ ClangASTType::GetChildClangTypeAtIndex (
// We have a pointer to an simple type
if (idx == 0 && pointee_clang_type.GetCompleteType())
{
- child_byte_size = pointee_clang_type.GetByteSize();
+ child_byte_size = pointee_clang_type.GetByteSize(nullptr);
child_byte_offset = 0;
return pointee_clang_type;
}
@@ -3630,7 +3647,7 @@ ClangASTType::GetChildClangTypeAtIndex (
char element_name[64];
::snprintf (element_name, sizeof (element_name), "[%zu]", idx);
child_name.assign(element_name);
- child_byte_size = element_type.GetByteSize();
+ child_byte_size = element_type.GetByteSize(nullptr);
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
return element_type;
}
@@ -3651,7 +3668,7 @@ ClangASTType::GetChildClangTypeAtIndex (
char element_name[64];
::snprintf (element_name, sizeof (element_name), "[%zu]", idx);
child_name.assign(element_name);
- child_byte_size = element_type.GetByteSize();
+ child_byte_size = element_type.GetByteSize(nullptr);
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
return element_type;
}
@@ -3701,7 +3718,7 @@ ClangASTType::GetChildClangTypeAtIndex (
// We have a pointer to an simple type
if (idx == 0)
{
- child_byte_size = pointee_clang_type.GetByteSize();
+ child_byte_size = pointee_clang_type.GetByteSize(nullptr);
child_byte_offset = 0;
return pointee_clang_type;
}
@@ -3745,7 +3762,7 @@ ClangASTType::GetChildClangTypeAtIndex (
// We have a pointer to an simple type
if (idx == 0)
{
- child_byte_size = pointee_clang_type.GetByteSize();
+ child_byte_size = pointee_clang_type.GetByteSize(nullptr);
child_byte_offset = 0;
return pointee_clang_type;
}
@@ -6643,7 +6660,7 @@ ClangASTType::GetValueAsScalar (const ll
if (encoding == lldb::eEncodingInvalid || count != 1)
return false;
- const uint64_t byte_size = GetByteSize();
+ const uint64_t byte_size = GetByteSize(nullptr);
lldb::offset_t offset = data_byte_offset;
switch (encoding)
{
@@ -6771,7 +6788,7 @@ ClangASTType::SetValueFromScalar (const
if (encoding == lldb::eEncodingInvalid || count != 1)
return false;
- const uint64_t bit_width = GetBitSize();
+ const uint64_t bit_width = GetBitSize(nullptr);
// This function doesn't currently handle non-byte aligned assignments
if ((bit_width % 8) != 0)
return false;
@@ -6851,7 +6868,7 @@ ClangASTType::ReadFromMemory (lldb_priva
if (!GetCompleteType())
return false;
- const uint64_t byte_size = GetByteSize();
+ const uint64_t byte_size = GetByteSize(nullptr);
if (data.GetByteSize() < byte_size)
{
lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
@@ -6901,7 +6918,7 @@ ClangASTType::WriteToMemory (lldb_privat
if (!GetCompleteType())
return false;
- const uint64_t byte_size = GetByteSize();
+ const uint64_t byte_size = GetByteSize(nullptr);
if (byte_size > 0)
{
Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=227274&r1=227273&r2=227274&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Tue Jan 27 18:07:51 2015
@@ -336,7 +336,7 @@ Type::GetByteSize()
if (encoding_type)
m_byte_size = encoding_type->GetByteSize();
if (m_byte_size == 0)
- m_byte_size = GetClangLayoutType().GetByteSize();
+ m_byte_size = GetClangLayoutType().GetByteSize(nullptr);
}
break;
More information about the lldb-commits
mailing list