diff options
Diffstat (limited to 'source/Symbol')
-rw-r--r-- | source/Symbol/ClangASTContext.cpp | 4 | ||||
-rw-r--r-- | source/Symbol/ClangASTType.cpp | 106 | ||||
-rw-r--r-- | source/Symbol/CompactUnwindInfo.cpp | 29 | ||||
-rw-r--r-- | source/Symbol/SymbolContext.cpp | 68 | ||||
-rw-r--r-- | source/Symbol/Type.cpp | 16 | ||||
-rw-r--r-- | source/Symbol/Variable.cpp | 3 |
6 files changed, 178 insertions, 48 deletions
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp index d851ae792181..da25eb84f19e 100644 --- a/source/Symbol/ClangASTContext.cpp +++ b/source/Symbol/ClangASTContext.cpp @@ -11,7 +11,7 @@ // C Includes // C++ Includes -#include <mutex> +#include <mutex> // std::once #include <string> // Other libraries and framework includes @@ -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; } diff --git a/source/Symbol/ClangASTType.cpp b/source/Symbol/ClangASTType.cpp index 8b672fac4312..eaff90ab8a0a 100644 --- a/source/Symbol/ClangASTType.cpp +++ b/source/Symbol/ClangASTType.cpp @@ -290,6 +290,37 @@ ClangASTType::IsArrayType (ClangASTType *element_type_ptr, } bool +ClangASTType::IsVectorType (ClangASTType *element_type, + uint64_t *size) const +{ + if (IsValid()) + { + clang::QualType qual_type (GetCanonicalQualType()); + + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) + { + case clang::Type::Vector: + { + const clang::VectorType *vector_type = qual_type->getAs<clang::VectorType>(); + if (vector_type) + { + if (size) + *size = vector_type->getNumElements(); + if (element_type) + *element_type = ClangASTType(m_ast, vector_type->getElementType().getAsOpaquePtr()); + } + return true; + } + break; + default: + break; + } + } + return false; +} + +bool ClangASTType::IsRuntimeGeneratedType () const { if (!IsValid()) @@ -1663,7 +1694,7 @@ ClangASTType::GetArrayElementType (uint64_t *stride) const // 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 +2093,59 @@ ClangASTType::GetBasicTypeFromAST (lldb::BasicType basic_type) const //---------------------------------------------------------------------- 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; + } + } + else + { + static bool g_printed = false; + if (!g_printed) + { + StreamString s; + s.Printf("warning: trying to determine the size of type "); + DumpTypeDescription(&s); + s.Printf("\n without a valid ExecutionContext. this is not reliable. please file a bug against LLDB.\nbacktrace:\n"); + Host::Backtrace(s, 10); + printf("%s\n", s.GetData()); + g_printed = true; + } + } + // 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 +3478,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, 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 +3506,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, // 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(exe_ctx); // Figure out the field offset within the current struct/union/class type bit_offset = record_layout.getFieldOffset (field_idx); @@ -3609,7 +3671,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, // 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(exe_ctx); child_byte_offset = 0; return pointee_clang_type; } @@ -3630,7 +3692,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, 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(exe_ctx); child_byte_offset = (int32_t)idx * (int32_t)child_byte_size; return element_type; } @@ -3651,7 +3713,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, 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(exe_ctx); child_byte_offset = (int32_t)idx * (int32_t)child_byte_size; return element_type; } @@ -3701,7 +3763,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, // 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(exe_ctx); child_byte_offset = 0; return pointee_clang_type; } @@ -3745,7 +3807,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx, // 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(exe_ctx); child_byte_offset = 0; return pointee_clang_type; } @@ -6643,7 +6705,7 @@ ClangASTType::GetValueAsScalar (const lldb_private::DataExtractor &data, 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 +6833,7 @@ ClangASTType::SetValueFromScalar (const Scalar &value, Stream &strm) 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 +6913,7 @@ ClangASTType::ReadFromMemory (lldb_private::ExecutionContext *exe_ctx, if (!GetCompleteType()) return false; - const uint64_t byte_size = GetByteSize(); + const uint64_t byte_size = GetByteSize(exe_ctx); if (data.GetByteSize() < byte_size) { lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0')); @@ -6901,7 +6963,7 @@ ClangASTType::WriteToMemory (lldb_private::ExecutionContext *exe_ctx, if (!GetCompleteType()) return false; - const uint64_t byte_size = GetByteSize(); + const uint64_t byte_size = GetByteSize(exe_ctx); if (byte_size > 0) { diff --git a/source/Symbol/CompactUnwindInfo.cpp b/source/Symbol/CompactUnwindInfo.cpp index 8c6a2e7214c3..e7153446cd16 100644 --- a/source/Symbol/CompactUnwindInfo.cpp +++ b/source/Symbol/CompactUnwindInfo.cpp @@ -809,8 +809,16 @@ CompactUnwindInfo::CreateUnwindPlan_x86_64 (Target &target, FunctionInfo &functi } } + if (mode == UNWIND_X86_64_MODE_STACK_IND) + { + row->SetCFAOffset (stack_size); + } + else + { + row->SetCFAOffset (stack_size * wordsize); + } + row->SetCFARegister (x86_64_eh_regnum::rsp); - row->SetCFAOffset (stack_size * wordsize); row->SetOffset (0); row->SetRegisterLocationToAtCFAPlusOffset (x86_64_eh_regnum::rip, wordsize * -1, true); row->SetRegisterLocationToIsCFAPlusOffset (x86_64_eh_regnum::rsp, 0, true); @@ -919,10 +927,10 @@ CompactUnwindInfo::CreateUnwindPlan_x86_64 (Target &target, FunctionInfo &functi case UNWIND_X86_64_REG_R14: case UNWIND_X86_64_REG_R15: case UNWIND_X86_64_REG_RBP: - row->SetRegisterLocationToAtCFAPlusOffset (translate_to_eh_frame_regnum_x86_64 (registers[i]), wordsize * -saved_registers_offset, true); + row->SetRegisterLocationToAtCFAPlusOffset (translate_to_eh_frame_regnum_x86_64 (registers[i]), wordsize * -saved_registers_offset, true); + saved_registers_offset++; break; } - saved_registers_offset++; } } unwind_plan.AppendRow (row); @@ -1084,7 +1092,16 @@ CompactUnwindInfo::CreateUnwindPlan_i386 (Target &target, FunctionInfo &function } row->SetCFARegister (i386_eh_regnum::esp); - row->SetCFAOffset (stack_size * wordsize); + + if (mode == UNWIND_X86_MODE_STACK_IND) + { + row->SetCFAOffset (stack_size); + } + else + { + row->SetCFAOffset (stack_size * wordsize); + } + row->SetOffset (0); row->SetRegisterLocationToAtCFAPlusOffset (i386_eh_regnum::eip, wordsize * -1, true); row->SetRegisterLocationToIsCFAPlusOffset (i386_eh_regnum::esp, 0, true); @@ -1193,10 +1210,10 @@ CompactUnwindInfo::CreateUnwindPlan_i386 (Target &target, FunctionInfo &function case UNWIND_X86_REG_EDI: case UNWIND_X86_REG_ESI: case UNWIND_X86_REG_EBP: - row->SetRegisterLocationToAtCFAPlusOffset (translate_to_eh_frame_regnum_i386 (registers[i]), wordsize * -saved_registers_offset, true); + row->SetRegisterLocationToAtCFAPlusOffset (translate_to_eh_frame_regnum_i386 (registers[i]), wordsize * -saved_registers_offset, true); + saved_registers_offset++; break; } - saved_registers_offset++; } } diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp index 129f4def0067..62ae6ac464ce 100644 --- a/source/Symbol/SymbolContext.cpp +++ b/source/Symbol/SymbolContext.cpp @@ -13,7 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/Host.h" -#include "lldb/Interpreter/Args.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompileUnit.h" @@ -21,6 +21,7 @@ #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" +#include "lldb/Symbol/Variable.h" #include "lldb/Target/Target.h" using namespace lldb; @@ -33,7 +34,8 @@ SymbolContext::SymbolContext() : function (nullptr), block (nullptr), line_entry (), - symbol (nullptr) + symbol (nullptr), + variable (nullptr) { } @@ -44,7 +46,8 @@ SymbolContext::SymbolContext(const ModuleSP& m, CompileUnit *cu, Function *f, Bl function (f), block (b), line_entry (), - symbol (s) + symbol (s), + variable (nullptr) { if (le) line_entry = *le; @@ -57,7 +60,8 @@ SymbolContext::SymbolContext(const TargetSP &t, const ModuleSP& m, CompileUnit * function (f), block (b), line_entry (), - symbol (s) + symbol (s), + variable (nullptr) { if (le) line_entry = *le; @@ -70,7 +74,8 @@ SymbolContext::SymbolContext(const SymbolContext& rhs) : function (rhs.function), block (rhs.block), line_entry (rhs.line_entry), - symbol (rhs.symbol) + symbol (rhs.symbol), + variable (rhs.variable) { } @@ -82,7 +87,8 @@ SymbolContext::SymbolContext (SymbolContextScope *sc_scope) : function (nullptr), block (nullptr), line_entry (), - symbol (nullptr) + symbol (nullptr), + variable (nullptr) { sc_scope->CalculateSymbolContext (this); } @@ -103,6 +109,7 @@ SymbolContext::operator= (const SymbolContext& rhs) block = rhs.block; line_entry = rhs.line_entry; symbol = rhs.symbol; + variable = rhs.variable; } return *this; } @@ -118,6 +125,7 @@ SymbolContext::Clear(bool clear_target) block = nullptr; line_entry.Clear(); symbol = nullptr; + variable = nullptr; } bool @@ -309,6 +317,37 @@ SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *t symbol->GetDescription(s, level, target); s->EOL(); } + + if (variable != nullptr) + { + s->Indent(" Variable: "); + + s->Printf("id = {0x%8.8" PRIx64 "}, ", variable->GetID()); + + switch (variable->GetScope()) + { + case eValueTypeVariableGlobal: + s->PutCString("kind = global, "); + break; + + case eValueTypeVariableStatic: + s->PutCString("kind = static, "); + break; + + case eValueTypeVariableArgument: + s->PutCString("kind = argument, "); + break; + + case eValueTypeVariableLocal: + s->PutCString("kind = local, "); + break; + + default: + break; + } + + s->Printf ("name = \"%s\"\n", variable->GetName().GetCString()); + } } uint32_t @@ -322,6 +361,7 @@ SymbolContext::GetResolvedMask () const if (block) resolved_mask |= eSymbolContextBlock; if (line_entry.IsValid()) resolved_mask |= eSymbolContextLineEntry; if (symbol) resolved_mask |= eSymbolContextSymbol; + if (variable) resolved_mask |= eSymbolContextVariable; return resolved_mask; } @@ -377,6 +417,12 @@ SymbolContext::Dump(Stream *s, Target *target) const if (symbol != nullptr && symbol->GetMangled()) *s << ' ' << symbol->GetMangled().GetName().AsCString(); s->EOL(); + *s << "Variable = " << (void *)variable; + if (variable != nullptr) + { + *s << " {0x" << variable->GetID() << "} " << variable->GetType()->GetName(); + s->EOL(); + } s->IndentLess(); s->IndentLess(); } @@ -389,7 +435,8 @@ lldb_private::operator== (const SymbolContext& lhs, const SymbolContext& rhs) && lhs.module_sp.get() == rhs.module_sp.get() && lhs.comp_unit == rhs.comp_unit && lhs.target_sp.get() == rhs.target_sp.get() - && LineEntry::Compare(lhs.line_entry, rhs.line_entry) == 0; + && LineEntry::Compare(lhs.line_entry, rhs.line_entry) == 0 + && lhs.variable == rhs.variable; } bool @@ -400,7 +447,8 @@ lldb_private::operator!= (const SymbolContext& lhs, const SymbolContext& rhs) || lhs.module_sp.get() != rhs.module_sp.get() || lhs.comp_unit != rhs.comp_unit || lhs.target_sp.get() != rhs.target_sp.get() - || LineEntry::Compare(lhs.line_entry, rhs.line_entry) != 0; + || LineEntry::Compare(lhs.line_entry, rhs.line_entry) != 0 + || lhs.variable != rhs.variable; } bool @@ -730,12 +778,12 @@ SymbolContextSpecifier::AddSpecification (const char *spec_string, Specification m_type |= eFileSpecified; break; case eLineStartSpecified: - m_start_line = Args::StringToSInt32(spec_string, 0, 0, &return_value); + m_start_line = StringConvert::ToSInt32(spec_string, 0, 0, &return_value); if (return_value) m_type |= eLineStartSpecified; break; case eLineEndSpecified: - m_end_line = Args::StringToSInt32(spec_string, 0, 0, &return_value); + m_end_line = StringConvert::ToSInt32(spec_string, 0, 0, &return_value); if (return_value) m_type |= eLineEndSpecified; break; diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp index 42b76590aaea..6e67f4695d9f 100644 --- a/source/Symbol/Type.cpp +++ b/source/Symbol/Type.cpp @@ -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; @@ -1141,7 +1141,7 @@ TypeImpl::GetPointerType () const { if (m_dynamic_type.IsValid()) { - return TypeImpl(m_static_type, m_dynamic_type.GetPointerType()); + return TypeImpl(m_static_type.GetPointerType(), m_dynamic_type.GetPointerType()); } return TypeImpl(m_static_type.GetPointerType()); } @@ -1156,7 +1156,7 @@ TypeImpl::GetPointeeType () const { if (m_dynamic_type.IsValid()) { - return TypeImpl(m_static_type, m_dynamic_type.GetPointeeType()); + return TypeImpl(m_static_type.GetPointeeType(), m_dynamic_type.GetPointeeType()); } return TypeImpl(m_static_type.GetPointeeType()); } @@ -1171,7 +1171,7 @@ TypeImpl::GetReferenceType () const { if (m_dynamic_type.IsValid()) { - return TypeImpl(m_static_type, m_dynamic_type.GetLValueReferenceType()); + return TypeImpl(m_static_type.GetReferenceType(), m_dynamic_type.GetLValueReferenceType()); } return TypeImpl(m_static_type.GetReferenceType()); } @@ -1186,7 +1186,7 @@ TypeImpl::GetTypedefedType () const { if (m_dynamic_type.IsValid()) { - return TypeImpl(m_static_type, m_dynamic_type.GetTypedefedType()); + return TypeImpl(m_static_type.GetTypedefedType(), m_dynamic_type.GetTypedefedType()); } return TypeImpl(m_static_type.GetTypedefedType()); } @@ -1201,7 +1201,7 @@ TypeImpl::GetDereferencedType () const { if (m_dynamic_type.IsValid()) { - return TypeImpl(m_static_type, m_dynamic_type.GetNonReferenceType()); + return TypeImpl(m_static_type.GetDereferencedType(), m_dynamic_type.GetNonReferenceType()); } return TypeImpl(m_static_type.GetDereferencedType()); } @@ -1216,7 +1216,7 @@ TypeImpl::GetUnqualifiedType() const { if (m_dynamic_type.IsValid()) { - return TypeImpl(m_static_type, m_dynamic_type.GetFullyUnqualifiedType()); + return TypeImpl(m_static_type.GetUnqualifiedType(), m_dynamic_type.GetFullyUnqualifiedType()); } return TypeImpl(m_static_type.GetUnqualifiedType()); } @@ -1231,7 +1231,7 @@ TypeImpl::GetCanonicalType() const { if (m_dynamic_type.IsValid()) { - return TypeImpl(m_static_type, m_dynamic_type.GetCanonicalType()); + return TypeImpl(m_static_type.GetCanonicalType(), m_dynamic_type.GetCanonicalType()); } return TypeImpl(m_static_type.GetCanonicalType()); } diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp index b1a60f6b4a24..4c03a307296d 100644 --- a/source/Symbol/Variable.cpp +++ b/source/Symbol/Variable.cpp @@ -203,7 +203,10 @@ void Variable::CalculateSymbolContext (SymbolContext *sc) { if (m_owner_scope) + { m_owner_scope->CalculateSymbolContext(sc); + sc->variable = this; + } else sc->Clear(false); } |