diff options
Diffstat (limited to 'source/Symbol')
-rw-r--r-- | source/Symbol/ClangASTContext.cpp | 8 | ||||
-rw-r--r-- | source/Symbol/ClangASTType.cpp | 31 | ||||
-rw-r--r-- | source/Symbol/FuncUnwinders.cpp | 2 | ||||
-rw-r--r-- | source/Symbol/Function.cpp | 38 | ||||
-rw-r--r-- | source/Symbol/Symbol.cpp | 37 | ||||
-rw-r--r-- | source/Symbol/Type.cpp | 10 | ||||
-rw-r--r-- | source/Symbol/Variable.cpp | 7 |
7 files changed, 116 insertions, 17 deletions
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp index 5ba9c6a8d796..4f30ccfc0de5 100644 --- a/source/Symbol/ClangASTContext.cpp +++ b/source/Symbol/ClangASTContext.cpp @@ -1152,12 +1152,18 @@ ClangASTContext::CreateRecordType (DeclContext *decl_ctx, // the CXXRecordDecl class since we often don't know from debug information // if something is struct or a class, so we default to always use the more // complete definition just in case. + + bool is_anonymous = (!name) || (!name[0]); + CXXRecordDecl *decl = CXXRecordDecl::Create (*ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(), SourceLocation(), - name && name[0] ? &ast->Idents.get(name) : NULL); + is_anonymous ? NULL : &ast->Idents.get(name)); + + if (is_anonymous) + decl->setAnonymousStructOrUnion(true); if (decl) { diff --git a/source/Symbol/ClangASTType.cpp b/source/Symbol/ClangASTType.cpp index 0dfabcc931fb..40f6462ee360 100644 --- a/source/Symbol/ClangASTType.cpp +++ b/source/Symbol/ClangASTType.cpp @@ -38,6 +38,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/Stream.h" +#include "lldb/Core/StreamFile.h" #include "lldb/Core/StreamString.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ClangExternalASTSourceCommon.h" @@ -413,7 +414,7 @@ ClangASTType::GetNumberOfFunctionArguments () const QualType qual_type (GetCanonicalQualType()); const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr()); if (func) - return func->getNumArgs(); + return func->getNumParams(); } return 0; } @@ -427,8 +428,8 @@ ClangASTType::GetFunctionArgumentAtIndex (const size_t index) const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr()); if (func) { - if (index < func->getNumArgs()) - return ClangASTType(m_ast, func->getArgType(index).getAsOpaquePtr()); + if (index < func->getNumParams()) + return ClangASTType(m_ast, func->getParamType(index).getAsOpaquePtr()); } } return ClangASTType(); @@ -1134,7 +1135,7 @@ ClangASTType::GetTypeName () const if (typedef_type) { const TypedefNameDecl *typedef_decl = typedef_type->getDecl(); - type_name = typedef_decl->getQualifiedNameAsString(printing_policy); + type_name = typedef_decl->getQualifiedNameAsString(); } else { @@ -1595,7 +1596,7 @@ ClangASTType::GetFunctionArgumentCount () const { const FunctionProtoType* func = dyn_cast<FunctionProtoType>(GetCanonicalQualType()); if (func) - return func->getNumArgs(); + return func->getNumParams(); } return -1; } @@ -1608,9 +1609,9 @@ ClangASTType::GetFunctionArgumentTypeAtIndex (size_t idx) const FunctionProtoType* func = dyn_cast<FunctionProtoType>(GetCanonicalQualType()); if (func) { - const uint32_t num_args = func->getNumArgs(); + const uint32_t num_args = func->getNumParams(); if (idx < num_args) - return ClangASTType(m_ast, func->getArgType(idx)); + return ClangASTType(m_ast, func->getParamType(idx)); } } return ClangASTType(); @@ -1624,7 +1625,7 @@ ClangASTType::GetFunctionReturnType () const QualType qual_type(GetCanonicalQualType()); const FunctionProtoType* func = dyn_cast<FunctionProtoType>(qual_type.getTypePtr()); if (func) - return ClangASTType(m_ast, func->getResultType()); + return ClangASTType(m_ast, func->getReturnType()); } return ClangASTType(); } @@ -4647,7 +4648,7 @@ ClangASTType::AddMethodToCXXRecordType (const char *name, if (!method_function_prototype) return NULL; - unsigned int num_params = method_function_prototype->getNumArgs(); + unsigned int num_params = method_function_prototype->getNumParams(); CXXDestructorDecl *cxx_dtor_decl(NULL); CXXConstructorDecl *cxx_ctor_decl(NULL); @@ -4714,7 +4715,7 @@ ClangASTType::AddMethodToCXXRecordType (const char *name, cxx_method_decl = CXXConversionDecl::Create (*m_ast, cxx_record_decl, SourceLocation(), - DeclarationNameInfo (m_ast->DeclarationNames.getCXXConversionFunctionName (m_ast->getCanonicalType (function_type->getResultType())), SourceLocation()), + DeclarationNameInfo (m_ast->DeclarationNames.getCXXConversionFunctionName (m_ast->getCanonicalType (function_type->getReturnType())), SourceLocation()), method_qual_type, NULL, // TypeSourceInfo * is_inline, @@ -4745,7 +4746,7 @@ ClangASTType::AddMethodToCXXRecordType (const char *name, cxx_method_decl->setVirtualAsWritten (is_virtual); if (is_attr_used) - cxx_method_decl->addAttr(::new (*m_ast) UsedAttr(SourceRange(), *m_ast)); + cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*m_ast)); // Populate the method decl with parameter decls @@ -4760,7 +4761,7 @@ ClangASTType::AddMethodToCXXRecordType (const char *name, SourceLocation(), SourceLocation(), NULL, // anonymous - method_function_prototype->getArgType(param_index), + method_function_prototype->getParamType(param_index), NULL, SC_None, NULL)); @@ -5133,7 +5134,7 @@ ClangASTType::AddMethodToObjCObjectType (const char *name, // the full symbol n bool is_defined = false; ObjCMethodDecl::ImplementationControl imp_control = ObjCMethodDecl::None; - const unsigned num_args = method_function_prototype->getNumArgs(); + const unsigned num_args = method_function_prototype->getNumParams(); if (num_args != num_selectors_with_args) return NULL; // some debug information is corrupt. We are not going to deal with it. @@ -5142,7 +5143,7 @@ ClangASTType::AddMethodToObjCObjectType (const char *name, // the full symbol n SourceLocation(), // beginLoc, SourceLocation(), // endLoc, method_selector, - method_function_prototype->getResultType(), + method_function_prototype->getReturnType(), NULL, // TypeSourceInfo *ResultTInfo, GetDeclContextForType (), name[0] == '-', @@ -5168,7 +5169,7 @@ ClangASTType::AddMethodToObjCObjectType (const char *name, // the full symbol n SourceLocation(), SourceLocation(), NULL, // anonymous - method_function_prototype->getArgType(param_index), + method_function_prototype->getParamType(param_index), NULL, SC_Auto, NULL)); diff --git a/source/Symbol/FuncUnwinders.cpp b/source/Symbol/FuncUnwinders.cpp index 68b05ade4bd0..134dbf5f50db 100644 --- a/source/Symbol/FuncUnwinders.cpp +++ b/source/Symbol/FuncUnwinders.cpp @@ -28,7 +28,7 @@ using namespace lldb_private; FuncUnwinders::FuncUnwinders ( UnwindTable& unwind_table, - UnwindAssembly *assembly_profiler, + const lldb::UnwindAssemblySP& assembly_profiler, AddressRange range ) : m_unwind_table(unwind_table), diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp index 31334a6df8d7..e6d6c000bc97 100644 --- a/source/Symbol/Function.cpp +++ b/source/Symbol/Function.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/Symbol/Function.h" +#include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Host/Host.h" @@ -404,6 +405,43 @@ Function::CalculateSymbolContextFunction () return this; } +lldb::DisassemblerSP +Function::GetInstructions (const ExecutionContext &exe_ctx, + const char *flavor, + bool prefer_file_cache) +{ + ModuleSP module_sp (GetAddressRange().GetBaseAddress().GetModule()); + if (module_sp) + { + const bool prefer_file_cache = false; + return Disassembler::DisassembleRange (module_sp->GetArchitecture(), + NULL, + flavor, + exe_ctx, + GetAddressRange(), + prefer_file_cache); + } + return lldb::DisassemblerSP(); +} + +bool +Function::GetDisassembly (const ExecutionContext &exe_ctx, + const char *flavor, + bool prefer_file_cache, + Stream &strm) +{ + lldb::DisassemblerSP disassembler_sp = GetInstructions (exe_ctx, flavor, prefer_file_cache); + if (disassembler_sp) + { + const bool show_address = true; + const bool show_bytes = false; + disassembler_sp->GetInstructionList().Dump (&strm, show_address, show_bytes, &exe_ctx); + return true; + } + return false; +} + + //Symbol * //Function::CalculateSymbolContextSymbol () //{ diff --git a/source/Symbol/Symbol.cpp b/source/Symbol/Symbol.cpp index a881b6f31012..6311a329739e 100644 --- a/source/Symbol/Symbol.cpp +++ b/source/Symbol/Symbol.cpp @@ -580,3 +580,40 @@ Symbol::ResolveReExportedSymbol (Target &target) } return NULL; } + + +lldb::DisassemblerSP +Symbol::GetInstructions (const ExecutionContext &exe_ctx, + const char *flavor, + bool prefer_file_cache) +{ + ModuleSP module_sp (m_addr_range.GetBaseAddress().GetModule()); + if (module_sp) + { + const bool prefer_file_cache = false; + return Disassembler::DisassembleRange (module_sp->GetArchitecture(), + NULL, + flavor, + exe_ctx, + m_addr_range, + prefer_file_cache); + } + return lldb::DisassemblerSP(); +} + +bool +Symbol::GetDisassembly (const ExecutionContext &exe_ctx, + const char *flavor, + bool prefer_file_cache, + Stream &strm) +{ + lldb::DisassemblerSP disassembler_sp = GetInstructions (exe_ctx, flavor, prefer_file_cache); + if (disassembler_sp) + { + const bool show_address = true; + const bool show_bytes = false; + disassembler_sp->GetInstructionList().Dump (&strm, show_address, show_bytes, &exe_ctx); + return true; + } + return false; +} diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp index 32a1d474053f..073940e8a7f7 100644 --- a/source/Symbol/Type.cpp +++ b/source/Symbol/Type.cpp @@ -1084,6 +1084,16 @@ TypeImpl::GetReferenceType () const } TypeImpl +TypeImpl::GetTypedefedType () const +{ + if (m_dynamic_type.IsValid()) + { + return TypeImpl(m_static_type, m_dynamic_type.GetTypedefedType()); + } + return TypeImpl(m_static_type.GetTypedefedType()); +} + +TypeImpl TypeImpl::GetDereferencedType () const { if (m_dynamic_type.IsValid()) diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp index 7276e0a4a1a2..36fe3b1d79d4 100644 --- a/source/Symbol/Variable.cpp +++ b/source/Symbol/Variable.cpp @@ -832,10 +832,17 @@ PrivateAutoComplete (StackFrame *frame, VariableList *variable_list = frame->GetVariableList(get_file_globals); + if (!variable_list) + break; + const size_t num_variables = variable_list->GetSize(); for (size_t i=0; i<num_variables; ++i) { Variable *variable = variable_list->GetVariableAtIndex(i).get(); + + if (!variable) + continue; + const char *variable_name = variable->GetName().AsCString(); if (strstr(variable_name, token.c_str()) == variable_name) { |