diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /include/lldb/Symbol | |
parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) | |
download | src-5f29bb8a675e8f96452b632e7129113f7dec850e.tar.gz src-5f29bb8a675e8f96452b632e7129113f7dec850e.zip |
Vendor import of stripped lldb trunk r366426 (just before the release_90
branch point):
https://llvm.org/svn/llvm-project/lldb/trunk@366426
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=351290
Diffstat (limited to 'include/lldb/Symbol')
42 files changed, 1272 insertions, 1593 deletions
diff --git a/include/lldb/Symbol/ArmUnwindInfo.h b/include/lldb/Symbol/ArmUnwindInfo.h index 422408b034c6..a74b4442df14 100644 --- a/include/lldb/Symbol/ArmUnwindInfo.h +++ b/include/lldb/Symbol/ArmUnwindInfo.h @@ -1,21 +1,19 @@ //===-- ArmUnwindInfo.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_ArmUnwindInfo_h_ #define liblldb_ArmUnwindInfo_h_ -#include <vector> - -#include "lldb/Core/RangeMap.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" +#include <vector> /* * Unwind information reader and parser for the ARM exception handling ABI diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h index 2428a1d3ffca..36d0944f12b0 100644 --- a/include/lldb/Symbol/Block.h +++ b/include/lldb/Symbol/Block.h @@ -1,31 +1,28 @@ //===-- Block.h -------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_Block_h_ #define liblldb_Block_h_ -#include <vector> - #include "lldb/Core/AddressRange.h" -#include "lldb/Core/RangeMap.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/SymbolContextScope.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" +#include <vector> namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Block Block.h "lldb/Symbol/Block.h" +/// \class Block Block.h "lldb/Symbol/Block.h" /// A class that describes a single lexical block. /// /// A Function object owns a BlockList object which owns one or more @@ -41,20 +38,18 @@ namespace lldb_private { /// Inlined functions are represented by attaching a InlineFunctionInfo shared /// pointer object to a block. Inlined functions are represented as named /// blocks. -//---------------------------------------------------------------------- class Block : public UserID, public SymbolContextScope { public: typedef RangeArray<uint32_t, uint32_t, 1> RangeList; typedef RangeList::Entry Range; - //------------------------------------------------------------------ /// Construct with a User ID \a uid, \a depth. /// /// Initialize this block with the specified UID \a uid. The \a depth in the /// \a block_list is used to represent the parent, sibling, and child block /// information and also allows for partial parsing at the block level. /// - /// @param[in] uid + /// \param[in] uid /// The UID for a given block. This value is given by the /// SymbolFile plug-in and can be any value that helps the /// SymbolFile plug-in to match this block back to the debug @@ -62,50 +57,41 @@ public: /// depth parsing. Common values would be the index into a /// table, or an offset into the debug information. /// - /// @param[in] depth + /// \param[in] depth /// The integer depth of this block in the block list hierarchy. /// - /// @param[in] block_list + /// \param[in] block_list /// The block list that this object belongs to. /// - /// @see BlockList - //------------------------------------------------------------------ + /// \see BlockList Block(lldb::user_id_t uid); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~Block() override; - //------------------------------------------------------------------ /// Add a child to this object. /// - /// @param[in] child_block_sp + /// \param[in] child_block_sp /// A shared pointer to a child block that will get added to /// this block. - //------------------------------------------------------------------ void AddChild(const lldb::BlockSP &child_block_sp); - //------------------------------------------------------------------ /// Add a new offset range to this block. /// - /// @param[in] start_offset + /// \param[in] start_offset /// An offset into this Function's address range that /// describes the start address of a range for this block. /// - /// @param[in] end_offset + /// \param[in] end_offset /// An offset into this Function's address range that /// describes the end address of a range for this block. - //------------------------------------------------------------------ void AddRange(const Range &range); void FinalizeRanges(); - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) + /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void CalculateSymbolContext(SymbolContext *sc) override; lldb::ModuleSP CalculateSymbolContextModule() override; @@ -116,69 +102,59 @@ public: Block *CalculateSymbolContextBlock() override; - //------------------------------------------------------------------ /// Check if an offset is in one of the block offset ranges. /// - /// @param[in] range_offset + /// \param[in] range_offset /// An offset into the Function's address range. /// - /// @return + /// \return /// Returns \b true if \a range_offset falls in one of this /// block's ranges, \b false otherwise. - //------------------------------------------------------------------ bool Contains(lldb::addr_t range_offset) const; - //------------------------------------------------------------------ /// Check if a offset range is in one of the block offset ranges. /// - /// @param[in] range + /// \param[in] range /// An offset range into the Function's address range. /// - /// @return + /// \return /// Returns \b true if \a range falls in one of this /// block's ranges, \b false otherwise. - //------------------------------------------------------------------ bool Contains(const Range &range) const; - //------------------------------------------------------------------ /// Check if this object contains "block" as a child block at any depth. /// - /// @param[in] block + /// \param[in] block /// A potential child block. /// - /// @return + /// \return /// Returns \b true if \a block is a child of this block, \b /// false otherwise. - //------------------------------------------------------------------ bool Contains(const Block *block) const; - //------------------------------------------------------------------ /// Dump the block contents. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] base_addr + /// \param[in] base_addr /// The resolved start address of the Function's address /// range. This should be resolved as the file or load address /// prior to passing the value into this function for dumping. /// - /// @param[in] depth + /// \param[in] depth /// Limit the number of levels deep that this function should /// print as this block can contain child blocks. Specify /// INT_MAX to dump all child blocks. /// - /// @param[in] show_context + /// \param[in] show_context /// If \b true, variables will dump their context information. - //------------------------------------------------------------------ void Dump(Stream *s, lldb::addr_t base_addr, int32_t depth, bool show_context) const; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) + /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void DumpSymbolContext(Stream *s) override; void DumpAddressRanges(Stream *s, lldb::addr_t base_addr); @@ -186,185 +162,177 @@ public: void GetDescription(Stream *s, Function *function, lldb::DescriptionLevel level, Target *target) const; - //------------------------------------------------------------------ /// Get the parent block. /// - /// @return + /// \return /// The parent block pointer, or nullptr if this block has no /// parent. - //------------------------------------------------------------------ Block *GetParent() const; - //------------------------------------------------------------------ /// Get the inlined block that contains this block. /// - /// @return + /// \return /// If this block contains inlined function info, it will return /// this block, else parent blocks will be searched to see if /// any contain this block. nullptr will be returned if this block /// nor any parent blocks are inlined function blocks. - //------------------------------------------------------------------ Block *GetContainingInlinedBlock(); - //------------------------------------------------------------------ /// Get the inlined parent block for this block. /// - /// @return + /// \return /// The parent block pointer, or nullptr if this block has no /// parent. - //------------------------------------------------------------------ Block *GetInlinedParent(); //------------------------------------------------------------------ - /// Get the sibling block for this block. + /// Get the inlined block at the given call site that contains this block. + /// + /// @param[in] find_call_site + /// a declaration with the file and line of the call site to find. /// /// @return + /// If this block contains inlined function info and is at the call + /// site given by the file and line at the given \b declaration, then + /// it will return this block, otherwise the parent blocks will be + /// searched to see if any is at the call site. nullptr will be returned + /// if no block is found at the call site. + //------------------------------------------------------------------ + Block * + GetContainingInlinedBlockWithCallSite(const Declaration &find_call_site); + + /// Get the sibling block for this block. + /// + /// \return /// The sibling block pointer, or nullptr if this block has no /// sibling. - //------------------------------------------------------------------ Block *GetSibling() const; - //------------------------------------------------------------------ /// Get the first child block. /// - /// @return + /// \return /// The first child block pointer, or nullptr if this block has no /// children. - //------------------------------------------------------------------ Block *GetFirstChild() const { return (m_children.empty() ? nullptr : m_children.front().get()); } - //------------------------------------------------------------------ /// Get the variable list for this block only. /// - /// @param[in] can_create + /// \param[in] can_create /// If \b true, the variables can be parsed if they already /// haven't been, else the current state of the block will be /// returned. /// - /// @return + /// \return /// A variable list shared pointer that contains all variables /// for this block. - //------------------------------------------------------------------ lldb::VariableListSP GetBlockVariableList(bool can_create); - //------------------------------------------------------------------ /// Get the variable list for this block and optionally all child blocks if /// \a get_child_variables is \b true. /// - /// @param[in] get_child_variables + /// \param[in] get_child_variables /// If \b true, all variables from all child blocks will be /// added to the variable list. /// - /// @param[in] can_create + /// \param[in] can_create /// If \b true, the variables can be parsed if they already /// haven't been, else the current state of the block will be /// returned. Passing \b true for this parameter can be used /// to see the current state of what has been parsed up to this /// point. /// - /// @param[in] add_inline_child_block_variables + /// \param[in] add_inline_child_block_variables /// If this is \b false, no child variables of child blocks /// that are inlined functions will be gotten. If \b true then /// all child variables will be added regardless of whether they /// come from inlined functions or not. /// - /// @return + /// \return /// A variable list shared pointer that contains all variables /// for this block. - //------------------------------------------------------------------ uint32_t AppendBlockVariables(bool can_create, bool get_child_block_variables, bool stop_if_child_block_is_inlined_function, const std::function<bool(Variable *)> &filter, VariableList *variable_list); - //------------------------------------------------------------------ /// Appends the variables from this block, and optionally from all parent /// blocks, to \a variable_list. /// - /// @param[in] can_create + /// \param[in] can_create /// If \b true, the variables can be parsed if they already /// haven't been, else the current state of the block will be /// returned. Passing \b true for this parameter can be used /// to see the current state of what has been parsed up to this /// point. /// - /// @param[in] get_parent_variables + /// \param[in] get_parent_variables /// If \b true, all variables from all parent blocks will be /// added to the variable list. /// - /// @param[in] stop_if_block_is_inlined_function + /// \param[in] stop_if_block_is_inlined_function /// If \b true, all variables from all parent blocks will be /// added to the variable list until there are no parent blocks /// or the parent block has inlined function info. /// - /// @param[in,out] variable_list + /// \param[in,out] variable_list /// All variables in this block, and optionally all parent /// blocks will be added to this list. /// - /// @return + /// \return /// The number of variable that were appended to \a /// variable_list. - //------------------------------------------------------------------ uint32_t AppendVariables(bool can_create, bool get_parent_variables, bool stop_if_block_is_inlined_function, const std::function<bool(Variable *)> &filter, VariableList *variable_list); - //------------------------------------------------------------------ /// Get const accessor for any inlined function information. /// - /// @return + /// \return /// A const pointer to any inlined function information, or nullptr /// if this is a regular block. - //------------------------------------------------------------------ const InlineFunctionInfo *GetInlinedFunctionInfo() const { return m_inlineInfoSP.get(); } - //------------------------------------------------------------------ /// Get the symbol file which contains debug info for this block's /// symbol context module. /// - /// @return A pointer to the symbol file or nullptr. - //------------------------------------------------------------------ + /// \return A pointer to the symbol file or nullptr. SymbolFile *GetSymbolFile(); CompilerDeclContext GetDeclContext(); - //------------------------------------------------------------------ /// Get the memory cost of this object. /// /// Returns the cost of this object plus any owned objects from the ranges, /// variables, and inline function information. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. - //------------------------------------------------------------------ size_t MemorySize() const; - //------------------------------------------------------------------ /// Set accessor for any inlined function information. /// - /// @param[in] name + /// \param[in] name /// The method name for the inlined function. This value should /// not be nullptr. /// - /// @param[in] mangled + /// \param[in] mangled /// The mangled method name for the inlined function. This can /// be nullptr if there is no mangled name for an inlined function /// or if the name is the same as \a name. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// A optional pointer to declaration information for the /// inlined function information. This value can be nullptr to /// indicate that no declaration information is available. /// - /// @param[in] call_decl_ptr + /// \param[in] call_decl_ptr /// Optional calling location declaration information that /// describes from where this inlined function was called. - //------------------------------------------------------------------ void SetInlinedFunctionInfo(const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr); @@ -373,15 +341,13 @@ public: m_parent_scope = parent_scope; } - //------------------------------------------------------------------ /// Set accessor for the variable list. /// /// Called by the SymbolFile plug-ins after they have parsed the variable /// lists and are ready to hand ownership of the list over to this object. /// - /// @param[in] variable_list_sp + /// \param[in] variable_list_sp /// A shared pointer to a VariableList. - //------------------------------------------------------------------ void SetVariableList(lldb::VariableListSP &variable_list_sp) { m_variable_list_sp = variable_list_sp; } @@ -403,10 +369,8 @@ public: uint32_t GetRangeIndexContainingAddress(const Address &addr); - //------------------------------------------------------------------ // Since blocks might have multiple discontiguous address ranges, we need to // be able to get at any of the address ranges in a block. - //------------------------------------------------------------------ bool GetRangeAtIndex(uint32_t range_idx, AddressRange &range); bool GetStartAddress(Address &addr); @@ -415,9 +379,7 @@ public: protected: typedef std::vector<lldb::BlockSP> collection; - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ SymbolContextScope *m_parent_scope; collection m_children; RangeList m_ranges; diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h index 4cff9b256570..d0a834e01f3a 100644 --- a/include/lldb/Symbol/ClangASTContext.h +++ b/include/lldb/Symbol/ClangASTContext.h @@ -1,9 +1,8 @@ //===-- ClangASTContext.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -47,25 +46,19 @@ public: typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton, clang::ObjCInterfaceDecl *); - //------------------------------------------------------------------ // llvm casting support - //------------------------------------------------------------------ static bool classof(const TypeSystem *ts) { return ts->getKind() == TypeSystem::eKindClang; } - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ ClangASTContext(const char *triple = nullptr); ~ClangASTContext() override; void Finalize() override; - //------------------------------------------------------------------ // PluginInterface functions - //------------------------------------------------------------------ ConstString GetPluginName() override; uint32_t GetPluginVersion() override; @@ -111,6 +104,9 @@ public: clang::TargetInfo *getTargetInfo(); + void setSema(clang::Sema *s); + clang::Sema *getSema() { return m_sema; } + void Clear(); const char *GetTargetTriple(); @@ -122,7 +118,7 @@ public: bool HasExternalSource(); void SetExternalSource( - llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_ap); + llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up); void RemoveExternalSource(); @@ -154,9 +150,7 @@ public: static ClangASTMetadata *GetMetadata(clang::ASTContext *ast, const void *object); - //------------------------------------------------------------------ // Basic Types - //------------------------------------------------------------------ CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override; @@ -169,9 +163,9 @@ public: lldb::BasicType type); static CompilerType GetBasicType(clang::ASTContext *ast, - const ConstString &name); + ConstString name); - static lldb::BasicType GetBasicTypeEnumeration(const ConstString &name); + static lldb::BasicType GetBasicTypeEnumeration(ConstString name); CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(const char *type_name, uint32_t dw_ate, @@ -212,7 +206,7 @@ public: template <typename RecordDeclType> CompilerType - GetTypeForIdentifier(const ConstString &type_name, + GetTypeForIdentifier(ConstString type_name, clang::DeclContext *decl_context = nullptr) { CompilerType compiler_type; @@ -244,13 +238,13 @@ public: } CompilerType CreateStructForIdentifier( - const ConstString &type_name, + ConstString type_name, const std::initializer_list<std::pair<const char *, CompilerType>> &type_fields, bool packed = false); CompilerType GetOrCreateStructForIdentifier( - const ConstString &type_name, + ConstString type_name, const std::initializer_list<std::pair<const char *, CompilerType>> &type_fields, bool packed = false); @@ -258,9 +252,7 @@ public: static bool IsOperator(const char *name, clang::OverloadedOperatorKind &op_kind); - //------------------------------------------------------------------ // Structure, Unions, Classes - //------------------------------------------------------------------ static clang::AccessSpecifier ConvertAccessTypeToAccessSpecifier(lldb::AccessType access); @@ -350,20 +342,18 @@ public: // Returns a mask containing bits from the ClangASTContext::eTypeXXX // enumerations - //------------------------------------------------------------------ // Namespace Declarations - //------------------------------------------------------------------ clang::NamespaceDecl * - GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx); + GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, + bool is_inline = false); static clang::NamespaceDecl * GetUniqueNamespaceDeclaration(clang::ASTContext *ast, const char *name, - clang::DeclContext *decl_ctx); + clang::DeclContext *decl_ctx, + bool is_inline = false); - //------------------------------------------------------------------ // Function Types - //------------------------------------------------------------------ clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, const char *name, @@ -412,25 +402,19 @@ public: CompilerType CreateBlockPointerType(const CompilerType &function_type); - //------------------------------------------------------------------ // Array Types - //------------------------------------------------------------------ CompilerType CreateArrayType(const CompilerType &element_type, size_t element_count, bool is_vector); - //------------------------------------------------------------------ // Enumeration Types - //------------------------------------------------------------------ CompilerType CreateEnumerationType(const char *name, clang::DeclContext *decl_ctx, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped); - //------------------------------------------------------------------ // Integer type functions - //------------------------------------------------------------------ static CompilerType GetIntTypeFromBitSize(clang::ASTContext *ast, size_t bit_size, bool is_signed); @@ -442,22 +426,16 @@ public: static CompilerType GetPointerSizedIntType(clang::ASTContext *ast, bool is_signed); - //------------------------------------------------------------------ // Floating point functions - //------------------------------------------------------------------ static CompilerType GetFloatTypeFromBitSize(clang::ASTContext *ast, size_t bit_size); - //------------------------------------------------------------------ // TypeSystem methods - //------------------------------------------------------------------ DWARFASTParser *GetDWARFParser() override; - PDBASTParser *GetPDBParser(); + PDBASTParser *GetPDBParser() override; - //------------------------------------------------------------------ // ClangASTContext callbacks for external source lookups. - //------------------------------------------------------------------ static void CompleteTagDecl(void *baton, clang::TagDecl *); static void CompleteObjCInterfaceDecl(void *baton, @@ -472,9 +450,7 @@ public: llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets); - //---------------------------------------------------------------------- // CompilerDecl override functions - //---------------------------------------------------------------------- ConstString DeclGetName(void *opaque_decl) override; ConstString DeclGetMangledName(void *opaque_decl) override; @@ -488,9 +464,7 @@ public: CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx) override; - //---------------------------------------------------------------------- // CompilerDeclContext override functions - //---------------------------------------------------------------------- std::vector<CompilerDecl> DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, @@ -507,9 +481,10 @@ public: bool *is_instance_method_ptr, ConstString *language_object_name_ptr) override; - //---------------------------------------------------------------------- + bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, + void *other_opaque_decl_ctx) override; + // Clang specific clang::DeclContext functions - //---------------------------------------------------------------------- static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc); @@ -532,9 +507,7 @@ public: static clang::ASTContext * DeclContextGetClangASTContext(const CompilerDeclContext &dc); - //---------------------------------------------------------------------- // Tests - //---------------------------------------------------------------------- bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, @@ -625,6 +598,8 @@ public: bool IsVoidType(lldb::opaque_compiler_type_t type) override; + bool CanPassInRegisters(const CompilerType &type) override; + bool SupportsLanguage(lldb::LanguageType language) override; static bool GetCXXClassName(const CompilerType &type, @@ -633,15 +608,11 @@ public: static bool GetObjCClassName(const CompilerType &type, std::string &class_name); - //---------------------------------------------------------------------- // Type Completion - //---------------------------------------------------------------------- bool GetCompleteType(lldb::opaque_compiler_type_t type) override; - //---------------------------------------------------------------------- // Accessors - //---------------------------------------------------------------------- ConstString GetTypeName(lldb::opaque_compiler_type_t type) override; @@ -655,9 +626,7 @@ public: unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override; - //---------------------------------------------------------------------- // Creating related types - //---------------------------------------------------------------------- // Using the current type, create a new typedef to that type using // "typedef_name" as the name and "decl_ctx" as the decl context. @@ -717,22 +686,21 @@ public: // If the current object represents a typedef type, get the underlying type CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override; - //---------------------------------------------------------------------- // Create related types using the current type's AST - //---------------------------------------------------------------------- CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override; - //---------------------------------------------------------------------- // Exploring the type - //---------------------------------------------------------------------- - uint64_t GetByteSize(lldb::opaque_compiler_type_t type, + llvm::Optional<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope) { - return (GetBitSize(type, exe_scope) + 7) / 8; + if (llvm::Optional<uint64_t> bit_size = GetBitSize(type, exe_scope)) + return (*bit_size + 7) / 8; + return llvm::None; } - uint64_t GetBitSize(lldb::opaque_compiler_type_t type, - ExecutionContextScope *exe_scope) override; + llvm::Optional<uint64_t> + GetBitSize(lldb::opaque_compiler_type_t type, + ExecutionContextScope *exe_scope) override; lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) override; @@ -745,19 +713,19 @@ public: bool omit_empty_base_classes, const ExecutionContext *exe_ctx) override; - CompilerType GetBuiltinTypeByName(const ConstString &name) override; + CompilerType GetBuiltinTypeByName(ConstString name) override; lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override; static lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type, - const ConstString &name); + ConstString name); void ForEachEnumerator( lldb::opaque_compiler_type_t type, std::function<bool(const CompilerType &integer_type, - const ConstString &name, + ConstString name, const llvm::APSInt &value)> const &callback) override; uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override; @@ -828,9 +796,7 @@ public: ConstString *child_name = nullptr, CompilerType *child_type = nullptr); - //---------------------------------------------------------------------- // Modifying RecordType - //---------------------------------------------------------------------- static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, @@ -890,16 +856,12 @@ public: bool has_extern); static bool GetHasExternalStorage(const CompilerType &type); - //------------------------------------------------------------------ // Tag Declarations - //------------------------------------------------------------------ static bool StartTagDeclarationDefinition(const CompilerType &type); static bool CompleteTagDeclarationDefinition(const CompilerType &type); - //---------------------------------------------------------------------- // Modifying Enumeration types - //---------------------------------------------------------------------- clang::EnumConstantDecl *AddEnumerationValueToEnumerationType( const CompilerType &enum_type, const Declaration &decl, const char *name, int64_t enum_value, uint32_t enum_value_bit_size); @@ -909,9 +871,7 @@ public: CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type); - //------------------------------------------------------------------ // Pointers & References - //------------------------------------------------------------------ // Call this function using the class type when you want to make a member // pointer type to pointee_type. @@ -924,9 +884,14 @@ public: const char *s, uint8_t *dst, size_t dst_size) override; - //---------------------------------------------------------------------- // Dumping types - //---------------------------------------------------------------------- +#ifndef NDEBUG + /// Convenience LLVM-style dump method for use in the debugger only. + /// In contrast to the other \p Dump() methods this directly invokes + /// \p clang::QualType::dump(). + LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override; +#endif + void Dump(Stream &s); void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, @@ -1011,39 +976,37 @@ protected: const clang::ClassTemplateSpecializationDecl * GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type); - //------------------------------------------------------------------ // Classes that inherit from ClangASTContext can see and modify these - //------------------------------------------------------------------ // clang-format off std::string m_target_triple; - std::unique_ptr<clang::ASTContext> m_ast_ap; - std::unique_ptr<clang::LangOptions> m_language_options_ap; - std::unique_ptr<clang::FileManager> m_file_manager_ap; - std::unique_ptr<clang::FileSystemOptions> m_file_system_options_ap; - std::unique_ptr<clang::SourceManager> m_source_manager_ap; - std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_ap; - std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_ap; + std::unique_ptr<clang::ASTContext> m_ast_up; + std::unique_ptr<clang::LangOptions> m_language_options_up; + std::unique_ptr<clang::FileManager> m_file_manager_up; + std::unique_ptr<clang::SourceManager> m_source_manager_up; + std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up; + std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up; std::shared_ptr<clang::TargetOptions> m_target_options_rp; - std::unique_ptr<clang::TargetInfo> m_target_info_ap; - std::unique_ptr<clang::IdentifierTable> m_identifier_table_ap; - std::unique_ptr<clang::SelectorTable> m_selector_table_ap; - std::unique_ptr<clang::Builtin::Context> m_builtins_ap; - std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_ap; - std::unique_ptr<PDBASTParser> m_pdb_ast_parser_ap; - std::unique_ptr<ClangASTSource> m_scratch_ast_source_ap; - std::unique_ptr<clang::MangleContext> m_mangle_ctx_ap; + std::unique_ptr<clang::TargetInfo> m_target_info_up; + std::unique_ptr<clang::IdentifierTable> m_identifier_table_up; + std::unique_ptr<clang::SelectorTable> m_selector_table_up; + std::unique_ptr<clang::Builtin::Context> m_builtins_up; + std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up; + std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up; + std::unique_ptr<ClangASTSource> m_scratch_ast_source_up; + std::unique_ptr<clang::MangleContext> m_mangle_ctx_up; CompleteTagDeclCallback m_callback_tag_decl; CompleteObjCInterfaceDeclCallback m_callback_objc_decl; void * m_callback_baton; clang::ExternalASTMerger::OriginMap m_origins; uint32_t m_pointer_byte_size; bool m_ast_owned; - bool m_can_evaluate_expressions; + /// The sema associated that is currently used to build this ASTContext. + /// May be null if we are already done parsing this ASTContext or the + /// ASTContext wasn't created by parsing source code. + clang::Sema * m_sema = nullptr; // clang-format on private: - //------------------------------------------------------------------ // For ClangASTContext only - //------------------------------------------------------------------ ClangASTContext(const ClangASTContext &); const ClangASTContext &operator=(const ClangASTContext &); }; @@ -1058,7 +1021,8 @@ public: GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, Expression::ResultType desired_type, - const EvaluateExpressionOptions &options) override; + const EvaluateExpressionOptions &options, + ValueObject *ctx_obj) override; FunctionCaller *GetFunctionCaller(const CompilerType &return_type, const Address &function_address, diff --git a/include/lldb/Symbol/ClangASTImporter.h b/include/lldb/Symbol/ClangASTImporter.h index 465d7e24a1e7..353b1232d940 100644 --- a/include/lldb/Symbol/ClangASTImporter.h +++ b/include/lldb/Symbol/ClangASTImporter.h @@ -1,9 +1,8 @@ //===-- ClangASTImporter.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,7 +21,9 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Symbol/CompilerDeclContext.h" +#include "lldb/Symbol/CxxModuleHandler.h" #include "lldb/lldb-types.h" #include "llvm/ADT/DenseMap.h" @@ -94,7 +95,9 @@ public: vbase_offsets; }; - ClangASTImporter() : m_file_manager(clang::FileSystemOptions()) {} + ClangASTImporter() + : m_file_manager(clang::FileSystemOptions(), + FileSystem::Instance().GetVirtualFileSystem()) {} clang::QualType CopyType(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx, clang::QualType type); @@ -185,7 +188,7 @@ public: virtual ~MapCompleter(); virtual void CompleteNamespaceMap(NamespaceMapSP &namespace_map, - const ConstString &name, + ConstString name, NamespaceMapSP &parent_map) const = 0; }; @@ -232,16 +235,61 @@ private: typedef std::map<const clang::Decl *, DeclOrigin> OriginMap; - class Minion : public clang::ASTImporter { + /// ASTImporter that intercepts and records the import process of the + /// underlying ASTImporter. + /// + /// This class updates the map from declarations to their original + /// declarations and can record and complete declarations that have been + /// imported in a certain interval. + /// + /// When intercepting a declaration import, the ASTImporterDelegate uses the + /// CxxModuleHandler to replace any missing or malformed declarations with + /// their counterpart from a C++ module. + class ASTImporterDelegate : public clang::ASTImporter { public: - Minion(ClangASTImporter &master, clang::ASTContext *target_ctx, - clang::ASTContext *source_ctx) + ASTImporterDelegate(ClangASTImporter &master, clang::ASTContext *target_ctx, + clang::ASTContext *source_ctx) : clang::ASTImporter(*target_ctx, master.m_file_manager, *source_ctx, master.m_file_manager, true /*minimal*/), m_decls_to_deport(nullptr), m_decls_already_deported(nullptr), m_master(master), m_source_ctx(source_ctx) {} - // A call to "InitDeportWorkQueues" puts the minion into deport mode. + /// Scope guard that attaches a CxxModuleHandler to an ASTImporterDelegate + /// and deattaches it at the end of the scope. Supports being used multiple + /// times on the same ASTImporterDelegate instance in nested scopes. + class CxxModuleScope { + /// The handler we attach to the ASTImporterDelegate. + CxxModuleHandler m_handler; + /// The ASTImporterDelegate we are supposed to attach the handler to. + ASTImporterDelegate &m_delegate; + /// True iff we attached the handler to the ASTImporterDelegate. + bool m_valid = false; + + public: + CxxModuleScope(ASTImporterDelegate &delegate, clang::ASTContext *dst_ctx) + : m_delegate(delegate) { + // If the delegate doesn't have a CxxModuleHandler yet, create one + // and attach it. + if (!delegate.m_std_handler) { + m_handler = CxxModuleHandler(delegate, dst_ctx); + m_valid = true; + delegate.m_std_handler = &m_handler; + } + } + ~CxxModuleScope() { + if (m_valid) { + // Make sure no one messed with the handler we placed. + assert(m_delegate.m_std_handler == &m_handler); + m_delegate.m_std_handler = nullptr; + } + } + }; + + protected: + llvm::Expected<clang::Decl *> ImportImpl(clang::Decl *From) override; + + public: + // A call to "InitDeportWorkQueues" puts the delegate into deport mode. // In deport mode, every copied Decl that could require completion is // recorded and placed into the decls_to_deport set. // @@ -249,8 +297,8 @@ private: // are in decls_to_deport, adding any Decls it sees along the way that it // hasn't already deported. It proceeds until decls_to_deport is empty. // - // These calls must be paired. Leaving a minion in deport mode or trying - // to start deport minion with a new pair of queues will result in an + // These calls must be paired. Leaving a delegate in deport mode or trying + // to start deport delegate with a new pair of queues will result in an // assertion failure. void @@ -260,28 +308,34 @@ private: void ImportDefinitionTo(clang::Decl *to, clang::Decl *from); - clang::Decl *Imported(clang::Decl *from, clang::Decl *to) override; + void Imported(clang::Decl *from, clang::Decl *to) override; clang::Decl *GetOriginalDecl(clang::Decl *To) override; + /// Decls we should ignore when mapping decls back to their original + /// ASTContext. Used by the CxxModuleHandler to mark declarations that + /// were created from the 'std' C++ module to prevent that the Importer + /// tries to sync them with the broken equivalent in the debug info AST. + std::set<clang::Decl *> m_decls_to_ignore; std::set<clang::NamedDecl *> *m_decls_to_deport; std::set<clang::NamedDecl *> *m_decls_already_deported; ClangASTImporter &m_master; clang::ASTContext *m_source_ctx; + CxxModuleHandler *m_std_handler = nullptr; }; - typedef std::shared_ptr<Minion> MinionSP; - typedef std::map<clang::ASTContext *, MinionSP> MinionMap; + typedef std::shared_ptr<ASTImporterDelegate> ImporterDelegateSP; + typedef std::map<clang::ASTContext *, ImporterDelegateSP> DelegateMap; typedef std::map<const clang::NamespaceDecl *, NamespaceMapSP> NamespaceMetaMap; struct ASTContextMetadata { ASTContextMetadata(clang::ASTContext *dst_ctx) - : m_dst_ctx(dst_ctx), m_minions(), m_origins(), m_namespace_maps(), + : m_dst_ctx(dst_ctx), m_delegates(), m_origins(), m_namespace_maps(), m_map_completer(nullptr) {} clang::ASTContext *m_dst_ctx; - MinionMap m_minions; + DelegateMap m_delegates; OriginMap m_origins; NamespaceMetaMap m_namespace_maps; @@ -316,18 +370,20 @@ private: return ASTContextMetadataSP(); } - MinionSP GetMinion(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx) { + ImporterDelegateSP GetDelegate(clang::ASTContext *dst_ctx, + clang::ASTContext *src_ctx) { ASTContextMetadataSP context_md = GetContextMetadata(dst_ctx); - MinionMap &minions = context_md->m_minions; - MinionMap::iterator minion_iter = minions.find(src_ctx); + DelegateMap &delegates = context_md->m_delegates; + DelegateMap::iterator delegate_iter = delegates.find(src_ctx); - if (minion_iter == minions.end()) { - MinionSP minion = MinionSP(new Minion(*this, dst_ctx, src_ctx)); - minions[src_ctx] = minion; - return minion; + if (delegate_iter == delegates.end()) { + ImporterDelegateSP delegate = + ImporterDelegateSP(new ASTImporterDelegate(*this, dst_ctx, src_ctx)); + delegates[src_ctx] = delegate; + return delegate; } else { - return minion_iter->second; + return delegate_iter->second; } } diff --git a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h index c077665e51ee..a2d4f8137a05 100644 --- a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h +++ b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h @@ -1,9 +1,8 @@ //===-- ClangExternalASTSourceCallbacks.h -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -51,9 +50,7 @@ public: m_callback_layout_record_type(layout_record_type_callback), m_callback_baton(callback_baton) {} - //------------------------------------------------------------------ // clang::ExternalASTSource - //------------------------------------------------------------------ clang::Decl *GetExternalDecl(uint32_t ID) override { // This method only needs to be implemented if the AST source ever passes @@ -127,10 +124,8 @@ public: } protected: - //------------------------------------------------------------------ // Classes that inherit from ClangExternalASTSourceCallbacks can see and // modify these - //------------------------------------------------------------------ CompleteTagDeclCallback m_callback_tag_decl; CompleteObjCInterfaceDeclCallback m_callback_objc_decl; FindExternalVisibleDeclsByNameCallback m_callback_find_by_name; diff --git a/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/include/lldb/Symbol/ClangExternalASTSourceCommon.h index 894c91f157da..8e69f6d3e4eb 100644 --- a/include/lldb/Symbol/ClangExternalASTSourceCommon.h +++ b/include/lldb/Symbol/ClangExternalASTSourceCommon.h @@ -1,9 +1,8 @@ //===-- ClangExternalASTSourceCommon.h --------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/ClangUtil.h b/include/lldb/Symbol/ClangUtil.h index c8638f782548..d6106032190c 100644 --- a/include/lldb/Symbol/ClangUtil.h +++ b/include/lldb/Symbol/ClangUtil.h @@ -1,9 +1,8 @@ //===-- ClangUtil.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // A collection of helper methods and data structures for manipulating clang // types and decls. diff --git a/include/lldb/Symbol/CompactUnwindInfo.h b/include/lldb/Symbol/CompactUnwindInfo.h index 711420f66a46..2646661ec237 100644 --- a/include/lldb/Symbol/CompactUnwindInfo.h +++ b/include/lldb/Symbol/CompactUnwindInfo.h @@ -1,23 +1,21 @@ //===-- CompactUnwindInfo.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_CompactUnwindInfo_h_ #define liblldb_CompactUnwindInfo_h_ -#include <mutex> -#include <vector> - -#include "lldb/Core/RangeMap.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" +#include <mutex> +#include <vector> namespace lldb_private { diff --git a/include/lldb/Symbol/CompileUnit.h b/include/lldb/Symbol/CompileUnit.h index a4d19cd3d8ae..c3ba2e2176e7 100644 --- a/include/lldb/Symbol/CompileUnit.h +++ b/include/lldb/Symbol/CompileUnit.h @@ -1,9 +1,8 @@ //===-- CompileUnit.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,6 +13,7 @@ #include "lldb/Core/ModuleChild.h" #include "lldb/Symbol/DebugMacros.h" #include "lldb/Symbol/Function.h" +#include "lldb/Symbol/SourceModule.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" @@ -21,8 +21,7 @@ #include "llvm/ADT/DenseMap.h" namespace lldb_private { -//---------------------------------------------------------------------- -/// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" +/// \class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" /// A class that describes a compilation unit. /// /// A representation of a compilation unit, or compiled source file. @@ -33,126 +32,113 @@ namespace lldb_private { /// Each compile unit has a list of functions, global and static variables, /// support file list (include files and inlined source files), and a line /// table. -//---------------------------------------------------------------------- class CompileUnit : public std::enable_shared_from_this<CompileUnit>, public ModuleChild, public FileSpec, public UserID, public SymbolContextScope { public: - //------------------------------------------------------------------ /// Construct with a module, path, UID and language. /// /// Initialize the compile unit given the owning \a module, a path to /// convert into a FileSpec, the SymbolFile plug-in supplied \a uid, and the /// source language type. /// - /// @param[in] module + /// \param[in] module /// The parent module that owns this compile unit. This value /// must be a valid pointer value. /// - /// @param[in] user_data + /// \param[in] user_data /// User data where the SymbolFile parser can store data. /// - /// @param[in] pathname + /// \param[in] pathname /// The path to the source file for this compile unit. /// - /// @param[in] uid + /// \param[in] uid /// The user ID of the compile unit. This value is supplied by /// the SymbolFile plug-in and should be a value that allows /// the SymbolFile plug-in to easily locate and parse additional /// information for the compile unit. /// - /// @param[in] language + /// \param[in] language /// A language enumeration type that describes the main language /// of this compile unit. /// - /// @param[in] is_optimized + /// \param[in] is_optimized /// A value that can initialized with eLazyBoolYes, eLazyBoolNo /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then /// an extra call into SymbolVendor will be made to calculate if /// the compile unit is optimized will be made when /// CompileUnit::GetIsOptimized() is called. /// - /// @see lldb::LanguageType - //------------------------------------------------------------------ + /// \see lldb::LanguageType CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, lldb::user_id_t uid, lldb::LanguageType language, lldb_private::LazyBool is_optimized); - //------------------------------------------------------------------ /// Construct with a module, file spec, UID and language. /// /// Initialize the compile unit given the owning \a module, a path to /// convert into a FileSpec, the SymbolFile plug-in supplied \a uid, and the /// source language type. /// - /// @param[in] module + /// \param[in] module /// The parent module that owns this compile unit. This value /// must be a valid pointer value. /// - /// @param[in] user_data + /// \param[in] user_data /// User data where the SymbolFile parser can store data. /// - /// @param[in] file_spec + /// \param[in] file_spec /// The file specification for the source file of this compile /// unit. /// - /// @param[in] uid + /// \param[in] uid /// The user ID of the compile unit. This value is supplied by /// the SymbolFile plug-in and should be a value that allows /// the plug-in to easily locate and parse /// additional information for the compile unit. /// - /// @param[in] language + /// \param[in] language /// A language enumeration type that describes the main language /// of this compile unit. /// - /// @param[in] is_optimized + /// \param[in] is_optimized /// A value that can initialized with eLazyBoolYes, eLazyBoolNo /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then /// an extra call into SymbolVendor will be made to calculate if /// the compile unit is optimized will be made when /// CompileUnit::GetIsOptimized() is called. /// - /// @see lldb::LanguageType - //------------------------------------------------------------------ + /// \see lldb::LanguageType CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &file_spec, lldb::user_id_t uid, lldb::LanguageType language, lldb_private::LazyBool is_optimized); - //------------------------------------------------------------------ /// Destructor - //------------------------------------------------------------------ ~CompileUnit() override; - //------------------------------------------------------------------ /// Add a function to this compile unit. /// /// Typically called by the SymbolFile plug-ins as they partially parse the /// debug information. /// - /// @param[in] function_sp + /// \param[in] function_sp /// A shared pointer to the Function object. - //------------------------------------------------------------------ void AddFunction(lldb::FunctionSP &function_sp); - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) + /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void CalculateSymbolContext(SymbolContext *sc) override; lldb::ModuleSP CalculateSymbolContextModule() override; CompileUnit *CalculateSymbolContextCompileUnit() override; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) + /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void DumpSymbolContext(Stream *s) override; lldb::LanguageType GetLanguage(); @@ -164,34 +150,29 @@ public: void GetDescription(Stream *s, lldb::DescriptionLevel level) const; - //------------------------------------------------------------------ /// Apply a lambda to each function in this compile unit. /// /// This provides raw access to the function shared pointer list and will not /// cause the SymbolFile plug-in to parse any unparsed functions. /// - /// @note Prefer using FindFunctionByUID over this if possible. + /// \note Prefer using FindFunctionByUID over this if possible. /// - /// @param[in] lambda + /// \param[in] lambda /// The lambda that should be applied to every function. The lambda can /// return true if the iteration should be aborted earlier. - //------------------------------------------------------------------ void ForeachFunction( llvm::function_ref<bool(const lldb::FunctionSP &)> lambda) const; - //------------------------------------------------------------------ /// Dump the compile unit contents to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] show_context + /// \param[in] show_context /// If \b true, variables will dump their symbol context /// information. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_context) const; - //------------------------------------------------------------------ /// Find the line entry by line and optional inlined file spec. /// /// Finds the first line entry that has an index greater than \a start_idx @@ -204,175 +185,157 @@ public: /// file and line by starting with \a start_idx equal to zero, and calling /// this function back with the return value + 1. /// - /// @param[in] start_idx + /// \param[in] start_idx /// The zero based index at which to start looking for matches. /// - /// @param[in] line + /// \param[in] line /// The line number to search for. /// - /// @param[in] file_spec_ptr + /// \param[in] file_spec_ptr /// If non-NULL search for entries that match this file spec, /// else if NULL, search for line entries that match the compile /// unit file. /// - /// @param[in] exact + /// \param[in] exact /// If \btrue match only if there is a line table entry for this line /// number. /// If \bfalse, find the line table entry equal to or after this line /// number. /// - /// @param[out] line_entry + /// \param[out] line_entry /// If non-NULL, a copy of the line entry that was found. /// - /// @return + /// \return /// The zero based index of a matching line entry, or UINT32_MAX /// if no matching line entry is found. - //------------------------------------------------------------------ uint32_t FindLineEntry(uint32_t start_idx, uint32_t line, const FileSpec *file_spec_ptr, bool exact, LineEntry *line_entry); - //------------------------------------------------------------------ /// Get the line table for the compile unit. /// /// Called by clients and the SymbolFile plug-in. The SymbolFile plug-ins /// use this function to determine if the line table has be parsed yet. /// Clients use this function to get the line table from a compile unit. /// - /// @return + /// \return /// The line table object pointer, or NULL if this line table /// hasn't been parsed yet. - //------------------------------------------------------------------ LineTable *GetLineTable(); DebugMacros *GetDebugMacros(); - //------------------------------------------------------------------ /// Get the compile unit's support file list. /// /// The support file list is used by the line table, and any objects that /// have valid Declaration objects. /// - /// @return + /// \return /// A support file list object. - //------------------------------------------------------------------ - FileSpecList &GetSupportFiles(); + const FileSpecList &GetSupportFiles(); - //------------------------------------------------------------------ /// Get the compile unit's imported module list. /// /// This reports all the imports that the compile unit made, including the /// current module. /// - /// @return - /// A list of imported module names. - //------------------------------------------------------------------ - const std::vector<ConstString> &GetImportedModules(); + /// \return + /// A list of imported modules. + const std::vector<SourceModule> &GetImportedModules(); - //------------------------------------------------------------------ /// Get the SymbolFile plug-in user data. /// /// SymbolFile plug-ins can store user data to internal state or objects to /// quickly allow them to parse more information for a given object. /// - /// @return + /// \return /// The user data stored with the CompileUnit when it was /// constructed. - //------------------------------------------------------------------ void *GetUserData() const; - //------------------------------------------------------------------ /// Get the variable list for a compile unit. /// /// Called by clients to get the variable list for a compile unit. The /// variable list will contain all global and static variables that were /// defined at the compile unit level. /// - /// @param[in] can_create + /// \param[in] can_create /// If \b true, the variable list will be parsed on demand. If /// \b false, the current variable list will be returned even /// if it contains a NULL VariableList object (typically /// called by dumping routines that want to display only what /// has currently been parsed). /// - /// @return + /// \return /// A shared pointer to a variable list, that can contain NULL /// VariableList pointer if there are no global or static /// variables. - //------------------------------------------------------------------ lldb::VariableListSP GetVariableList(bool can_create); - //------------------------------------------------------------------ /// Finds a function by user ID. /// /// Typically used by SymbolFile plug-ins when partially parsing the debug /// information to see if the function has been parsed yet. /// - /// @param[in] uid + /// \param[in] uid /// The user ID of the function to find. This value is supplied /// by the SymbolFile plug-in and should be a value that /// allows the plug-in to easily locate and parse additional /// information in the function. /// - /// @return + /// \return /// A shared pointer to the function object that might contain /// a NULL Function pointer. - //------------------------------------------------------------------ lldb::FunctionSP FindFunctionByUID(lldb::user_id_t uid); - //------------------------------------------------------------------ /// Set the line table for the compile unit. /// /// Called by the SymbolFile plug-in when if first parses the line table and /// hands ownership of the line table to this object. The compile unit owns /// the line table object and will delete the object when it is deleted. /// - /// @param[in] line_table + /// \param[in] line_table /// A line table object pointer that this object now owns. - //------------------------------------------------------------------ void SetLineTable(LineTable *line_table); void SetDebugMacros(const DebugMacrosSP &debug_macros); - //------------------------------------------------------------------ /// Set accessor for the variable list. /// /// Called by the SymbolFile plug-ins after they have parsed the variable /// lists and are ready to hand ownership of the list over to this object. /// - /// @param[in] variable_list_sp + /// \param[in] variable_list_sp /// A shared pointer to a VariableList. - //------------------------------------------------------------------ void SetVariableList(lldb::VariableListSP &variable_list_sp); - //------------------------------------------------------------------ /// Resolve symbol contexts by file and line. /// /// Given a file in \a file_spec, and a line number, find all instances and /// append them to the supplied symbol context list \a sc_list. /// - /// @param[in] file_spec + /// \param[in] file_spec /// A file specification. If \a file_spec contains no directory /// information, only the basename will be used when matching /// contexts. If the directory in \a file_spec is valid, a /// complete file specification match will be performed. /// - /// @param[in] line + /// \param[in] line /// The line number to match against the compile unit's line /// tables. /// - /// @param[in] check_inlines + /// \param[in] check_inlines /// If \b true this function will also match any inline /// file and line matches. If \b false, the compile unit's /// file specification must match \a file_spec for any matches /// to be returned. /// - /// @param[in] exact + /// \param[in] exact /// If true, only resolve the context if \a line exists in the line table. /// If false, resolve the context to the closest line greater than \a line /// in the line table. /// - /// @param[in] resolve_scope + /// \param[in] resolve_scope /// For each matching line entry, this bitfield indicates what /// values within each SymbolContext that gets added to \a /// sc_list will be resolved. See the SymbolContext::Scope @@ -380,21 +343,19 @@ public: /// resolved. Only SymbolContext entries that can be resolved /// using a LineEntry base address will be able to be resolved. /// - /// @param[out] sc_list + /// \param[out] sc_list /// A SymbolContext list class that will get any matching /// entries appended to. /// - /// @return + /// \return /// The number of new matches that were added to \a sc_list. /// - /// @see enum SymbolContext::Scope - //------------------------------------------------------------------ + /// \see enum SymbolContext::Scope uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, bool exact, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Get whether compiler optimizations were enabled for this compile unit /// /// "optimized" means that the debug experience may be difficult for the @@ -402,41 +363,39 @@ public: /// would expect them, stepping through the source lines in the function may /// appear strange, etc. /// - /// @return + /// \return /// Returns 'true' if this compile unit was compiled with /// optimization. 'false' indicates that either the optimization /// is unknown, or this compile unit was built without optimization. - //------------------------------------------------------------------ bool GetIsOptimized(); - //------------------------------------------------------------------ /// Returns the number of functions in this compile unit - //------------------------------------------------------------------ size_t GetNumFunctions() const { return m_functions_by_uid.size(); } protected: - void *m_user_data; ///< User data for the SymbolFile parser to store - ///information into. - lldb::LanguageType - m_language; ///< The programming language enumeration value. - Flags m_flags; ///< Compile unit flags that help with partial parsing. - + /// User data for the SymbolFile parser to store information into. + void *m_user_data; + /// The programming language enumeration value. + lldb::LanguageType m_language; + /// Compile unit flags that help with partial parsing. + Flags m_flags; /// Maps UIDs to functions. llvm::DenseMap<lldb::user_id_t, lldb::FunctionSP> m_functions_by_uid; - std::vector<ConstString> m_imported_modules; ///< All modules, including the - ///current module, imported by - ///this - ///< compile unit. - FileSpecList m_support_files; ///< Files associated with this compile unit's - ///line table and declarations. - std::unique_ptr<LineTable> - m_line_table_ap; ///< Line table that will get parsed on demand. - DebugMacrosSP - m_debug_macros_sp; ///< Debug macros that will get parsed on demand. - lldb::VariableListSP m_variables; ///< Global and static variable list that - ///will get parsed on demand. - lldb_private::LazyBool m_is_optimized; /// eLazyBoolYes if this compile unit - /// was compiled with optimization. + /// All modules, including the current module, imported by this + /// compile unit. + std::vector<SourceModule> m_imported_modules; + /// Files associated with this compile unit's line table and + /// declarations. + FileSpecList m_support_files; + /// Line table that will get parsed on demand. + std::unique_ptr<LineTable> m_line_table_up; + /// Debug macros that will get parsed on demand. + DebugMacrosSP m_debug_macros_sp; + /// Global and static variable list that will get parsed on demand. + lldb::VariableListSP m_variables; + /// eLazyBoolYes if this compile unit was compiled with + /// optimization. + lldb_private::LazyBool m_is_optimized; private: enum { diff --git a/include/lldb/Symbol/CompilerDecl.h b/include/lldb/Symbol/CompilerDecl.h index 5d744d999bea..4817ec4b2267 100644 --- a/include/lldb/Symbol/CompilerDecl.h +++ b/include/lldb/Symbol/CompilerDecl.h @@ -1,9 +1,8 @@ //===-- CompilerDecl.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { class CompilerDecl { public: - //---------------------------------------------------------------------- // Constructors and Destructors - //---------------------------------------------------------------------- CompilerDecl() : m_type_system(nullptr), m_opaque_decl(nullptr) {} CompilerDecl(TypeSystem *type_system, void *decl) @@ -28,9 +25,7 @@ public: ~CompilerDecl() {} - //---------------------------------------------------------------------- // Tests - //---------------------------------------------------------------------- explicit operator bool() const { return IsValid(); } @@ -46,9 +41,7 @@ public: bool IsClang() const; - //---------------------------------------------------------------------- // Accessors - //---------------------------------------------------------------------- TypeSystem *GetTypeSystem() const { return m_type_system; } diff --git a/include/lldb/Symbol/CompilerDeclContext.h b/include/lldb/Symbol/CompilerDeclContext.h index 179a1be0248b..e7958c08d833 100644 --- a/include/lldb/Symbol/CompilerDeclContext.h +++ b/include/lldb/Symbol/CompilerDeclContext.h @@ -1,9 +1,8 @@ //===-- CompilerDeclContext.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,9 +18,7 @@ namespace lldb_private { class CompilerDeclContext { public: - //---------------------------------------------------------------------- // Constructors and Destructors - //---------------------------------------------------------------------- CompilerDeclContext() : m_type_system(nullptr), m_opaque_decl_ctx(nullptr) {} CompilerDeclContext(TypeSystem *type_system, void *decl_ctx) @@ -29,9 +26,7 @@ public: ~CompilerDeclContext() {} - //---------------------------------------------------------------------- // Tests - //---------------------------------------------------------------------- explicit operator bool() const { return IsValid(); } @@ -50,35 +45,44 @@ public: std::vector<CompilerDecl> FindDeclByName(ConstString name, const bool ignore_using_decls); - //---------------------------------------------------------------------- /// Checks if this decl context represents a method of a class. /// - /// @param[out] language_ptr + /// \param[out] language_ptr /// If non NULL and \b true is returned from this function, /// this will indicate if the language that respresents the method. /// - /// @param[out] is_instance_method_ptr + /// \param[out] is_instance_method_ptr /// If non NULL and \b true is returned from this function, /// this will indicate if the method is an instance function (true) /// or a class method (false indicating the function is static, or /// doesn't require an instance of the class to be called). /// - /// @param[out] language_object_name_ptr + /// \param[out] language_object_name_ptr /// If non NULL and \b true is returned from this function, /// this will indicate if implicit object name for the language /// like "this" for C++, and "self" for Objective C. /// - /// @return + /// \return /// Returns true if this is a decl context that represents a method /// in a struct, union or class. - //---------------------------------------------------------------------- bool IsClassMethod(lldb::LanguageType *language_ptr, bool *is_instance_method_ptr, ConstString *language_object_name_ptr); - //---------------------------------------------------------------------- + /// Check if the given other decl context is contained in the lookup + /// of this decl context (for example because the other context is a nested + /// inline namespace). + /// + /// @param[in] other + /// The other decl context for which we should check if it is contained + /// in the lookoup of this context. + /// + /// @return + /// Returns true iff the other decl context is contained in the lookup + /// of this decl context. + bool IsContainedInLookup(CompilerDeclContext other) const; + // Accessors - //---------------------------------------------------------------------- TypeSystem *GetTypeSystem() const { return m_type_system; } diff --git a/include/lldb/Symbol/CompilerType.h b/include/lldb/Symbol/CompilerType.h index 353313d8e2a3..98d916597f42 100644 --- a/include/lldb/Symbol/CompilerType.h +++ b/include/lldb/Symbol/CompilerType.h @@ -1,9 +1,8 @@ //===-- CompilerType.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -22,7 +21,6 @@ namespace lldb_private { class DataExtractor; -//---------------------------------------------------------------------- // A class that can carry around a clang ASTContext and a opaque clang // QualType. A clang::QualType can be easily reconstructed from an opaque clang // type and often the ASTContext is needed when doing various type related @@ -30,12 +28,9 @@ class DataExtractor; // lightweight class that can be used. There are many static equivalents of the // member functions that allow the ASTContext and the opaque clang QualType to // be specified for ease of use and to avoid code duplication. -//---------------------------------------------------------------------- class CompilerType { public: - //---------------------------------------------------------------------- // Constructors and Destructors - //---------------------------------------------------------------------- CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type); CompilerType(clang::ASTContext *ast_context, clang::QualType qual_type); @@ -46,9 +41,7 @@ public: ~CompilerType(); - //---------------------------------------------------------------------- // Operators - //---------------------------------------------------------------------- const CompilerType &operator=(const CompilerType &rhs) { m_type = rhs.m_type; @@ -56,9 +49,7 @@ public: return *this; } - //---------------------------------------------------------------------- // Tests - //---------------------------------------------------------------------- explicit operator bool() const { return m_type != nullptr && m_type_system != nullptr; @@ -146,21 +137,15 @@ public: bool IsVoidType() const; - //---------------------------------------------------------------------- // Type Completion - //---------------------------------------------------------------------- bool GetCompleteType() const; - //---------------------------------------------------------------------- // AST related queries - //---------------------------------------------------------------------- size_t GetPointerByteSize() const; - //---------------------------------------------------------------------- // Accessors - //---------------------------------------------------------------------- TypeSystem *GetTypeSystem() const { return m_type_system; } @@ -188,9 +173,7 @@ public: unsigned GetTypeQualifiers() const; - //---------------------------------------------------------------------- // Creating related types - //---------------------------------------------------------------------- CompilerType GetArrayElementType(uint64_t *stride = nullptr) const; @@ -212,78 +195,56 @@ public: TypeMemberFunctionImpl GetMemberFunctionAtIndex(size_t idx); - //---------------------------------------------------------------------- // If this type is a reference to a type (L value or R value reference), // return a new type with the reference removed, else return the current type // itself. - //---------------------------------------------------------------------- CompilerType GetNonReferenceType() const; - //---------------------------------------------------------------------- // If this type is a pointer type, return the type that the pointer points // to, else return an invalid type. - //---------------------------------------------------------------------- CompilerType GetPointeeType() const; - //---------------------------------------------------------------------- // Return a new CompilerType that is a pointer to this type - //---------------------------------------------------------------------- CompilerType GetPointerType() const; - //---------------------------------------------------------------------- // Return a new CompilerType that is a L value reference to this type if this // type is valid and the type system supports L value references, else return // an invalid type. - //---------------------------------------------------------------------- CompilerType GetLValueReferenceType() const; - //---------------------------------------------------------------------- // Return a new CompilerType that is a R value reference to this type if this // type is valid and the type system supports R value references, else return // an invalid type. - //---------------------------------------------------------------------- CompilerType GetRValueReferenceType() const; - //---------------------------------------------------------------------- // Return a new CompilerType adds a const modifier to this type if this type // is valid and the type system supports const modifiers, else return an // invalid type. - //---------------------------------------------------------------------- CompilerType AddConstModifier() const; - //---------------------------------------------------------------------- // Return a new CompilerType adds a volatile modifier to this type if this // type is valid and the type system supports volatile modifiers, else return // an invalid type. - //---------------------------------------------------------------------- CompilerType AddVolatileModifier() const; - //---------------------------------------------------------------------- // Return a new CompilerType adds a restrict modifier to this type if this // type is valid and the type system supports restrict modifiers, else return // an invalid type. - //---------------------------------------------------------------------- CompilerType AddRestrictModifier() const; - //---------------------------------------------------------------------- // Create a typedef to this type using "name" as the name of the typedef this // type is valid and the type system supports typedefs, else return an // invalid type. - //---------------------------------------------------------------------- CompilerType CreateTypedef(const char *name, const CompilerDeclContext &decl_ctx) const; // If the current object represents a typedef type, get the underlying type CompilerType GetTypedefedType() const; - //---------------------------------------------------------------------- // Create related types using the current type's AST - //---------------------------------------------------------------------- CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const; - //---------------------------------------------------------------------- // Exploring the type - //---------------------------------------------------------------------- struct IntegralTemplateArgument; @@ -303,16 +264,14 @@ public: lldb::BasicType GetBasicTypeEnumeration() const; - static lldb::BasicType GetBasicTypeEnumeration(const ConstString &name); + static lldb::BasicType GetBasicTypeEnumeration(ConstString name); - //---------------------------------------------------------------------- // If this type is an enumeration, iterate through all of its enumerators // using a callback. If the callback returns true, keep iterating, else abort // the iteration. - //---------------------------------------------------------------------- void ForEachEnumerator( std::function<bool(const CompilerType &integer_type, - const ConstString &name, + ConstString name, const llvm::APSInt &value)> const &callback) const; uint32_t GetNumFields() const; @@ -377,18 +336,21 @@ public: bool IsMeaninglessWithoutDynamicResolution() const; - //------------------------------------------------------------------ // Pointers & References - //------------------------------------------------------------------ // Converts "s" to a floating point value and place resulting floating point // bytes in the "dst" buffer. size_t ConvertStringToFloatValue(const char *s, uint8_t *dst, size_t dst_size) const; - //---------------------------------------------------------------------- // Dumping types - //---------------------------------------------------------------------- + +#ifndef NDEBUG + /// Convenience LLVM-style dump method for use in the debugger only. + /// Don't call this function from actual code. + LLVM_DUMP_METHOD void dump() const; +#endif + void DumpValue(ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, uint32_t bitfield_bit_size, diff --git a/include/lldb/Symbol/CxxModuleHandler.h b/include/lldb/Symbol/CxxModuleHandler.h new file mode 100644 index 000000000000..f4aef3666ece --- /dev/null +++ b/include/lldb/Symbol/CxxModuleHandler.h @@ -0,0 +1,65 @@ +//===-- CxxModuleHandler.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_CxxModuleHandler_h_ +#define liblldb_CxxModuleHandler_h_ + +#include "clang/AST/ASTImporter.h" +#include "clang/Sema/Sema.h" +#include "llvm/ADT/StringSet.h" + +namespace lldb_private { + +/// Handles importing decls into an ASTContext with an attached C++ module. +/// +/// This class searches a C++ module (which must be attached to the target +/// ASTContext) for an equivalent decl to the one that should be imported. +/// If the decl that is found in the module is a suitable replacement +/// for the decl that should be imported, the module decl will be treated as +/// the result of the import process. +/// +/// If the Decl that should be imported is a template specialization +/// that doesn't exist yet in the target ASTContext (e.g. `std::vector<int>`), +/// then this class tries to create the template specialization in the target +/// ASTContext. This is only possible if the CxxModuleHandler can determine +/// that instantiating this template is safe to do, e.g. because the target +/// decl is a container class from the STL. +class CxxModuleHandler { + /// The ASTImporter that should be used to import any Decls which aren't + /// directly handled by this class itself. + clang::ASTImporter *m_importer = nullptr; + + /// The Sema instance of the target ASTContext. + clang::Sema *m_sema = nullptr; + + /// List of template names this class currently supports. These are the + /// template names inside the 'std' namespace such as 'vector' or 'list'. + llvm::StringSet<> m_supported_templates; + + /// Tries to manually instantiate the given foreign template in the target + /// context (designated by m_sema). + llvm::Optional<clang::Decl *> tryInstantiateStdTemplate(clang::Decl *d); + +public: + CxxModuleHandler() = default; + CxxModuleHandler(clang::ASTImporter &importer, clang::ASTContext *target); + + /// Attempts to import the given decl into the target ASTContext by + /// deserializing it from the 'std' module. This function returns a Decl if a + /// Decl has been deserialized from the 'std' module. Otherwise this function + /// returns nothing. + llvm::Optional<clang::Decl *> Import(clang::Decl *d); + + /// Returns true iff this instance is capable of importing any declarations + /// in the target ASTContext. + bool isValid() const { return m_sema != nullptr; } +}; + +} // namespace lldb_private + +#endif // liblldb_CxxModuleHandler_h_ diff --git a/include/lldb/Symbol/DWARFCallFrameInfo.h b/include/lldb/Symbol/DWARFCallFrameInfo.h index 133c66d4ae4f..104075f28df3 100644 --- a/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -1,9 +1,8 @@ //===-- DWARFCallFrameInfo.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,12 +13,11 @@ #include <mutex> #include "lldb/Core/AddressRange.h" -#include "lldb/Utility/Flags.h" - -#include "lldb/Core/RangeMap.h" #include "lldb/Core/dwarf.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/UnwindPlan.h" +#include "lldb/Utility/Flags.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/Utility/VMRange.h" #include "lldb/lldb-private.h" @@ -45,13 +43,18 @@ public: // address. bool GetAddressRange(Address addr, AddressRange &range); - // Return an UnwindPlan based on the call frame information encoded in the - // FDE of this DWARFCallFrameInfo section. - bool GetUnwindPlan(Address addr, UnwindPlan &unwind_plan); + /// Return an UnwindPlan based on the call frame information encoded in the + /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid + /// (at least) for the given address. + bool GetUnwindPlan(const Address &addr, UnwindPlan &unwind_plan); + + /// Return an UnwindPlan based on the call frame information encoded in the + /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid + /// (at least) for some address in the given range. + bool GetUnwindPlan(const AddressRange &range, UnwindPlan &unwind_plan); typedef RangeVector<lldb::addr_t, uint32_t> FunctionAddressAndSizeVector; - //------------------------------------------------------------------ // Build a vector of file address and size for all functions in this Module // based on the eh_frame FDE entries. // @@ -61,7 +64,7 @@ public: // functions in the Module. But the eh_frame can help to give the addresses // of these stripped symbols, at least. // - // @param[out] function_info + // \param[out] function_info // A vector provided by the caller is filled out. May be empty if no // FDEs/no eh_frame // is present in this Module. @@ -118,8 +121,8 @@ private: bool IsEHFrame() const; - bool GetFDEEntryByFileAddress(lldb::addr_t file_offset, - FDEEntryMap::Entry &fde_entry); + llvm::Optional<FDEEntryMap::Entry> + GetFirstFDEEntryInRange(const AddressRange &range); void GetFDEIndex(); diff --git a/include/lldb/Symbol/DebugMacros.h b/include/lldb/Symbol/DebugMacros.h index 86700994fbcc..d364299ef490 100644 --- a/include/lldb/Symbol/DebugMacros.h +++ b/include/lldb/Symbol/DebugMacros.h @@ -1,9 +1,8 @@ //===-- DebugMacros.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/DeclVendor.h b/include/lldb/Symbol/DeclVendor.h index d1ccb4191cbc..9c10fe1177fb 100644 --- a/include/lldb/Symbol/DeclVendor.h +++ b/include/lldb/Symbol/DeclVendor.h @@ -1,9 +1,8 @@ //===-- DeclVendor.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,54 +18,57 @@ namespace lldb_private { -//---------------------------------------------------------------------- // The Decl vendor class is intended as a generic interface to search for named // declarations that are not necessarily backed by a specific symbol file. -//---------------------------------------------------------------------- class DeclVendor { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ DeclVendor() {} virtual ~DeclVendor() {} - //------------------------------------------------------------------ /// Look up the set of Decls that the DeclVendor currently knows about /// matching a given name. /// - /// @param[in] name + /// \param[in] name /// The name to look for. /// - /// @param[in] append + /// \param[in] append /// If true, FindDecls will clear "decls" when it starts. /// - /// @param[in] max_matches + /// \param[in] max_matches /// The maximum number of Decls to return. UINT32_MAX means "as /// many as possible." /// - /// @return + /// \return /// The number of Decls added to decls; will not exceed /// max_matches. - //------------------------------------------------------------------ - virtual uint32_t FindDecls(const ConstString &name, bool append, + virtual uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches, std::vector<clang::NamedDecl *> &decls) = 0; - //------------------------------------------------------------------ + /// Look up the types that the DeclVendor currently knows about matching a + /// given name. + /// + /// \param[in] name + /// The name to look for. + /// + /// \param[in] max_matches + // The maximum number of matches. UINT32_MAX means "as many as possible". + /// + /// \return + /// The vector of CompilerTypes that was found. + std::vector<CompilerType> FindTypes(ConstString name, uint32_t max_matches); + /// Interface for ExternalASTMerger. Returns an ImporterSource /// allowing type completion. /// - /// @return + /// \return /// An ImporterSource for this DeclVendor. - //------------------------------------------------------------------ virtual clang::ExternalASTMerger::ImporterSource GetImporterSource() = 0; private: - //------------------------------------------------------------------ // For DeclVendor only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(DeclVendor); }; diff --git a/include/lldb/Symbol/Declaration.h b/include/lldb/Symbol/Declaration.h index b654988bccd2..63798f883e5f 100644 --- a/include/lldb/Symbol/Declaration.h +++ b/include/lldb/Symbol/Declaration.h @@ -1,9 +1,8 @@ //===-- Declaration.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,20 +14,16 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class Declaration Declaration.h "lldb/Symbol/Declaration.h" +/// \class Declaration Declaration.h "lldb/Symbol/Declaration.h" /// A class that describes the declaration location of a /// lldb object. /// /// The declarations include the file specification, line number, and the /// column info and can help track where functions, blocks, inlined functions, /// types, variables, any many other debug core objects were declared. -//---------------------------------------------------------------------- class Declaration { public: - //------------------------------------------------------------------ /// Default constructor. - //------------------------------------------------------------------ Declaration() : m_file(), m_line(0) #ifdef LLDB_ENABLE_DECLARATION_COLUMNS @@ -38,21 +33,19 @@ public: { } - //------------------------------------------------------------------ /// Construct with file specification, and optional line and column. /// - /// @param[in] file_spec + /// \param[in] file_spec /// The file specification that describes where this was /// declared. /// - /// @param[in] line + /// \param[in] line /// The line number that describes where this was declared. Set /// to zero if there is no line number information. /// - /// @param[in] column + /// \param[in] column /// The column number that describes where this was declared. /// Set to zero if there is no column number information. - //------------------------------------------------------------------ Declaration(const FileSpec &file_spec, uint32_t line = 0, uint32_t column = 0) : m_file(file_spec), m_line(line) #ifdef LLDB_ENABLE_DECLARATION_COLUMNS @@ -62,9 +55,7 @@ public: { } - //------------------------------------------------------------------ /// Construct with a reference to another Declaration object. - //------------------------------------------------------------------ Declaration(const Declaration &rhs) : m_file(rhs.m_file), m_line(rhs.m_line) #ifdef LLDB_ENABLE_DECLARATION_COLUMNS @@ -74,9 +65,7 @@ public: { } - //------------------------------------------------------------------ /// Construct with a pointer to another Declaration object. - //------------------------------------------------------------------ Declaration(const Declaration *decl_ptr) : m_file(), m_line(0) #ifdef LLDB_ENABLE_DECLARATION_COLUMNS @@ -88,12 +77,10 @@ public: *this = *decl_ptr; } - //------------------------------------------------------------------ /// Clear the object's state. /// /// Sets the file specification to be empty, and the line and column to /// zero. - //------------------------------------------------------------------ void Clear() { m_file.Clear(); m_line = 0; @@ -102,45 +89,50 @@ public: #endif } - //------------------------------------------------------------------ /// Compare two declaration objects. /// /// Compares the two file specifications from \a lhs and \a rhs. If the file /// specifications are equal, then continue to compare the line number and /// column numbers respectively. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const Declaration object reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const Declaration object reference. /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs static int Compare(const Declaration &lhs, const Declaration &rhs); - //------------------------------------------------------------------ + /// Checks if this object has the same file and line as another declaration + /// object. + /// + /// \param[in] declaration + /// The const Declaration object to compare with. + /// + /// \return + /// Returns \b true if \b declaration is at the same file and + /// line, \b false otherwise. + bool FileAndLineEqual(const Declaration &declaration) const; + /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_fullpaths) const; bool DumpStopContext(Stream *s, bool show_fullpaths) const; - //------------------------------------------------------------------ /// Get accessor for the declaration column number. /// - /// @return + /// \return /// Non-zero indicates a valid column number, zero indicates no /// column information is available. - //------------------------------------------------------------------ uint32_t GetColumn() const { #ifdef LLDB_ENABLE_DECLARATION_COLUMNS return m_column; @@ -149,79 +141,63 @@ public: #endif } - //------------------------------------------------------------------ /// Get accessor for file specification. /// - /// @return + /// \return /// A reference to the file specification object. - //------------------------------------------------------------------ FileSpec &GetFile() { return m_file; } - //------------------------------------------------------------------ /// Get const accessor for file specification. /// - /// @return + /// \return /// A const reference to the file specification object. - //------------------------------------------------------------------ const FileSpec &GetFile() const { return m_file; } - //------------------------------------------------------------------ /// Get accessor for the declaration line number. /// - /// @return + /// \return /// Non-zero indicates a valid line number, zero indicates no /// line information is available. - //------------------------------------------------------------------ uint32_t GetLine() const { return m_line; } bool IsValid() const { return m_file && m_line != 0; } - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () size_t MemorySize() const; - //------------------------------------------------------------------ /// Set accessor for the declaration column number. /// - /// @param[in] column + /// \param[in] column /// Non-zero indicates a valid column number, zero indicates no /// column information is available. - //------------------------------------------------------------------ void SetColumn(uint32_t column) { #ifdef LLDB_ENABLE_DECLARATION_COLUMNS m_column = col; #endif } - //------------------------------------------------------------------ /// Set accessor for the declaration file specification. /// - /// @param[in] file_spec + /// \param[in] file_spec /// The new declaration file specification. - //------------------------------------------------------------------ void SetFile(const FileSpec &file_spec) { m_file = file_spec; } - //------------------------------------------------------------------ /// Set accessor for the declaration line number. /// - /// @param[in] line + /// \param[in] line /// Non-zero indicates a valid line number, zero indicates no /// line information is available. - //------------------------------------------------------------------ void SetLine(uint32_t line) { m_line = line; } protected: - //------------------------------------------------------------------ /// Member variables. - //------------------------------------------------------------------ FileSpec m_file; ///< The file specification that points to the ///< source file where the declaration occurred. uint32_t m_line; ///< Non-zero values indicates a valid line number, diff --git a/include/lldb/Symbol/FuncUnwinders.h b/include/lldb/Symbol/FuncUnwinders.h index ae8bcc892ce4..cc767d4e1e82 100644 --- a/include/lldb/Symbol/FuncUnwinders.h +++ b/include/lldb/Symbol/FuncUnwinders.h @@ -35,17 +35,10 @@ public: ~FuncUnwinders(); - // current_offset is the byte offset into the function. - // 0 means no instructions have executed yet. -1 means the offset is unknown. - // On architectures where the pc points to the next instruction that will - // execute, this offset value will have already been decremented by 1 to stay - // within the bounds of the correct function body. - lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, - int current_offset); + lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, Thread &thread); lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite(Target &target, - lldb_private::Thread &thread, - int current_offset); + lldb_private::Thread &thread); lldb::UnwindPlanSP GetUnwindPlanFastUnwind(Target &target, lldb_private::Thread &thread); @@ -81,26 +74,23 @@ public: // used. Instead, clients should ask for the *behavior* they are looking for, // using one of the above UnwindPlan retrieval methods. - lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread, - int current_offset); + lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread); - lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target, int current_offset); + lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target); lldb::UnwindPlanSP GetEHFrameAugmentedUnwindPlan(Target &target, - Thread &thread, - int current_offset); + Thread &thread); - lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target, - int current_offset); + lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target); lldb::UnwindPlanSP GetDebugFrameAugmentedUnwindPlan(Target &target, - Thread &thread, - int current_offset); + Thread &thread); - lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target, - int current_offset); + lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target); - lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target, int current_offset); + lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target); + + lldb::UnwindPlanSP GetSymbolFileUnwindPlan(Thread &thread); lldb::UnwindPlanSP GetArchDefaultUnwindPlan(Thread &thread); @@ -132,6 +122,7 @@ private: std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind; lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp; + lldb::UnwindPlanSP m_unwind_plan_symbol_file_sp; lldb::UnwindPlanSP m_unwind_plan_fast_sp; lldb::UnwindPlanSP m_unwind_plan_arch_default_sp; lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp; @@ -143,8 +134,8 @@ private: m_tried_unwind_plan_eh_frame_augmented : 1, m_tried_unwind_plan_debug_frame_augmented : 1, m_tried_unwind_plan_compact_unwind : 1, - m_tried_unwind_plan_arm_unwind : 1, m_tried_unwind_fast : 1, - m_tried_unwind_arch_default : 1, + m_tried_unwind_plan_arm_unwind : 1, m_tried_unwind_plan_symbol_file : 1, + m_tried_unwind_fast : 1, m_tried_unwind_arch_default : 1, m_tried_unwind_arch_default_at_func_entry : 1; Address m_first_non_prologue_insn; diff --git a/include/lldb/Symbol/Function.h b/include/lldb/Symbol/Function.h index 447abd2e6f78..f68a16705d93 100644 --- a/include/lldb/Symbol/Function.h +++ b/include/lldb/Symbol/Function.h @@ -1,9 +1,8 @@ //===-- Function.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,216 +19,182 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class FunctionInfo Function.h "lldb/Symbol/Function.h" +/// \class FunctionInfo Function.h "lldb/Symbol/Function.h" /// A class that contains generic function information. /// /// This provides generic function information that gets reused between inline /// functions and function types. -//---------------------------------------------------------------------- class FunctionInfo { public: - //------------------------------------------------------------------ /// Construct with the function method name and optional declaration /// information. /// - /// @param[in] name + /// \param[in] name /// A C string name for the method name for this function. This /// value should not be the mangled named, but the simple method /// name. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// Optional declaration information that describes where the /// function was declared. This can be NULL. - //------------------------------------------------------------------ FunctionInfo(const char *name, const Declaration *decl_ptr); - //------------------------------------------------------------------ /// Construct with the function method name and optional declaration /// information. /// - /// @param[in] name + /// \param[in] name /// A name for the method name for this function. This value /// should not be the mangled named, but the simple method name. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// Optional declaration information that describes where the /// function was declared. This can be NULL. - //------------------------------------------------------------------ - FunctionInfo(const ConstString &name, const Declaration *decl_ptr); + FunctionInfo(ConstString name, const Declaration *decl_ptr); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since classes inherit from this class. - //------------------------------------------------------------------ virtual ~FunctionInfo(); - //------------------------------------------------------------------ /// Compare two function information objects. /// /// First compares the method names, and if equal, then compares the /// declaration information. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const FunctionInfo object reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const FunctionInfo object reference. /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs static int Compare(const FunctionInfo &lhs, const FunctionInfo &rhs); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_fullpaths) const; - //------------------------------------------------------------------ /// Get accessor for the declaration information. /// - /// @return + /// \return /// A reference to the declaration object. - //------------------------------------------------------------------ Declaration &GetDeclaration(); - //------------------------------------------------------------------ /// Get const accessor for the declaration information. /// - /// @return + /// \return /// A const reference to the declaration object. - //------------------------------------------------------------------ const Declaration &GetDeclaration() const; - //------------------------------------------------------------------ /// Get accessor for the method name. /// - /// @return + /// \return /// A const reference to the method name object. - //------------------------------------------------------------------ ConstString GetName() const; - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () virtual size_t MemorySize() const; protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ ConstString m_name; ///< Function method name (not a mangled name). Declaration m_declaration; ///< Information describing where this function ///information was defined. }; -//---------------------------------------------------------------------- -/// @class InlineFunctionInfo Function.h "lldb/Symbol/Function.h" +/// \class InlineFunctionInfo Function.h "lldb/Symbol/Function.h" /// A class that describes information for an inlined function. -//---------------------------------------------------------------------- class InlineFunctionInfo : public FunctionInfo { public: - //------------------------------------------------------------------ /// Construct with the function method name, mangled name, and optional /// declaration information. /// - /// @param[in] name + /// \param[in] name /// A C string name for the method name for this function. This /// value should not be the mangled named, but the simple method /// name. /// - /// @param[in] mangled + /// \param[in] mangled /// A C string name for the mangled name for this function. This /// value can be NULL if there is no mangled information. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// Optional declaration information that describes where the /// function was declared. This can be NULL. /// - /// @param[in] call_decl_ptr + /// \param[in] call_decl_ptr /// Optional calling location declaration information that /// describes from where this inlined function was called. - //------------------------------------------------------------------ InlineFunctionInfo(const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr); - //------------------------------------------------------------------ /// Construct with the function method name, mangled name, and optional /// declaration information. /// - /// @param[in] name + /// \param[in] name /// A name for the method name for this function. This value /// should not be the mangled named, but the simple method name. /// - /// @param[in] mangled + /// \param[in] mangled /// A name for the mangled name for this function. This value /// can be empty if there is no mangled information. /// - /// @param[in] decl_ptr + /// \param[in] decl_ptr /// Optional declaration information that describes where the /// function was declared. This can be NULL. /// - /// @param[in] call_decl_ptr + /// \param[in] call_decl_ptr /// Optional calling location declaration information that /// describes from where this inlined function was called. - //------------------------------------------------------------------ - InlineFunctionInfo(const ConstString &name, const Mangled &mangled, + InlineFunctionInfo(ConstString name, const Mangled &mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~InlineFunctionInfo() override; - //------------------------------------------------------------------ /// Compare two inlined function information objects. /// /// First compares the FunctionInfo objects, and if equal, compares the /// mangled names. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const InlineFunctionInfo object /// reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const InlineFunctionInfo object /// reference. /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs int Compare(const InlineFunctionInfo &lhs, const InlineFunctionInfo &rhs); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_fullpaths) const; void DumpStopContext(Stream *s, lldb::LanguageType language) const; @@ -238,54 +203,42 @@ public: ConstString GetDisplayName(lldb::LanguageType language) const; - //------------------------------------------------------------------ /// Get accessor for the call site declaration information. /// - /// @return + /// \return /// A reference to the declaration object. - //------------------------------------------------------------------ Declaration &GetCallSite(); - //------------------------------------------------------------------ /// Get const accessor for the call site declaration information. /// - /// @return + /// \return /// A const reference to the declaration object. - //------------------------------------------------------------------ const Declaration &GetCallSite() const; - //------------------------------------------------------------------ /// Get accessor for the mangled name object. /// - /// @return + /// \return /// A reference to the mangled name object. - //------------------------------------------------------------------ Mangled &GetMangled(); - //------------------------------------------------------------------ /// Get const accessor for the mangled name object. /// - /// @return + /// \return /// A const reference to the mangled name object. - //------------------------------------------------------------------ const Mangled &GetMangled() const; - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () size_t MemorySize() const override; private: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ Mangled m_mangled; ///< Mangled inlined function name (can be empty if there ///is no mangled information). Declaration m_call_decl; @@ -293,12 +246,10 @@ private: class Function; -//---------------------------------------------------------------------- -/// @class CallEdge Function.h "lldb/Symbol/Function.h" +/// \class CallEdge Function.h "lldb/Symbol/Function.h" /// /// Represent a call made within a Function. This can be used to find a path /// in the call graph between two functions. -//---------------------------------------------------------------------- class CallEdge { public: /// Construct a call edge using a symbol name to identify the calling @@ -349,8 +300,7 @@ private: DISALLOW_COPY_AND_ASSIGN(CallEdge); }; -//---------------------------------------------------------------------- -/// @class Function Function.h "lldb/Symbol/Function.h" +/// \class Function Function.h "lldb/Symbol/Function.h" /// A class that describes a function. /// /// Functions belong to CompileUnit objects (Function::m_comp_unit), have @@ -362,61 +312,54 @@ private: /// (Function::m_type), and contains lexical blocks (Function::m_blocks). /// /// The function information is split into a few pieces: -/// @li The concrete instance information -/// @li The abstract information +/// \li The concrete instance information +/// \li The abstract information /// /// The abstract information is found in the function type (Type) that /// describes a function information, return type and parameter types. /// /// The concrete information is the address range information and specific /// locations for an instance of this function. -//---------------------------------------------------------------------- class Function : public UserID, public SymbolContextScope { public: - //------------------------------------------------------------------ /// Construct with a compile unit, function UID, function type UID, optional /// mangled name, function type, and a section offset based address range. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// The compile unit to which this function belongs. /// - /// @param[in] func_uid + /// \param[in] func_uid /// The UID for this function. This value is provided by the /// SymbolFile plug-in and can be any value that allows /// the plug-in to quickly find and parse more detailed /// information when and if more information is needed. /// - /// @param[in] func_type_uid + /// \param[in] func_type_uid /// The type UID for the function Type to allow for lazy type /// parsing from the debug information. /// - /// @param[in] mangled + /// \param[in] mangled /// The optional mangled name for this function. If empty, there /// is no mangled information. /// - /// @param[in] func_type + /// \param[in] func_type /// The optional function type. If NULL, the function type will /// be parsed on demand when accessed using the /// Function::GetType() function by asking the SymbolFile /// plug-in to get the type for \a func_type_uid. /// - /// @param[in] range + /// \param[in] range /// The section offset based address for this function. - //------------------------------------------------------------------ Function(CompileUnit *comp_unit, lldb::user_id_t func_uid, lldb::user_id_t func_type_uid, const Mangled &mangled, Type *func_type, const AddressRange &range); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~Function() override; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) + /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void CalculateSymbolContext(SymbolContext *sc) override; lldb::ModuleSP CalculateSymbolContextModule() override; @@ -428,89 +371,71 @@ public: const AddressRange &GetAddressRange() { return m_range; } lldb::LanguageType GetLanguage() const; - //------------------------------------------------------------------ /// Find the file and line number of the source location of the start of the /// function. This will use the declaration if present and fall back on the /// line table if that fails. So there may NOT be a line table entry for /// this source file/line combo. /// - /// @param[out] source_file + /// \param[out] source_file /// The source file. /// - /// @param[out] line_no + /// \param[out] line_no /// The line number. - //------------------------------------------------------------------ void GetStartLineSourceInfo(FileSpec &source_file, uint32_t &line_no); - //------------------------------------------------------------------ /// Find the file and line number of the source location of the end of the /// function. /// /// - /// @param[out] source_file + /// \param[out] source_file /// The source file. /// - /// @param[out] line_no + /// \param[out] line_no /// The line number. - //------------------------------------------------------------------ void GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no); - //------------------------------------------------------------------ /// Get the outgoing call edges from this function, sorted by their return /// PC addresses (in increasing order). - //------------------------------------------------------------------ llvm::MutableArrayRef<CallEdge> GetCallEdges(); - //------------------------------------------------------------------ /// Get the outgoing tail-calling edges from this function. If none exist, /// return None. - //------------------------------------------------------------------ llvm::MutableArrayRef<CallEdge> GetTailCallingEdges(); - //------------------------------------------------------------------ /// Get accessor for the block list. /// - /// @return + /// \return /// The block list object that describes all lexical blocks /// in the function. /// - /// @see BlockList - //------------------------------------------------------------------ + /// \see BlockList Block &GetBlock(bool can_create); - //------------------------------------------------------------------ /// Get accessor for the compile unit that owns this function. /// - /// @return + /// \return /// A compile unit object pointer. - //------------------------------------------------------------------ CompileUnit *GetCompileUnit(); - //------------------------------------------------------------------ /// Get const accessor for the compile unit that owns this function. /// - /// @return + /// \return /// A const compile unit object pointer. - //------------------------------------------------------------------ const CompileUnit *GetCompileUnit() const; void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target); - //------------------------------------------------------------------ /// Get accessor for the frame base location. /// - /// @return + /// \return /// A location expression that describes the function frame /// base. - //------------------------------------------------------------------ DWARFExpression &GetFrameBaseExpression() { return m_frame_base; } - //------------------------------------------------------------------ /// Get const accessor for the frame base location. /// - /// @return + /// \return /// A const compile unit object pointer. - //------------------------------------------------------------------ const DWARFExpression &GetFrameBaseExpression() const { return m_frame_base; } ConstString GetName() const; @@ -521,79 +446,64 @@ public: const Mangled &GetMangled() const { return m_mangled; } - //------------------------------------------------------------------ /// Get the DeclContext for this function, if available. /// - /// @return + /// \return /// The DeclContext, or NULL if none exists. - //------------------------------------------------------------------ CompilerDeclContext GetDeclContext(); - //------------------------------------------------------------------ /// Get accessor for the type that describes the function return value type, /// and parameter types. /// - /// @return + /// \return /// A type object pointer. - //------------------------------------------------------------------ Type *GetType(); - //------------------------------------------------------------------ /// Get const accessor for the type that describes the function return value /// type, and parameter types. /// - /// @return + /// \return /// A const type object pointer. - //------------------------------------------------------------------ const Type *GetType() const; CompilerType GetCompilerType(); - //------------------------------------------------------------------ /// Get the size of the prologue instructions for this function. The /// "prologue" instructions include any instructions given line number 0 /// immediately following the prologue end. /// - /// @return + /// \return /// The size of the prologue. - //------------------------------------------------------------------ uint32_t GetPrologueByteSize(); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] show_context + /// \param[in] show_context /// If \b true, variables will dump their symbol context /// information. - //------------------------------------------------------------------ void Dump(Stream *s, bool show_context) const; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) + /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void DumpSymbolContext(Stream *s) override; - //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// @return + /// \return /// The number of bytes that this object occupies in memory. /// The returned value does not include the bytes for any /// shared string values. /// - /// @see ConstString::StaticMemorySize () - //------------------------------------------------------------------ + /// \see ConstString::StaticMemorySize () size_t MemorySize() const; - //------------------------------------------------------------------ /// Get whether compiler optimizations were enabled for this function /// /// The debug information may provide information about whether this @@ -603,14 +513,12 @@ public: /// would expect them, stepping through the source lines in the function may /// appear strange, etc. /// - /// @return + /// \return /// Returns 'true' if this function was compiled with /// optimization. 'false' indicates that either the optimization /// is unknown, or this function was built without optimization. - //------------------------------------------------------------------ bool GetIsOptimized(); - //------------------------------------------------------------------ /// Get whether this function represents a 'top-level' function /// /// The concept of a top-level function is language-specific, mostly meant @@ -621,10 +529,9 @@ public: /// If stopped in a top-level function, LLDB will expose global variables /// as-if locals in the 'frame variable' command /// - /// @return + /// \return /// Returns 'true' if this function is a top-level function, /// 'false' otherwise. - //------------------------------------------------------------------ bool IsTopLevelFunction(); lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx, @@ -640,9 +547,7 @@ protected: (1 << 0) ///< Have we already tried to calculate the prologue size? }; - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ CompileUnit *m_comp_unit; ///< The compile unit that owns this function. lldb::user_id_t m_type_uid; ///< The user ID of for the prototype Type for this function. diff --git a/include/lldb/Symbol/LineEntry.h b/include/lldb/Symbol/LineEntry.h index c1ce614609c1..fe97a78e3ed4 100644 --- a/include/lldb/Symbol/LineEntry.h +++ b/include/lldb/Symbol/LineEntry.h @@ -1,9 +1,8 @@ //===-- LineEntry.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -16,16 +15,12 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h" +/// \class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h" /// A line table entry class. -//---------------------------------------------------------------------- struct LineEntry { - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize all member variables to invalid values. - //------------------------------------------------------------------ LineEntry(); LineEntry(const lldb::SectionSP §ion_sp, lldb::addr_t section_offset, @@ -34,95 +29,84 @@ struct LineEntry { bool _is_start_of_basic_block, bool _is_prologue_end, bool _is_epilogue_begin, bool _is_terminal_entry); - //------------------------------------------------------------------ /// Clear the object's state. /// /// Clears all member variables to invalid values. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// The compile unit object that contains the support file /// list so the line entry can dump the file name (since this /// object contains a file index into the support file list). /// - /// @param[in] show_file + /// \param[in] show_file /// If \b true, display the filename with the line entry which /// requires that the compile unit object \a comp_unit be a /// valid pointer. /// - /// @param[in] style + /// \param[in] style /// The display style for the section offset address. /// - /// @return + /// \return /// Returns \b true if the address was able to be displayed /// using \a style. File and load addresses may be unresolved /// and it may not be possible to display a valid address value. /// Returns \b false if the address was not able to be properly /// dumped. /// - /// @see Address::DumpStyle - //------------------------------------------------------------------ + /// \see Address::DumpStyle bool Dump(Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const; bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu, Target *target, bool show_address_only) const; - //------------------------------------------------------------------ /// Dumps information specific to a process that stops at this line entry to /// the supplied stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// The compile unit object that contains the support file /// list so the line entry can dump the file name (since this /// object contains a file index into the support file list). /// - /// @return + /// \return /// Returns \b true if the file and line were properly dumped, /// \b false otherwise. - //------------------------------------------------------------------ bool DumpStopContext(Stream *s, bool show_fullpaths) const; - //------------------------------------------------------------------ /// Check if a line entry object is valid. /// - /// @return + /// \return /// Returns \b true if the line entry contains a valid section /// offset address, file index, and line number, \b false /// otherwise. - //------------------------------------------------------------------ bool IsValid() const; - //------------------------------------------------------------------ /// Compare two LineEntry objects. /// - /// @param[in] lhs + /// \param[in] lhs /// The Left Hand Side const LineEntry object reference. /// - /// @param[in] rhs + /// \param[in] rhs /// The Right Hand Side const LineEntry object reference. /// - /// @return - /// @li -1 if lhs < rhs - /// @li 0 if lhs == rhs - /// @li 1 if lhs > rhs - //------------------------------------------------------------------ + /// \return + /// \li -1 if lhs < rhs + /// \li 0 if lhs == rhs + /// \li 1 if lhs > rhs static int Compare(const LineEntry &lhs, const LineEntry &rhs); - //------------------------------------------------------------------ /// Give the range for this LineEntry + any additional LineEntries for this /// same source line that are contiguous. /// @@ -139,27 +123,30 @@ struct LineEntry { /// LineEntry (and it will include the range of the following LineEntries /// that match either 32 or 0.) /// + /// When \b include_inlined_functions is \b true inlined functions with + /// a call site at this LineEntry will also be included in the complete + /// range. + /// /// If the initial LineEntry this method is called on is a line #0, only the /// range of contiuous LineEntries with line #0 will be included in the /// complete range. /// - /// @return + /// @param[in] include_inlined_functions + /// Whether to include inlined functions at the same line or not. + /// + /// \return /// The contiguous AddressRange for this source line. - //------------------------------------------------------------------ - AddressRange GetSameLineContiguousAddressRange() const; + AddressRange + GetSameLineContiguousAddressRange(bool include_inlined_functions) const; - //------------------------------------------------------------------ /// Apply file mappings from target.source-map to the LineEntry's file. /// - /// @param[in] target_sp + /// \param[in] target_sp /// Shared pointer to the target this LineEntry belongs to. - //------------------------------------------------------------------ void ApplyFileMappings(lldb::TargetSP target_sp); - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ AddressRange range; ///< The section offset address range for this line entry. FileSpec file; ///< The source file, possibly mapped by the target.source-map ///setting @@ -183,18 +170,16 @@ struct LineEntry { ///instructions. }; -//------------------------------------------------------------------ /// Less than operator. /// -/// @param[in] lhs +/// \param[in] lhs /// The Left Hand Side const LineEntry object reference. /// -/// @param[in] rhs +/// \param[in] rhs /// The Right Hand Side const LineEntry object reference. /// -/// @return +/// \return /// Returns \b true if lhs < rhs, false otherwise. -//------------------------------------------------------------------ bool operator<(const LineEntry &lhs, const LineEntry &rhs); } // namespace lldb_private diff --git a/include/lldb/Symbol/LineTable.h b/include/lldb/Symbol/LineTable.h index 684972d50789..d24cc35e10f3 100644 --- a/include/lldb/Symbol/LineTable.h +++ b/include/lldb/Symbol/LineTable.h @@ -1,29 +1,25 @@ //===-- LineTable.h ---------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_LineTable_h_ #define liblldb_LineTable_h_ -#include <vector> - #include "lldb/Core/ModuleChild.h" -#include "lldb/Core/RangeMap.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/LineEntry.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" +#include <vector> namespace lldb_private { -//---------------------------------------------------------------------- -/// @class LineSequence LineTable.h "lldb/Symbol/LineTable.h" An abstract base +/// \class LineSequence LineTable.h "lldb/Symbol/LineTable.h" An abstract base /// class used during symbol table creation. -//---------------------------------------------------------------------- class LineSequence { public: LineSequence(); @@ -36,36 +32,28 @@ private: DISALLOW_COPY_AND_ASSIGN(LineSequence); }; -//---------------------------------------------------------------------- -/// @class LineTable LineTable.h "lldb/Symbol/LineTable.h" +/// \class LineTable LineTable.h "lldb/Symbol/LineTable.h" /// A line table class. -//---------------------------------------------------------------------- class LineTable { public: - //------------------------------------------------------------------ /// Construct with compile unit. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// The compile unit to which this line table belongs. - //------------------------------------------------------------------ LineTable(CompileUnit *comp_unit); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~LineTable(); - //------------------------------------------------------------------ /// Adds a new line entry to this line table. /// /// All line entries are maintained in file address order. /// - /// @param[in] line_entry + /// \param[in] line_entry /// A const reference to a new line_entry to add to this line /// table. /// - /// @see Address::DumpStyle - //------------------------------------------------------------------ + /// \see Address::DumpStyle // void // AddLineEntry (const LineEntry& line_entry); @@ -90,45 +78,40 @@ public: // Insert a sequence of entries into this line table. void InsertSequence(LineSequence *sequence); - //------------------------------------------------------------------ /// Dump all line entries in this line table to the stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] style + /// \param[in] style /// The display style for the address. /// - /// @see Address::DumpStyle - //------------------------------------------------------------------ + /// \see Address::DumpStyle void Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_line_ranges); void GetDescription(Stream *s, Target *target, lldb::DescriptionLevel level); - //------------------------------------------------------------------ /// Find a line entry that contains the section offset address \a so_addr. /// - /// @param[in] so_addr + /// \param[in] so_addr /// A section offset address object containing the address we /// are searching for. /// - /// @param[out] line_entry + /// \param[out] line_entry /// A copy of the line entry that was found if \b true is /// returned, otherwise \a entry is left unmodified. /// - /// @param[out] index_ptr + /// \param[out] index_ptr /// A pointer to a 32 bit integer that will get the actual line /// entry index if it is not nullptr. /// - /// @return + /// \return /// Returns \b true if \a so_addr is contained in a line entry /// in this line table, \b false otherwise. - //------------------------------------------------------------------ bool FindLineEntryByAddress(const Address &so_addr, LineEntry &line_entry, uint32_t *index_ptr = nullptr); - //------------------------------------------------------------------ /// Find a line entry index that has a matching file index and source line /// number. /// @@ -136,34 +119,33 @@ public: /// line number \a line starting at the \a start_idx entries into the line /// entry collection. /// - /// @param[in] start_idx + /// \param[in] start_idx /// The number of entries to skip when starting the search. /// - /// @param[out] file_idx + /// \param[out] file_idx /// The file index to search for that should be found prior /// to calling this function using the following functions: /// CompileUnit::GetSupportFiles() /// FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const /// - /// @param[in] line + /// \param[in] line /// The source line to match. /// - /// @param[in] exact + /// \param[in] exact /// If true, match only if you find a line entry exactly matching \a line. /// If false, return the closest line entry greater than \a line. /// - /// @param[out] line_entry + /// \param[out] line_entry /// A reference to a line entry object that will get a copy of /// the line entry if \b true is returned, otherwise \a /// line_entry is left untouched. /// - /// @return + /// \return /// Returns \b true if a matching line entry is found in this /// line table, \b false otherwise. /// - /// @see CompileUnit::GetSupportFiles() - /// @see FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const - //------------------------------------------------------------------ + /// \see CompileUnit::GetSupportFiles() + /// \see FileSpecList::FindFileIndex (uint32_t, const FileSpec &) const uint32_t FindLineEntryIndexByFileIndex(uint32_t start_idx, uint32_t file_idx, uint32_t line, bool exact, LineEntry *line_entry_ptr); @@ -175,61 +157,53 @@ public: size_t FineLineEntriesForFileIndex(uint32_t file_idx, bool append, SymbolContextList &sc_list); - //------------------------------------------------------------------ /// Get the line entry from the line table at index \a idx. /// - /// @param[in] idx + /// \param[in] idx /// An index into the line table entry collection. /// - /// @return + /// \return /// A valid line entry if \a idx is a valid index, or an invalid /// line entry if \a idx is not valid. /// - /// @see LineTable::GetSize() - /// @see LineEntry::IsValid() const - //------------------------------------------------------------------ + /// \see LineTable::GetSize() + /// \see LineEntry::IsValid() const bool GetLineEntryAtIndex(uint32_t idx, LineEntry &line_entry); - //------------------------------------------------------------------ /// Gets the size of the line table in number of line table entries. /// - /// @return + /// \return /// The number of line table entries in this line table. - //------------------------------------------------------------------ uint32_t GetSize() const; typedef lldb_private::RangeArray<lldb::addr_t, lldb::addr_t, 32> FileAddressRanges; - //------------------------------------------------------------------ /// Gets all contiguous file address ranges for the entire line table. /// - /// @param[out] file_ranges + /// \param[out] file_ranges /// A collection of file address ranges that will be filled in /// by this function. /// - /// @param[out] append + /// \param[out] append /// If \b true, then append to \a file_ranges, otherwise clear /// \a file_ranges prior to adding any ranges. /// - /// @return + /// \return /// The number of address ranges added to \a file_ranges - //------------------------------------------------------------------ size_t GetContiguousFileAddressRanges(FileAddressRanges &file_ranges, bool append); - //------------------------------------------------------------------ /// Given a file range link map, relink the current line table and return a /// fixed up line table. /// - /// @param[out] file_range_map + /// \param[out] file_range_map /// A collection of file ranges that maps to new file ranges /// that will be used when linking the line table. /// - /// @return + /// \return /// A new line table if at least one line table entry was able /// to be mapped. - //------------------------------------------------------------------ typedef RangeDataVector<lldb::addr_t, lldb::addr_t, lldb::addr_t> FileRangeMap; @@ -304,9 +278,7 @@ protected: return lhs.file_addr < rhs.file_addr; } - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ /// The file address for this line entry. lldb::addr_t file_addr; /// The source line number, or zero if there is no line number @@ -339,24 +311,18 @@ protected: Entry *a_entry; }; - //------------------------------------------------------------------ // Types - //------------------------------------------------------------------ typedef std::vector<lldb_private::Section *> section_collection; ///< The collection type for the sections. typedef std::vector<Entry> entry_collection; ///< The collection type for the line entries. - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ CompileUnit *m_comp_unit; ///< The compile unit that this line table belongs to. entry_collection m_entries; ///< The collection of line entries in this line table. - //------------------------------------------------------------------ // Helper class - //------------------------------------------------------------------ class LineSequenceImpl : public LineSequence { public: LineSequenceImpl() = default; diff --git a/include/lldb/Symbol/LocateSymbolFile.h b/include/lldb/Symbol/LocateSymbolFile.h new file mode 100644 index 000000000000..0ff834df9c40 --- /dev/null +++ b/include/lldb/Symbol/LocateSymbolFile.h @@ -0,0 +1,58 @@ +//===-- LocateSymbolFile.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_Symbols_h_ +#define liblldb_Symbols_h_ + +#include <stdint.h> + +#include "lldb/Core/FileSpecList.h" +#include "lldb/Utility/FileSpec.h" + +namespace lldb_private { + +class ArchSpec; +class ModuleSpec; +class UUID; + +class Symbols { +public: + // Locate the executable file given a module specification. + // + // Locating the file should happen only on the local computer or using the + // current computers global settings. + static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec); + + // Locate the symbol file given a module specification. + // + // Locating the file should happen only on the local computer or using the + // current computers global settings. + static FileSpec + LocateExecutableSymbolFile(const ModuleSpec &module_spec, + const FileSpecList &default_search_paths); + + static FileSpec FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec, + const lldb_private::UUID *uuid, + const ArchSpec *arch); + + // Locate the object and symbol file given a module specification. + // + // Locating the file can try to download the file from a corporate build + // repository, or using any other means necessary to locate both the + // unstripped object file and the debug symbols. The force_lookup argument + // controls whether the external program is called unconditionally to find + // the symbol file, or if the user's settings are checked to see if they've + // enabled the external program before calling. + // + static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, + bool force_lookup = true); +}; + +} // namespace lldb_private + +#endif // liblldb_Symbols_h_ diff --git a/include/lldb/Symbol/ObjectContainer.h b/include/lldb/Symbol/ObjectContainer.h index 1e14856ea6ea..9310fdc18d90 100644 --- a/include/lldb/Symbol/ObjectContainer.h +++ b/include/lldb/Symbol/ObjectContainer.h @@ -1,9 +1,8 @@ //===-- ObjectContainer.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -19,8 +18,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class ObjectContainer ObjectContainer.h "lldb/Symbol/ObjectContainer.h" +/// \class ObjectContainer ObjectContainer.h "lldb/Symbol/ObjectContainer.h" /// A plug-in interface definition class for object containers. /// /// Object containers contain object files from one or more architectures, and @@ -29,16 +27,13 @@ namespace lldb_private { /// Typical object containers are static libraries (.a files) that contain /// multiple named object files, and universal files that contain multiple /// architectures. -//---------------------------------------------------------------------- class ObjectContainer : public PluginInterface, public ModuleChild { public: - //------------------------------------------------------------------ /// Construct with a parent module, offset, and header data. /// /// Object files belong to modules and a valid module must be supplied upon /// construction. The at an offset within a file for objects that contain /// more than one architecture or object. - //------------------------------------------------------------------ ObjectContainer(const lldb::ModuleSP &module_sp, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset) @@ -51,72 +46,61 @@ public: m_data.SetData(data_sp, data_offset, length); } - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// from by the plug-in instance. - //------------------------------------------------------------------ ~ObjectContainer() override = default; - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the current contents of this object to the /// supplied stream \a s. The dumping should include the section list if it /// has been parsed, and the symbol table if it has been parsed. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ virtual void Dump(Stream *s) const = 0; - //------------------------------------------------------------------ /// Gets the architecture given an index. /// /// Copies the architecture specification for index \a idx. /// - /// @param[in] idx + /// \param[in] idx /// The architecture index to extract. /// - /// @param[out] arch + /// \param[out] arch /// A architecture object that will be filled in if \a idx is a /// architecture valid index. /// - /// @return + /// \return /// Returns \b true if \a idx is valid and \a arch has been /// filled in, \b false otherwise. /// - /// @see ObjectContainer::GetNumArchitectures() const - //------------------------------------------------------------------ + /// \see ObjectContainer::GetNumArchitectures() const virtual bool GetArchitectureAtIndex(uint32_t idx, ArchSpec &arch) const { return false; } - //------------------------------------------------------------------ /// Returns the offset into a file at which this object resides. /// /// Some files contain many object files, and this function allows access to /// an object's offset within the file. /// - /// @return + /// \return /// The offset in bytes into the file. Defaults to zero for /// simple object files that a represented by an entire file. - //------------------------------------------------------------------ virtual lldb::addr_t GetOffset() const { return m_offset; } virtual lldb::addr_t GetByteSize() const { return m_length; } - //------------------------------------------------------------------ /// Get the number of objects within this object file (archives). /// - /// @return + /// \return /// Zero for object files that are not archives, or the number /// of objects contained in the archive. - //------------------------------------------------------------------ virtual size_t GetNumObjects() const { return 0; } - //------------------------------------------------------------------ /// Get the number of architectures in this object file. /// /// The default implementation returns 1 as for object files that contain a @@ -124,12 +108,10 @@ public: /// one architecture should override this function and return an appropriate /// value. /// - /// @return + /// \return /// The number of architectures contained in this object file. - //------------------------------------------------------------------ virtual size_t GetNumArchitectures() const { return 0; } - //------------------------------------------------------------------ /// Attempts to parse the object header. /// /// This function is used as a test to see if a given plug-in instance can @@ -138,13 +120,11 @@ public: /// false should be returned and the next plug-in can attempt to parse an /// object file. /// - /// @return + /// \return /// Returns \b true if the header was parsed successfully, \b /// false otherwise. - //------------------------------------------------------------------ virtual bool ParseHeader() = 0; - //------------------------------------------------------------------ /// Selects an architecture in an object file. /// /// Object files that contain a single architecture should verify that the @@ -156,11 +136,10 @@ public: /// state from any previously selected architecture and prepare to return /// information for the new architecture. /// - /// @return + /// \return /// Returns a pointer to the object file of the requested \a /// arch and optional \a name. Returns nullptr of no such object /// file exists in the container. - //------------------------------------------------------------------ virtual lldb::ObjectFileSP GetObjectFile(const FileSpec *file) = 0; virtual bool ObjectAtIndexIsContainer(uint32_t object_idx) { return false; } @@ -178,9 +157,7 @@ public: } protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ FileSpec m_file; ///< The file that represents this container objects (which ///can be different from the module's file). lldb::addr_t diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h index c6bafcecb6f6..84683e3f2a3f 100644 --- a/include/lldb/Symbol/ObjectFile.h +++ b/include/lldb/Symbol/ObjectFile.h @@ -1,9 +1,8 @@ //===-- ObjectFile.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -43,8 +42,7 @@ public: virtual ArchSpec GetArchitecture() = 0; }; -//---------------------------------------------------------------------- -/// @class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h" +/// \class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h" /// A plug-in interface definition class for object file parsers. /// /// Object files belong to Module objects and know how to extract information @@ -57,14 +55,13 @@ public: /// /// Once an architecture is selected the object file information can be /// extracted from this abstract class. -//---------------------------------------------------------------------- class ObjectFile : public std::enable_shared_from_this<ObjectFile>, public PluginInterface, public ModuleChild { friend class lldb_private::Module; public: - typedef enum { + enum Type { eTypeInvalid = 0, eTypeCoreFile, /// A core file that has a checkpoint of a program's /// execution state @@ -77,29 +74,27 @@ public: /// execution eTypeJIT, /// JIT code that has symbols, sections and possibly debug info eTypeUnknown - } Type; + }; - typedef enum { + enum Strata { eStrataInvalid = 0, eStrataUnknown, eStrataUser, eStrataKernel, eStrataRawImage, eStrataJIT - } Strata; + }; struct LoadableData { lldb::addr_t Dest; llvm::ArrayRef<uint8_t> Contents; }; - //------------------------------------------------------------------ /// Construct with a parent module, offset, and header data. /// /// Object files belong to modules and a valid module must be supplied upon /// construction. The at an offset within a file for objects that contain /// more than one architecture or object. - //------------------------------------------------------------------ ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, const lldb::DataBufferSP &data_sp, lldb::offset_t data_offset); @@ -107,73 +102,65 @@ public: ObjectFile(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, lldb::DataBufferSP &data_sp); - //------------------------------------------------------------------ /// Destructor. /// /// The destructor is virtual since this class is designed to be inherited /// from by the plug-in instance. - //------------------------------------------------------------------ ~ObjectFile() override; - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the current contents of this object to the /// supplied stream \a s. The dumping should include the section list if it /// has been parsed, and the symbol table if it has been parsed. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ virtual void Dump(Stream *s) = 0; - //------------------------------------------------------------------ /// Find a ObjectFile plug-in that can parse \a file_spec. /// /// Scans all loaded plug-in interfaces that implement versions of the /// ObjectFile plug-in interface and returns the first instance that can /// parse the file. /// - /// @param[in] module + /// \param[in] module /// The parent module that owns this object file. /// - /// @param[in] file_spec + /// \param[in] file_spec /// A file specification that indicates which file to use as the /// object file. /// - /// @param[in] file_offset + /// \param[in] file_offset /// The offset into the file at which to start parsing the /// object. This is for files that contain multiple /// architectures or objects. /// - /// @param[in] file_size + /// \param[in] file_size /// The size of the current object file if it can be determined /// or if it is known. This can be zero. /// - /// @see ObjectFile::ParseHeader() - //------------------------------------------------------------------ + /// \see ObjectFile::ParseHeader() static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataBufferSP &data_sp, lldb::offset_t &data_offset); - //------------------------------------------------------------------ /// Find a ObjectFile plug-in that can parse a file in memory. /// /// Scans all loaded plug-in interfaces that implement versions of the /// ObjectFile plug-in interface and returns the first instance that can /// parse the file. /// - /// @param[in] module + /// \param[in] module /// The parent module that owns this object file. /// - /// @param[in] process_sp + /// \param[in] process_sp /// A shared pointer to the process whose memory space contains /// an object file. This will be stored as a std::weak_ptr. /// - /// @param[in] header_addr + /// \param[in] header_addr /// The address of the header for the object file in memory. - //------------------------------------------------------------------ static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, @@ -190,60 +177,53 @@ public: lldb::offset_t file_offset, lldb::offset_t file_size, lldb_private::ModuleSpecList &specs); - //------------------------------------------------------------------ /// Split a path into a file path with object name. /// /// For paths like "/tmp/foo.a(bar.o)" we often need to split a path up into /// the actual path name and into the object name so we can make a valid /// object file from it. /// - /// @param[in] path_with_object + /// \param[in] path_with_object /// A path that might contain an archive path with a .o file /// specified in parens in the basename of the path. /// - /// @param[out] archive_file + /// \param[out] archive_file /// If \b true is returned, \a file_spec will be filled in with /// the path to the archive. /// - /// @param[out] archive_object + /// \param[out] archive_object /// If \b true is returned, \a object will be filled in with /// the name of the object inside the archive. /// - /// @return + /// \return /// \b true if the path matches the pattern of archive + object /// and \a archive_file and \a archive_object are modified, /// \b false otherwise and \a archive_file and \a archive_object /// are guaranteed to be remain unchanged. - //------------------------------------------------------------------ static bool SplitArchivePathWithObject( const char *path_with_object, lldb_private::FileSpec &archive_file, lldb_private::ConstString &archive_object, bool must_exist); - //------------------------------------------------------------------ /// Gets the address size in bytes for the current object file. /// - /// @return + /// \return /// The size of an address in bytes for the currently selected /// architecture (and object for archives). Returns zero if no /// architecture or object has been selected. - //------------------------------------------------------------------ virtual uint32_t GetAddressByteSize() const = 0; - //------------------------------------------------------------------ /// Get the address type given a file address in an object file. /// /// Many binary file formats know what kinds This is primarily for ARM /// binaries, though it can be applied to any executable file format that /// supports different opcode types within the same binary. ARM binaries /// support having both ARM and Thumb within the same executable container. - /// We need to be able to get @return + /// We need to be able to get \return /// The size of an address in bytes for the currently selected /// architecture (and object for archives). Returns zero if no /// architecture or object has been selected. - //------------------------------------------------------------------ virtual AddressClass GetAddressClass(lldb::addr_t file_addr); - //------------------------------------------------------------------ /// Extract the dependent modules from an object file. /// /// If an object file has information about which other images it depends on @@ -252,106 +232,86 @@ public: /// FileSpecList::AppendIfUnique(const FileSpec &) should be used to make /// sure any files that are added are not already in the list. /// - /// @param[out] file_list + /// \param[out] file_list /// A list of file specification objects that gets dependent /// files appended to. /// - /// @return + /// \return /// The number of new files that were appended to \a file_list. /// - /// @see FileSpecList::AppendIfUnique(const FileSpec &) - //------------------------------------------------------------------ + /// \see FileSpecList::AppendIfUnique(const FileSpec &) virtual uint32_t GetDependentModules(FileSpecList &file_list) = 0; - //------------------------------------------------------------------ /// Tells whether this object file is capable of being the main executable /// for a process. /// - /// @return + /// \return /// \b true if it is, \b false otherwise. - //------------------------------------------------------------------ virtual bool IsExecutable() const = 0; - //------------------------------------------------------------------ /// Returns the offset into a file at which this object resides. /// /// Some files contain many object files, and this function allows access to /// an object's offset within the file. /// - /// @return + /// \return /// The offset in bytes into the file. Defaults to zero for /// simple object files that a represented by an entire file. - //------------------------------------------------------------------ virtual lldb::addr_t GetFileOffset() const { return m_file_offset; } virtual lldb::addr_t GetByteSize() const { return m_length; } - //------------------------------------------------------------------ /// Get accessor to the object file specification. /// - /// @return + /// \return /// The file specification object pointer if there is one, or /// NULL if this object is only from memory. - //------------------------------------------------------------------ virtual FileSpec &GetFileSpec() { return m_file; } - //------------------------------------------------------------------ /// Get const accessor to the object file specification. /// - /// @return + /// \return /// The const file specification object pointer if there is one, /// or NULL if this object is only from memory. - //------------------------------------------------------------------ virtual const FileSpec &GetFileSpec() const { return m_file; } - //------------------------------------------------------------------ /// Get the ArchSpec for this object file. /// - /// @return + /// \return /// The ArchSpec of this object file. In case of error, an invalid /// ArchSpec object is returned. - //------------------------------------------------------------------ virtual ArchSpec GetArchitecture() = 0; - //------------------------------------------------------------------ /// Gets the section list for the currently selected architecture (and /// object for archives). /// /// Section list parsing can be deferred by ObjectFile instances until this /// accessor is called the first time. /// - /// @return + /// \return /// The list of sections contained in this object file. - //------------------------------------------------------------------ virtual SectionList *GetSectionList(bool update_module_section_list = true); virtual void CreateSections(SectionList &unified_section_list) = 0; - //------------------------------------------------------------------ /// Notify the ObjectFile that the file addresses in the Sections for this /// module have been changed. - //------------------------------------------------------------------ virtual void SectionFileAddressesChanged() {} - //------------------------------------------------------------------ /// Gets the symbol table for the currently selected architecture (and /// object for archives). /// /// Symbol table parsing can be deferred by ObjectFile instances until this /// accessor is called the first time. /// - /// @return + /// \return /// The symbol table for this object file. - //------------------------------------------------------------------ virtual Symtab *GetSymtab() = 0; - //------------------------------------------------------------------ /// Perform relocations on the section if necessary. /// - //------------------------------------------------------------------ virtual void RelocateSection(lldb_private::Section *section); - //------------------------------------------------------------------ /// Appends a Symbol for the specified so_addr to the symbol table. /// /// If verify_unique is false, the symbol table is not searched to determine @@ -360,10 +320,9 @@ public: /// the first match in the SymbolTable and appends a Symbol only if /// required/found. /// - /// @return + /// \return /// The resolved symbol or nullptr. Returns nullptr if a /// a Symbol could not be found for the specified so_addr. - //------------------------------------------------------------------ virtual Symbol *ResolveSymbolForAddress(const Address &so_addr, bool verify_unique) { // Typically overridden to lazily add stripped symbols recoverable from the @@ -376,94 +335,78 @@ public: return nullptr; } - //------------------------------------------------------------------ /// Detect if this object file has been stripped of local symbols. - //------------------------------------------------------------------ /// Detect if this object file has been stripped of local symbols. /// - /// @return + /// \return /// Return \b true if the object file has been stripped of local /// symbols. - //------------------------------------------------------------------ virtual bool IsStripped() = 0; - //------------------------------------------------------------------ /// Frees the symbol table. /// /// This function should only be used when an object file is /// - /// @param[in] flags + /// \param[in] flags /// eSymtabFromUnifiedSectionList: Whether to clear symbol table /// for unified module section list, or object file. /// - /// @return + /// \return /// The symbol table for this object file. - //------------------------------------------------------------------ virtual void ClearSymtab(); - //------------------------------------------------------------------ /// Gets the UUID for this object file. /// /// If the object file format contains a UUID, the value should be returned. /// Else ObjectFile instances should return the MD5 checksum of all of the /// bytes for the object file (or memory for memory based object files). /// - /// @return - /// Returns \b true if a UUID was successfully extracted into - /// \a uuid, \b false otherwise. - //------------------------------------------------------------------ - virtual bool GetUUID(lldb_private::UUID *uuid) = 0; + /// \return + /// The object file's UUID. In case of an error, an empty UUID is + /// returned. + virtual UUID GetUUID() = 0; - //------------------------------------------------------------------ /// Gets the symbol file spec list for this object file. /// /// If the object file format contains a debug symbol file link, the values /// will be returned in the FileSpecList. /// - /// @return + /// \return /// Returns filespeclist. - //------------------------------------------------------------------ virtual lldb_private::FileSpecList GetDebugSymbolFilePaths() { return FileSpecList(); } - //------------------------------------------------------------------ /// Gets the file spec list of libraries re-exported by this object file. /// /// If the object file format has the notion of one library re-exporting the /// symbols from another, the re-exported libraries will be returned in the /// FileSpecList. /// - /// @return + /// \return /// Returns filespeclist. - //------------------------------------------------------------------ virtual lldb_private::FileSpecList GetReExportedLibraries() { return FileSpecList(); } - //------------------------------------------------------------------ /// Sets the load address for an entire module, assuming a rigid slide of /// sections, if possible in the implementation. /// - /// @return + /// \return /// Returns true iff any section's load address changed. - //------------------------------------------------------------------ virtual bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset) { return false; } - //------------------------------------------------------------------ /// Gets whether endian swapping should occur when extracting data from this /// object file. /// - /// @return + /// \return /// Returns \b true if endian swapping is needed, \b false /// otherwise. - //------------------------------------------------------------------ virtual lldb::ByteOrder GetByteOrder() const = 0; - //------------------------------------------------------------------ /// Attempts to parse the object header. /// /// This function is used as a test to see if a given plug-in instance can @@ -472,27 +415,11 @@ public: /// false should be returned and the next plug-in can attempt to parse an /// object file. /// - /// @return + /// \return /// Returns \b true if the header was parsed successfully, \b /// false otherwise. - //------------------------------------------------------------------ virtual bool ParseHeader() = 0; - //------------------------------------------------------------------ - /// Returns a reference to the UnwindTable for this ObjectFile - /// - /// The UnwindTable contains FuncUnwinders objects for any function in this - /// ObjectFile. If a FuncUnwinders object hasn't been created yet (i.e. the - /// function has yet to be unwound in a stack walk), it will be created when - /// requested. Specifically, we do not create FuncUnwinders objects for - /// functions until they are needed. - /// - /// @return - /// Returns the unwind table for this object file. - //------------------------------------------------------------------ - virtual lldb_private::UnwindTable &GetUnwindTable() { return m_unwind_table; } - - //------------------------------------------------------------------ /// Returns if the function bounds for symbols in this symbol file are /// likely accurate. /// @@ -509,15 +436,13 @@ public: /// that symbol start addresses are unavailable before false is returned. /// If it is unclear, this should return true. /// - /// @return + /// \return /// Returns true if assembly emulation should be used for this /// module. /// Only returns false if the ObjectFile is sure that symbol /// addresses are insufficient for accurate assembly emulation. - //------------------------------------------------------------------ virtual bool AllowAssemblyEmulationUnwindPlans() { return true; } - //------------------------------------------------------------------ /// Similar to Process::GetImageInfoAddress(). /// /// Some platforms embed auxiliary structures useful to debuggers in the @@ -527,24 +452,21 @@ public: /// runtime linker so that a debugger may monitor the loading and unloading /// of shared libraries. /// - /// @return + /// \return /// The address of any auxiliary tables, or an invalid address if this /// object file format does not support or contain such information. virtual lldb_private::Address GetImageInfoAddress(Target *target) { return Address(); } - //------------------------------------------------------------------ /// Returns the address of the Entry Point in this object file - if the /// object file doesn't have an entry point (because it is not an executable /// file) then an invalid address is returned. /// - /// @return + /// \return /// Returns the entry address for this module. - //------------------------------------------------------------------ virtual lldb_private::Address GetEntryPointAddress() { return Address(); } - //------------------------------------------------------------------ /// Returns base address of this object file. /// /// This also sometimes referred to as the "preferred load address" or the @@ -553,46 +475,41 @@ public: /// (usually the first byte of the first section) then the returned address /// will have this section set. Otherwise, the address will just have the /// offset member filled in, indicating that this represents a file address. - //------------------------------------------------------------------ virtual lldb_private::Address GetBaseAddress() { return Address(m_memory_addr); } virtual uint32_t GetNumThreadContexts() { return 0; } - //------------------------------------------------------------------ /// Some object files may have an identifier string embedded in them, e.g. /// in a Mach-O core file using the LC_IDENT load command (which is /// obsolete, but can still be found in some old files) /// - /// @return + /// \return /// Returns the identifier string if one exists, else an empty /// string. - //------------------------------------------------------------------ virtual std::string GetIdentifierString () { return std::string(); } - //------------------------------------------------------------------ /// When the ObjectFile is a core file, lldb needs to locate the "binary" in /// the core file. lldb can iterate over the pages looking for a valid /// binary, but some core files may have metadata describing where the main /// binary is exactly which removes ambiguity when there are multiple /// binaries present in the captured memory pages. /// - /// @param[out] address + /// \param[out] address /// If the address of the binary is specified, this will be set. /// This is an address is the virtual address space of the core file /// memory segments; it is not an offset into the object file. /// If no address is available, will be set to LLDB_INVALID_ADDRESS. /// - /// @param[out] uuid + /// \param[out] uuid /// If the uuid of the binary is specified, this will be set. /// If no UUID is available, will be cleared. /// - /// @return + /// \return /// Returns true if either address or uuid has been set. - //------------------------------------------------------------------ virtual bool GetCorefileMainBinaryInfo (lldb::addr_t &address, UUID &uuid) { address = LLDB_INVALID_ADDRESS; uuid.Clear(); @@ -604,7 +521,6 @@ public: return lldb::RegisterContextSP(); } - //------------------------------------------------------------------ /// The object file should be able to calculate its type by looking at its /// file header and possibly the sections or other data in the object file. /// The file type is used in the debugger to help select the correct plug- @@ -612,18 +528,15 @@ public: /// eTypeXXX definitions do not match up with the type of file you are /// loading, please feel free to add a new enumeration value. /// - /// @return + /// \return /// The calculated file type for the current object file. - //------------------------------------------------------------------ virtual Type CalculateType() = 0; - //------------------------------------------------------------------ /// In cases where the type can't be calculated (elf files), this routine /// allows someone to explicitly set it. As an example, SymbolVendorELF uses /// this routine to set eTypeDebugInfo when loading debug link files. virtual void SetType(Type type) { m_type = type; } - //------------------------------------------------------------------ /// The object file should be able to calculate the strata of the object /// file. /// @@ -632,13 +545,11 @@ public: /// out, it will help with debugger plug-in selection when it comes time to /// debug. /// - /// @return + /// \return /// The calculated object file strata for the current object /// file. - //------------------------------------------------------------------ virtual Strata CalculateStrata() = 0; - //------------------------------------------------------------------ /// Get the object file version numbers. /// /// Many object files have a set of version numbers that describe the @@ -646,43 +557,33 @@ public: /// minor and build, but there may be more. This function will extract the /// versions from object files if they are available. /// - /// @return + /// \return /// This function returns extracted version numbers as a /// llvm::VersionTuple. In case of error an empty VersionTuple is /// returned. - //------------------------------------------------------------------ virtual llvm::VersionTuple GetVersion() { return llvm::VersionTuple(); } - //------------------------------------------------------------------ /// Get the minimum OS version this object file can run on. /// /// Some object files have information that specifies the minimum OS version /// that they can be used on. /// - /// @return + /// \return /// This function returns extracted version numbers as a /// llvm::VersionTuple. In case of error an empty VersionTuple is /// returned. - //------------------------------------------------------------------ virtual llvm::VersionTuple GetMinimumOSVersion() { return llvm::VersionTuple(); } - //------------------------------------------------------------------ /// Get the SDK OS version this object file was built with. /// - /// The versions arguments and returns values are the same as the - /// GetMinimumOSVersion() - //------------------------------------------------------------------ - virtual uint32_t GetSDKVersion(uint32_t *versions, uint32_t num_versions) { - if (versions && num_versions) { - for (uint32_t i = 0; i < num_versions; ++i) - versions[i] = UINT32_MAX; - } - return 0; - } + /// \return + /// This function returns extracted version numbers as a + /// llvm::VersionTuple. In case of error an empty VersionTuple is + /// returned. + virtual llvm::VersionTuple GetSDKVersion() { return llvm::VersionTuple(); } - //------------------------------------------------------------------ /// Return true if this file is a dynamic link editor (dyld) /// /// Often times dyld has symbols that mirror symbols in libc and other @@ -690,12 +591,9 @@ public: /// to stop in these shared libraries by default. We can ask the ObjectFile /// if it is such a file and should be avoided for things like settings /// breakpoints and doing function lookups for expressions. - //------------------------------------------------------------------ virtual bool GetIsDynamicLinkEditor() { return false; } - //------------------------------------------------------------------ // Member Functions - //------------------------------------------------------------------ Type GetType() { if (m_type == eTypeInvalid) m_type = CalculateType(); @@ -747,24 +645,20 @@ public: llvm::StringRef name, lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined); - //------------------------------------------------------------------ /// Loads this objfile to memory. /// /// Loads the bits needed to create an executable image to the memory. It is /// useful with bare-metal targets where target does not have the ability to /// start a process itself. /// - /// @param[in] target + /// \param[in] target /// Target where to load. /// - /// @return - //------------------------------------------------------------------ + /// \return virtual std::vector<LoadableData> GetLoadableData(Target &target); protected: - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ FileSpec m_file; Type m_type; Strata m_strata; @@ -775,27 +669,22 @@ protected: ///determined). DataExtractor m_data; ///< The data for this object file so things can be parsed lazily. - lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects - /// created for this ObjectFile's - /// functions lldb::ProcessWP m_process_wp; const lldb::addr_t m_memory_addr; - std::unique_ptr<lldb_private::SectionList> m_sections_ap; - std::unique_ptr<lldb_private::Symtab> m_symtab_ap; + std::unique_ptr<lldb_private::SectionList> m_sections_up; + std::unique_ptr<lldb_private::Symtab> m_symtab_up; uint32_t m_synthetic_symbol_idx; - //------------------------------------------------------------------ /// Sets the architecture for a module. At present the architecture can /// only be set if it is invalid. It is not allowed to switch from one /// concrete architecture to another. /// - /// @param[in] new_arch + /// \param[in] new_arch /// The architecture this module will be set to. /// - /// @return + /// \return /// Returns \b true if the architecture was changed, \b /// false otherwise. - //------------------------------------------------------------------ bool SetModulesArchitecture(const ArchSpec &new_arch); ConstString GetNextSyntheticSymbolName(); diff --git a/include/lldb/Symbol/PostfixExpression.h b/include/lldb/Symbol/PostfixExpression.h new file mode 100644 index 000000000000..e3a8587a5f84 --- /dev/null +++ b/include/lldb/Symbol/PostfixExpression.h @@ -0,0 +1,226 @@ +//===-- PostfixExpression.h -------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements support for postfix expressions found in several symbol +// file formats, and their conversion to DWARF. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SYMBOL_POSTFIXEXPRESSION_H +#define LLDB_SYMBOL_POSTFIXEXPRESSION_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Casting.h" + +namespace lldb_private { + +class Stream; + +namespace postfix { + +/// The base class for all nodes in the parsed postfix tree. +class Node { +public: + enum Kind { + BinaryOp, + InitialValue, + Integer, + Register, + Symbol, + UnaryOp, + }; + +protected: + Node(Kind kind) : m_kind(kind) {} + +public: + Kind GetKind() const { return m_kind; } + +private: + Kind m_kind; +}; + +/// A node representing a binary expression. +class BinaryOpNode : public Node { +public: + enum OpType { + Align, // alignDown(a, b) + Minus, // a - b + Plus, // a + b + }; + + BinaryOpNode(OpType op_type, Node &left, Node &right) + : Node(BinaryOp), m_op_type(op_type), m_left(&left), m_right(&right) {} + + OpType GetOpType() const { return m_op_type; } + + const Node *Left() const { return m_left; } + Node *&Left() { return m_left; } + + const Node *Right() const { return m_right; } + Node *&Right() { return m_right; } + + static bool classof(const Node *node) { return node->GetKind() == BinaryOp; } + +private: + OpType m_op_type; + Node *m_left; + Node *m_right; +}; + +/// A node representing the canonical frame address. +class InitialValueNode: public Node { +public: + InitialValueNode() : Node(InitialValue) {} + + static bool classof(const Node *node) { + return node->GetKind() == InitialValue; + } +}; + +/// A node representing an integer literal. +class IntegerNode : public Node { +public: + IntegerNode(int64_t value) : Node(Integer), m_value(value) {} + + int64_t GetValue() const { return m_value; } + + static bool classof(const Node *node) { return node->GetKind() == Integer; } + +private: + int64_t m_value; +}; + +/// A node representing the value of a register with the given register number. +/// The register kind (RegisterKind enum) used for the specifying the register +/// number is implicit and assumed to be the same for all Register nodes in a +/// given tree. +class RegisterNode : public Node { +public: + RegisterNode(uint32_t reg_num) : Node(Register), m_reg_num(reg_num) {} + + uint32_t GetRegNum() const { return m_reg_num; } + + static bool classof(const Node *node) { return node->GetKind() == Register; } + +private: + uint32_t m_reg_num; +}; + +/// A node representing a symbolic reference to a named entity. This may be a +/// register, which hasn't yet been resolved to a RegisterNode. +class SymbolNode : public Node { +public: + SymbolNode(llvm::StringRef name) : Node(Symbol), m_name(name) {} + + llvm::StringRef GetName() const { return m_name; } + + static bool classof(const Node *node) { return node->GetKind() == Symbol; } + +private: + llvm::StringRef m_name; +}; + +/// A node representing a unary operation. +class UnaryOpNode : public Node { +public: + enum OpType { + Deref, // *a + }; + + UnaryOpNode(OpType op_type, Node &operand) + : Node(UnaryOp), m_op_type(op_type), m_operand(&operand) {} + + OpType GetOpType() const { return m_op_type; } + + const Node *Operand() const { return m_operand; } + Node *&Operand() { return m_operand; } + + static bool classof(const Node *node) { return node->GetKind() == UnaryOp; } + +private: + OpType m_op_type; + Node *m_operand; +}; + +/// A template class implementing a visitor pattern, but with a couple of +/// twists: +/// - It uses type switch instead of virtual double dispatch. This allows the +// node classes to be vtable-free and trivially destructible. +/// - The Visit functions get an extra Node *& parameter, which refers to the +/// child pointer of the parent of the node we are currently visiting. This +/// allows mutating algorithms, which replace the currently visited node with +/// a different one. +/// - The class is templatized on the return type of the Visit functions, which +/// means it's possible to return values from them. +template <typename ResultT = void> class Visitor { +protected: + virtual ~Visitor() = default; + + virtual ResultT Visit(BinaryOpNode &binary, Node *&ref) = 0; + virtual ResultT Visit(InitialValueNode &val, Node *&ref) = 0; + virtual ResultT Visit(IntegerNode &integer, Node *&) = 0; + virtual ResultT Visit(RegisterNode ®, Node *&) = 0; + virtual ResultT Visit(SymbolNode &symbol, Node *&ref) = 0; + virtual ResultT Visit(UnaryOpNode &unary, Node *&ref) = 0; + + /// Invoke the correct Visit function based on the dynamic type of the given + /// node. + ResultT Dispatch(Node *&node) { + switch (node->GetKind()) { + case Node::BinaryOp: + return Visit(llvm::cast<BinaryOpNode>(*node), node); + case Node::InitialValue: + return Visit(llvm::cast<InitialValueNode>(*node), node); + case Node::Integer: + return Visit(llvm::cast<IntegerNode>(*node), node); + case Node::Register: + return Visit(llvm::cast<RegisterNode>(*node), node); + case Node::Symbol: + return Visit(llvm::cast<SymbolNode>(*node), node); + case Node::UnaryOp: + return Visit(llvm::cast<UnaryOpNode>(*node), node); + } + llvm_unreachable("Fully covered switch!"); + } +}; + +/// A utility function for "resolving" SymbolNodes. It traverses a tree and +/// calls the callback function for all SymbolNodes it encountered. The +/// replacement function should return the node it wished to replace the current +/// SymbolNode with (this can also be the original node), or nullptr in case of +/// an error. The nodes returned by the callback are inspected and replaced +/// recursively, *except* for the case when the function returns the exact same +/// node as the input one. It returns true if all SymbolNodes were replaced +/// successfully. +bool ResolveSymbols(Node *&node, + llvm::function_ref<Node *(SymbolNode &symbol)> replacer); + +template <typename T, typename... Args> +inline T *MakeNode(llvm::BumpPtrAllocator &alloc, Args &&... args) { + static_assert(std::is_trivially_destructible<T>::value, + "This object will not be destroyed!"); + return new (alloc.Allocate<T>()) T(std::forward<Args>(args)...); +} + +/// Parse the given postfix expression. The parsed nodes are placed into the +/// provided allocator. +Node *Parse(llvm::StringRef expr, llvm::BumpPtrAllocator &alloc); + +/// Serialize the given expression tree as DWARF. The result is written into the +/// given stream. The AST should not contain any SymbolNodes. If the expression +/// contains InitialValueNodes, the generated expression will assume that their +/// value will be provided as the top value of the initial evaluation stack (as +/// is the case with the CFA value in register eh_unwind rules). +void ToDWARF(Node &node, Stream &stream); + +} // namespace postfix +} // namespace lldb_private + +#endif // LLDB_SYMBOL_POSTFIXEXPRESSION_H diff --git a/include/lldb/Symbol/SourceModule.h b/include/lldb/Symbol/SourceModule.h new file mode 100644 index 000000000000..b12ff01a5198 --- /dev/null +++ b/include/lldb/Symbol/SourceModule.h @@ -0,0 +1,27 @@ +//===-- SourceModule.h ------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_SourceModule_h_ +#define liblldb_SourceModule_h_ + +#include "lldb/Utility/ConstString.h" +#include <vector> + +namespace lldb_private { + +/// Information needed to import a source-language module. +struct SourceModule { + /// Something like "Module.Submodule". + std::vector<ConstString> path; + ConstString search_path; + ConstString sysroot; +}; + +} // namespace lldb_private + +#endif diff --git a/include/lldb/Symbol/Symbol.h b/include/lldb/Symbol/Symbol.h index 9523158e0780..1cbc2f5492f4 100644 --- a/include/lldb/Symbol/Symbol.h +++ b/include/lldb/Symbol/Symbol.h @@ -1,9 +1,8 @@ //===-- Symbol.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -43,41 +42,33 @@ public: void Clear(); - bool Compare(const ConstString &name, lldb::SymbolType type) const; + bool Compare(ConstString name, lldb::SymbolType type) const; void Dump(Stream *s, Target *target, uint32_t index) const; bool ValueIsAddress() const; - //------------------------------------------------------------------ // The GetAddressRef() accessor functions should only be called if you // previously call ValueIsAddress() otherwise you might get an reference to // an Address object that contains an constant integer value in // m_addr_range.m_base_addr.m_offset which could be incorrectly used to // represent an absolute address since it has no section. - //------------------------------------------------------------------ Address &GetAddressRef() { return m_addr_range.GetBaseAddress(); } const Address &GetAddressRef() const { return m_addr_range.GetBaseAddress(); } - //------------------------------------------------------------------ // Makes sure the symbol's value is an address and returns the file address. // Returns LLDB_INVALID_ADDRESS if the symbol's value isn't an address. - //------------------------------------------------------------------ lldb::addr_t GetFileAddress() const; - //------------------------------------------------------------------ // Makes sure the symbol's value is an address and gets the load address // using \a target if it is. Returns LLDB_INVALID_ADDRESS if the symbol's // value isn't an address or if the section isn't loaded in \a target. - //------------------------------------------------------------------ lldb::addr_t GetLoadAddress(Target *target) const; - //------------------------------------------------------------------ // Access the address value. Do NOT hand out the AddressRange as an object as // the byte size of the address range may not be filled in and it should be // accessed via GetByteSize(). - //------------------------------------------------------------------ Address GetAddress() const { // Make sure the our value is an address before we hand a copy out. We use // the Address inside m_addr_range to contain the value for symbols that @@ -134,7 +125,7 @@ public: FileSpec GetReExportedSymbolSharedLibrary() const; - void SetReExportedSymbolName(const ConstString &name); + void SetReExportedSymbolName(ConstString name); bool SetReExportedSymbolSharedLibrary(const FileSpec &fspec); @@ -174,6 +165,10 @@ public: bool IsTrampoline() const; bool IsIndirect() const; + + bool IsWeak() const { return m_is_weak; } + + void SetIsWeak (bool b) { m_is_weak = b; } bool GetByteSizeIsValid() const { return m_size_is_valid; } @@ -204,22 +199,18 @@ public: void SetContainsLinkerAnnotations(bool b) { m_contains_linker_annotations = b; } - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) + /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void CalculateSymbolContext(SymbolContext *sc) override; lldb::ModuleSP CalculateSymbolContextModule() override; Symbol *CalculateSymbolContextSymbol() override; - //------------------------------------------------------------------ - /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*) + /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*) /// - /// @see SymbolContextScope - //------------------------------------------------------------------ + /// \see SymbolContextScope void DumpSymbolContext(Stream *s) override; lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx, @@ -263,7 +254,8 @@ protected: m_contains_linker_annotations : 1, // The symbol name contains linker // annotations, which are optional when // doing name lookups - m_type : 7; + m_is_weak : 1, + m_type : 6; // Values from the lldb::SymbolType enum. Mangled m_mangled; // uniqued symbol name/mangled name pair AddressRange m_addr_range; // Contains the value, or the section offset // address when the value is an address in a diff --git a/include/lldb/Symbol/SymbolContext.h b/include/lldb/Symbol/SymbolContext.h index a7afffb705d2..55a345489358 100644 --- a/include/lldb/Symbol/SymbolContext.h +++ b/include/lldb/Symbol/SymbolContext.h @@ -1,9 +1,8 @@ //===-- SymbolContext.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -24,59 +23,51 @@ namespace lldb_private { class SymbolContextScope; -//---------------------------------------------------------------------- -/// @class SymbolContext SymbolContext.h "lldb/Symbol/SymbolContext.h" Defines +/// \class SymbolContext SymbolContext.h "lldb/Symbol/SymbolContext.h" Defines /// a symbol context baton that can be handed other debug core functions. /// /// Many debugger functions require a context when doing lookups. This class /// provides a common structure that can be used as the result of a query that /// can contain a single result. Examples of such queries include -/// @li Looking up a load address. -//---------------------------------------------------------------------- +/// \li Looking up a load address. class SymbolContext { public: - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize all pointer members to nullptr and all struct members to /// their default state. - //------------------------------------------------------------------ SymbolContext(); - //------------------------------------------------------------------ /// Construct with an object that knows how to reconstruct its symbol /// context. /// - /// @param[in] sc_scope + /// \param[in] sc_scope /// A symbol context scope object that knows how to reconstruct /// it's context. - //------------------------------------------------------------------ explicit SymbolContext(SymbolContextScope *sc_scope); - //------------------------------------------------------------------ /// Construct with module, and optional compile unit, function, block, line /// table, line entry and symbol. /// /// Initialize all pointer to the specified values. /// - /// @param[in] module + /// \param[in] module /// A Module pointer to the module for this context. /// - /// @param[in] comp_unit + /// \param[in] comp_unit /// A CompileUnit pointer to the compile unit for this context. /// - /// @param[in] function + /// \param[in] function /// A Function pointer to the function for this context. /// - /// @param[in] block + /// \param[in] block /// A Block pointer to the deepest block for this context. /// - /// @param[in] line_entry + /// \param[in] line_entry /// A LineEntry pointer to the line entry for this context. /// - /// @param[in] symbol + /// \param[in] symbol /// A Symbol pointer to the symbol for this context. - //------------------------------------------------------------------ explicit SymbolContext(const lldb::TargetSP &target_sp, const lldb::ModuleSP &module_sp, CompileUnit *comp_unit = nullptr, @@ -91,52 +82,35 @@ public: LineEntry *line_entry = nullptr, Symbol *symbol = nullptr); - //------------------------------------------------------------------ - /// Copy constructor - /// - /// Makes a copy of the another SymbolContext object \a rhs. - /// - /// @param[in] rhs - /// A const SymbolContext object reference to copy. - //------------------------------------------------------------------ - SymbolContext(const SymbolContext &rhs); - ~SymbolContext(); - //------------------------------------------------------------------ /// Assignment operator. /// /// Copies the address value from another SymbolContext object \a rhs into /// \a this object. /// - /// @param[in] rhs + /// \param[in] rhs /// A const SymbolContext object reference to copy. /// - /// @return + /// \return /// A const SymbolContext object reference to \a this. - //------------------------------------------------------------------ const SymbolContext &operator=(const SymbolContext &rhs); - //------------------------------------------------------------------ /// Clear the object's state. /// /// Resets all pointer members to nullptr, and clears any class objects to /// their default state. - //------------------------------------------------------------------ void Clear(bool clear_target); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream /// \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, Target *target) const; - //------------------------------------------------------------------ /// Dump the stop context in this object to a Stream. /// /// Dump the best description of this object to the stream. The information @@ -146,45 +120,43 @@ public: /// is available, that will be output. Else just the address at which the /// target was stopped will be displayed. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. /// - /// @param[in] so_addr + /// \param[in] so_addr /// The resolved section offset address. /// - /// @param[in] show_fullpaths + /// \param[in] show_fullpaths /// When printing file paths (with the Module), whether the /// base name of the Module should be printed or the full path. /// - /// @param[in] show_module + /// \param[in] show_module /// Whether the module name should be printed followed by a /// grave accent "`" character. /// - /// @param[in] show_inlined_frames + /// \param[in] show_inlined_frames /// If a given pc is in inlined function(s), whether the inlined /// functions should be printed on separate lines in addition to /// the concrete function containing the pc. /// - /// @param[in] show_function_arguments + /// \param[in] show_function_arguments /// If false, this method will try to elide the function argument /// types when printing the function name. This may be ambiguous /// for languages that have function overloading - but it may /// make the "function name" too long to include all the argument /// types. /// - /// @param[in] show_function_name + /// \param[in] show_function_name /// Normally this should be true - the function/symbol name should /// be printed. In disassembly formatting, where we want a format /// like "<*+36>", this should be false and "*" will be printed /// instead. - //------------------------------------------------------------------ bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name) const; - //------------------------------------------------------------------ /// Get the address range contained within a symbol context. /// /// Address range priority is as follows: @@ -197,17 +169,17 @@ public: /// - symbol address range if symbol is not nullptr and /// eSymbolContextSymbol is set in \a scope /// - /// @param[in] scope + /// \param[in] scope /// A mask of symbol context bits telling this function which /// address ranges it can use when trying to extract one from /// the valid (non-nullptr) symbol context classes. /// - /// @param[in] range_idx + /// \param[in] range_idx /// The address range index to grab. Since many functions and /// blocks are not always contiguous, they may have more than /// one address range. /// - /// @param[in] use_inline_block_range + /// \param[in] use_inline_block_range /// If \a scope has the eSymbolContextBlock bit set, and there /// is a valid block in the symbol context, return the block /// address range for the containing inline function block, not @@ -215,21 +187,19 @@ public: /// for the address range of the inlined function block, not /// the deepest lexical block. /// - /// @param[out] range + /// \param[out] range /// An address range object that will be filled in if \b true /// is returned. /// - /// @return + /// \return /// \b True if this symbol context contains items that describe /// an address range, \b false otherwise. - //------------------------------------------------------------------ bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const; bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Status &error); - //------------------------------------------------------------------ /// Find the best global data symbol visible from this context. /// /// Symbol priority is: @@ -239,18 +209,17 @@ public: /// - non-extern symbol in the target /// It is an error if the highest-priority result is ambiguous. /// - /// @param[in] name + /// \param[in] name /// The name of the symbol to search for. /// - /// @param[out] error + /// \param[out] error /// An error that will be populated with a message if there was an /// ambiguous result. The error will not be populated if no result /// was found. /// - /// @return + /// \return /// The symbol that was found, or \b nullptr if none was found. - //------------------------------------------------------------------ - const Symbol *FindBestGlobalDataSymbol(const ConstString &name, Status &error); + const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error); void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) const; @@ -259,7 +228,6 @@ public: lldb::LanguageType GetLanguage() const; - //------------------------------------------------------------------ /// Find a block that defines the function represented by this symbol /// context. /// @@ -276,59 +244,51 @@ public: /// represented by this symbol context (whether the function is an inline /// function or not). /// - /// @return + /// \return /// The block object pointer that defines the function that is /// represented by this symbol context object, nullptr otherwise. - //------------------------------------------------------------------ Block *GetFunctionBlock(); - //------------------------------------------------------------------ /// If this symbol context represents a function that is a method, return /// true and provide information about the method. /// - /// @param[out] language + /// \param[out] language /// If \b true is returned, the language for the method. /// - /// @param[out] is_instance_method + /// \param[out] is_instance_method /// If \b true is returned, \b true if this is a instance method, /// \b false if this is a static/class function. /// - /// @param[out] language_object_name + /// \param[out] language_object_name /// If \b true is returned, the name of the artificial variable /// for the language ("this" for C++, "self" for ObjC). /// - /// @return + /// \return /// \b True if this symbol context represents a function that /// is a method of a class, \b false otherwise. - //------------------------------------------------------------------ bool GetFunctionMethodInfo(lldb::LanguageType &language, bool &is_instance_method, ConstString &language_object_name); - //------------------------------------------------------------------ /// Sorts the types in TypeMap according to SymbolContext to TypeList /// - //------------------------------------------------------------------ void SortTypeList(TypeMap &type_map, TypeList &type_list) const; - //------------------------------------------------------------------ /// Find a name of the innermost function for the symbol context. /// /// For instance, if the symbol context contains an inlined block, it will /// return the inlined function name. /// - /// @param[in] prefer_mangled + /// \param[in] prefer_mangled /// if \btrue, then the mangled name will be returned if there /// is one. Otherwise the unmangled name will be returned if it /// is available. /// - /// @return + /// \return /// The name of the function represented by this symbol context. - //------------------------------------------------------------------ ConstString GetFunctionName( Mangled::NamePreference preference = Mangled::ePreferDemangled) const; - //------------------------------------------------------------------ /// Get the line entry that corresponds to the function. /// /// If the symbol context contains an inlined block, the line entry for the @@ -339,43 +299,38 @@ public: /// table information for the symbol context. it will return the inlined /// function name. /// - /// @param[in] prefer_mangled + /// \param[in] prefer_mangled /// if \btrue, then the mangled name will be returned if there /// is one. Otherwise the unmangled name will be returned if it /// is available. /// - /// @return + /// \return /// The name of the function represented by this symbol context. - //------------------------------------------------------------------ LineEntry GetFunctionStartLineEntry() const; - //------------------------------------------------------------------ /// Find the block containing the inlined block that contains this block. /// /// For instance, if the symbol context contains an inlined block, it will /// return the inlined function name. /// - /// @param[in] curr_frame_pc + /// \param[in] curr_frame_pc /// The address within the block of this object. /// - /// @param[out] next_frame_sc + /// \param[out] next_frame_sc /// A new symbol context that does what the title says it does. /// - /// @param[out] next_frame_addr + /// \param[out] next_frame_addr /// This is what you should report as the PC in \a next_frame_sc. /// - /// @return + /// \return /// \b true if this SymbolContext specifies a block contained in an /// inlined block. If this returns \b true, \a next_frame_sc and /// \a next_frame_addr will be filled in correctly. - //------------------------------------------------------------------ bool GetParentOfInlinedScope(const Address &curr_frame_pc, SymbolContext &next_frame_sc, Address &inlined_frame_addr) const; - //------------------------------------------------------------------ // Member variables - //------------------------------------------------------------------ lldb::TargetSP target_sp; ///< The Target for a given query lldb::ModuleSP module_sp; ///< The Module for a given query CompileUnit *comp_unit; ///< The CompileUnit for a given query @@ -388,7 +343,7 @@ public: class SymbolContextSpecifier { public: - typedef enum SpecificationType { + enum SpecificationType { eNothingSpecified = 0, eModuleSpecified = 1 << 0, eFileSpecified = 1 << 1, @@ -397,7 +352,7 @@ public: eFunctionSpecified = 1 << 4, eClassOrNamespaceSpecified = 1 << 5, eAddressRangeSpecified = 1 << 6 - } SpecificationType; + }; // This one produces a specifier that matches everything... SymbolContextSpecifier(const lldb::TargetSP &target_sp); @@ -420,45 +375,37 @@ private: lldb::TargetSP m_target_sp; std::string m_module_spec; lldb::ModuleSP m_module_sp; - std::unique_ptr<FileSpec> m_file_spec_ap; + std::unique_ptr<FileSpec> m_file_spec_up; size_t m_start_line; size_t m_end_line; std::string m_function_spec; std::string m_class_name; - std::unique_ptr<AddressRange> m_address_range_ap; + std::unique_ptr<AddressRange> m_address_range_up; uint32_t m_type; // Or'ed bits from SpecificationType }; -//---------------------------------------------------------------------- -/// @class SymbolContextList SymbolContext.h "lldb/Symbol/SymbolContext.h" +/// \class SymbolContextList SymbolContext.h "lldb/Symbol/SymbolContext.h" /// Defines a list of symbol context objects. /// /// This class provides a common structure that can be used to contain the /// result of a query that can contain a multiple results. Examples of such /// queries include: -/// @li Looking up a function by name. -/// @li Finding all addresses for a specified file and line number. -//---------------------------------------------------------------------- +/// \li Looking up a function by name. +/// \li Finding all addresses for a specified file and line number. class SymbolContextList { public: - //------------------------------------------------------------------ /// Default constructor. /// /// Initialize with an empty list. - //------------------------------------------------------------------ SymbolContextList(); - //------------------------------------------------------------------ /// Destructor. - //------------------------------------------------------------------ ~SymbolContextList(); - //------------------------------------------------------------------ /// Append a new symbol context to the list. /// - /// @param[in] sc + /// \param[in] sc /// A symbol context to append to the list. - //------------------------------------------------------------------ void Append(const SymbolContext &sc); void Append(const SymbolContextList &sc_list); @@ -468,55 +415,47 @@ public: uint32_t AppendIfUnique(const SymbolContextList &sc_list, bool merge_symbol_into_function); - //------------------------------------------------------------------ /// Clear the object's state. /// /// Clears the symbol context list. - //------------------------------------------------------------------ void Clear(); - //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of each symbol context in the list to /// the supplied stream \a s. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object description. - //------------------------------------------------------------------ void Dump(Stream *s, Target *target) const; - //------------------------------------------------------------------ /// Get accessor for a symbol context at index \a idx. /// /// Dump a description of the contents of each symbol context in the list to /// the supplied stream \a s. /// - /// @param[in] idx + /// \param[in] idx /// The zero based index into the symbol context list. /// - /// @param[out] sc + /// \param[out] sc /// A reference to the symbol context to fill in. /// - /// @return + /// \return /// Returns \b true if \a idx was a valid index into this /// symbol context list and \a sc was filled in, \b false /// otherwise. - //------------------------------------------------------------------ bool GetContextAtIndex(size_t idx, SymbolContext &sc) const; - //------------------------------------------------------------------ /// Direct reference accessor for a symbol context at index \a idx. /// /// The index \a idx must be a valid index, no error checking will be done /// to ensure that it is valid. /// - /// @param[in] idx + /// \param[in] idx /// The zero based index into the symbol context list. /// - /// @return + /// \return /// A const reference to the symbol context to fill in. - //------------------------------------------------------------------ SymbolContext &operator[](size_t idx) { return m_symbol_contexts[idx]; } const SymbolContext &operator[](size_t idx) const { @@ -525,12 +464,10 @@ public: bool RemoveContextAtIndex(size_t idx); - //------------------------------------------------------------------ /// Get accessor for a symbol context list size. /// - /// @return + /// \return /// Returns the number of symbol context objects in the list. - //------------------------------------------------------------------ uint32_t GetSize() const; uint32_t NumLineEntriesWithLine(uint32_t line) const; @@ -542,9 +479,7 @@ protected: typedef std::vector<SymbolContext> collection; ///< The collection type for the list. - //------------------------------------------------------------------ // Member variables. - //------------------------------------------------------------------ collection m_symbol_contexts; ///< The list of symbol contexts. public: diff --git a/include/lldb/Symbol/SymbolContextScope.h b/include/lldb/Symbol/SymbolContextScope.h index 85718b9bba4f..a626302053df 100644 --- a/include/lldb/Symbol/SymbolContextScope.h +++ b/include/lldb/Symbol/SymbolContextScope.h @@ -1,9 +1,8 @@ //===-- SymbolContextScope.h ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,8 +13,7 @@ namespace lldb_private { -//---------------------------------------------------------------------- -/// @class SymbolContextScope SymbolContextScope.h +/// \class SymbolContextScope SymbolContextScope.h /// "lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is /// part of a symbol context /// and can reconstruct its symbol context. @@ -27,11 +25,11 @@ namespace lldb_private { /// complete SymbolContext object in the object. /// /// Examples of these objects include: -/// @li Module -/// @li CompileUnit -/// @li Function -/// @li Block -/// @li Symbol +/// \li Module +/// \li CompileUnit +/// \li Function +/// \li Block +/// \li Symbol /// /// Other objects can store a "SymbolContextScope *" using any pointers to one /// of the above objects. This allows clients to hold onto a pointer that @@ -41,7 +39,7 @@ namespace lldb_private { /// /// Example objects include that currently use "SymbolContextScope *" objects /// include: -/// @li Variable objects that can reconstruct where they are scoped +/// \li Variable objects that can reconstruct where they are scoped /// by making sure the SymbolContextScope * comes from the scope /// in which the variable was declared. If a variable is a global, /// the appropriate CompileUnit * will be used when creating the @@ -49,9 +47,9 @@ namespace lldb_private { /// in which the variable is defined. Function arguments can use /// the Function object as their scope. The SymbolFile parsers /// will set these correctly as the variables are parsed. -/// @li Type objects that know exactly in which scope they +/// \li Type objects that know exactly in which scope they /// originated much like the variables above. -/// @li StackID objects that are able to know that if the CFA +/// \li StackID objects that are able to know that if the CFA /// (stack pointer at the beginning of a function) and the /// start PC for the function/symbol and the SymbolContextScope /// pointer (a unique pointer that identifies a symbol context @@ -63,21 +61,18 @@ namespace lldb_private { /// can also be created using a SymbolContextScope* and and object pairs that /// allow large collections of objects to be passed around with minimal /// overhead. -//---------------------------------------------------------------------- class SymbolContextScope { public: virtual ~SymbolContextScope() = default; - //------------------------------------------------------------------ /// Reconstruct the object's symbol context into \a sc. /// /// The object should fill in as much of the SymbolContext as it can so /// function calls that require a symbol context can be made for the given /// object. /// - /// @param[out] sc + /// \param[out] sc /// A symbol context object pointer that gets filled in. - //------------------------------------------------------------------ virtual void CalculateSymbolContext(SymbolContext *sc) = 0; virtual lldb::ModuleSP CalculateSymbolContextModule() { @@ -92,16 +87,14 @@ public: virtual Symbol *CalculateSymbolContextSymbol() { return nullptr; } - //------------------------------------------------------------------ /// Dump the object's symbol context to the stream \a s. /// /// The object should dump its symbol context to the stream \a s. This /// function is widely used in the DumpDebug and verbose output for lldb /// objects. /// - /// @param[in] s + /// \param[in] s /// The stream to which to dump the object's symbol context. - //------------------------------------------------------------------ virtual void DumpSymbolContext(Stream *s) = 0; }; diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h index 433c20da99e2..dbb723e9d369 100644 --- a/include/lldb/Symbol/SymbolFile.h +++ b/include/lldb/Symbol/SymbolFile.h @@ -1,9 +1,8 @@ //===-- SymbolFile.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -15,6 +14,7 @@ #include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Function.h" +#include "lldb/Symbol/SourceModule.h" #include "lldb/Symbol/Type.h" #include "lldb/lldb-private.h" @@ -32,14 +32,12 @@ namespace lldb_private { class SymbolFile : public PluginInterface { public: - //------------------------------------------------------------------ // Symbol file ability bits. // // Each symbol file can claim to support one or more symbol file abilities. // These get returned from SymbolFile::GetAbilities(). These help us to // determine which plug-in will be best to load the debug information found // in files. - //------------------------------------------------------------------ enum Abilities { CompileUnits = (1u << 0), LineTables = (1u << 1), @@ -53,15 +51,12 @@ public: static SymbolFile *FindPlugin(ObjectFile *obj_file); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ SymbolFile(ObjectFile *obj_file) : m_obj_file(obj_file), m_abilities(0), m_calculated_abilities(false) {} ~SymbolFile() override {} - //------------------------------------------------------------------ /// Get a mask of what this symbol file supports for the object file /// that it was constructed with. /// @@ -85,11 +80,10 @@ public: /// for "void SymbolFile::InitializeObject()" which will get called /// on the SymbolFile object with the best set of abilities. /// - /// @return + /// \return /// A uint32_t mask containing bits from the SymbolFile::Abilities /// enumeration. Any bits that are set represent an ability that /// this symbol plug-in can parse from the object file. - ///------------------------------------------------------------------ uint32_t GetAbilities() { if (!m_calculated_abilities) { m_abilities = CalculateAbilities(); @@ -101,13 +95,10 @@ public: virtual uint32_t CalculateAbilities() = 0; - //------------------------------------------------------------------ /// Symbols file subclasses should override this to return the Module that /// owns the TypeSystem that this symbol file modifies type information in. - //------------------------------------------------------------------ virtual std::recursive_mutex &GetModuleMutex() const; - //------------------------------------------------------------------ /// Initialize the SymbolFile object. /// /// The SymbolFile object with the best set of abilities (detected @@ -115,12 +106,9 @@ public: /// called if it is chosen to parse an object file. More complete /// initialization can happen in this function which will get called /// prior to any other functions in the SymbolFile protocol. - //------------------------------------------------------------------ virtual void InitializeObject() {} - //------------------------------------------------------------------ // Compile Unit function calls - //------------------------------------------------------------------ // Approach 1 - iterator virtual uint32_t GetNumCompileUnits() = 0; virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) = 0; @@ -136,7 +124,7 @@ public: virtual bool ParseImportedModules(const SymbolContext &sc, - std::vector<ConstString> &imported_modules) = 0; + std::vector<SourceModule> &imported_modules) = 0; virtual size_t ParseBlocksRecursive(Function &func) = 0; virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0; virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0; @@ -144,10 +132,10 @@ public: /// The characteristics of an array type. struct ArrayInfo { - int64_t first_index; + int64_t first_index = 0; llvm::SmallVector<uint64_t, 1> element_orders; - uint32_t byte_stride; - uint32_t bit_stride; + uint32_t byte_stride = 0; + uint32_t bit_stride = 0; }; /// If \c type_uid points to an array type, return its characteristics. /// To support variable-length array types, this function takes an @@ -178,13 +166,13 @@ public: virtual void DumpClangAST(Stream &s) {} virtual uint32_t - FindGlobalVariables(const ConstString &name, + FindGlobalVariables(ConstString name, const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables); virtual uint32_t FindGlobalVariables(const RegularExpression ®ex, uint32_t max_matches, VariableList &variables); - virtual uint32_t FindFunctions(const ConstString &name, + virtual uint32_t FindFunctions(ConstString name, const CompilerDeclContext *parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool include_inlines, bool append, @@ -193,7 +181,7 @@ public: bool include_inlines, bool append, SymbolContextList &sc_list); virtual uint32_t - FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); @@ -217,7 +205,7 @@ public: GetTypeSystemForLanguage(lldb::LanguageType language); virtual CompilerDeclContext - FindNamespace(const ConstString &name, + FindNamespace(ConstString name, const CompilerDeclContext *parent_decl_ctx) { return CompilerDeclContext(); } @@ -231,12 +219,22 @@ public: virtual void AddSymbols(Symtab &symtab) {} - //------------------------------------------------------------------ /// Notify the SymbolFile that the file addresses in the Sections /// for this module have been changed. - //------------------------------------------------------------------ virtual void SectionFileAddressesChanged() {} + struct RegisterInfoResolver { + virtual ~RegisterInfoResolver(); // anchor + + virtual const RegisterInfo *ResolveName(llvm::StringRef name) const = 0; + virtual const RegisterInfo *ResolveNumber(lldb::RegisterKind kind, + uint32_t number) const = 0; + }; + virtual lldb::UnwindPlanSP + GetUnwindPlan(const Address &address, const RegisterInfoResolver &resolver) { + return nullptr; + } + virtual void Dump(Stream &s) {} protected: diff --git a/include/lldb/Symbol/SymbolVendor.h b/include/lldb/Symbol/SymbolVendor.h index d48f646d52cd..c4015ff03492 100644 --- a/include/lldb/Symbol/SymbolVendor.h +++ b/include/lldb/Symbol/SymbolVendor.h @@ -1,9 +1,8 @@ //===-- SymbolVendor.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -14,6 +13,7 @@ #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Symbol/SourceModule.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/TypeMap.h" #include "lldb/lldb-private.h" @@ -21,7 +21,6 @@ namespace lldb_private { -//---------------------------------------------------------------------- // The symbol vendor class is designed to abstract the process of searching for // debug information for a given module. Platforms can subclass this class and // provide extra ways to find debug information. Examples would be a subclass @@ -29,15 +28,12 @@ namespace lldb_private { // or runtime data in the object files. A symbol vendor can use multiple // sources (SymbolFile objects) to provide the information and only parse as // deep as needed in order to provide the information that is requested. -//---------------------------------------------------------------------- class SymbolVendor : public ModuleChild, public PluginInterface { public: static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp, Stream *feedback_strm); - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ SymbolVendor(const lldb::ModuleSP &module_sp); ~SymbolVendor() override; @@ -61,8 +57,9 @@ public: virtual size_t ParseTypes(CompileUnit &comp_unit); - virtual bool ParseImportedModules(const SymbolContext &sc, - std::vector<ConstString> &imported_modules); + virtual bool + ParseImportedModules(const SymbolContext &sc, + std::vector<SourceModule> &imported_modules); virtual size_t ParseBlocksRecursive(Function &func); @@ -79,7 +76,7 @@ public: lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); - virtual size_t FindGlobalVariables(const ConstString &name, + virtual size_t FindGlobalVariables(ConstString name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, VariableList &variables); @@ -88,7 +85,7 @@ public: size_t max_matches, VariableList &variables); - virtual size_t FindFunctions(const ConstString &name, + virtual size_t FindFunctions(ConstString name, const CompilerDeclContext *parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool include_inlines, bool append, @@ -99,7 +96,7 @@ public: SymbolContextList &sc_list); virtual size_t - FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); @@ -108,7 +105,7 @@ public: bool append, TypeMap &types); virtual CompilerDeclContext - FindNamespace(const ConstString &name, + FindNamespace(ConstString name, const CompilerDeclContext *parent_decl_ctx); virtual size_t GetNumCompileUnits(); @@ -125,7 +122,7 @@ public: virtual size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list); - SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); } + SymbolFile *GetSymbolFile() { return m_sym_file_up.get(); } FileSpec GetMainFileSpec() const; @@ -135,23 +132,17 @@ public: // Clear module unified section list symbol table. virtual void ClearSymtab(); - //------------------------------------------------------------------ /// Notify the SymbolVendor that the file addresses in the Sections /// for this module have been changed. - //------------------------------------------------------------------ virtual void SectionFileAddressesChanged(); - //------------------------------------------------------------------ // PluginInterface protocol - //------------------------------------------------------------------ ConstString GetPluginName() override; uint32_t GetPluginVersion() override; protected: - //------------------------------------------------------------------ // Classes that inherit from SymbolVendor can see and modify these - //------------------------------------------------------------------ typedef std::vector<lldb::CompUnitSP> CompileUnits; typedef CompileUnits::iterator CompileUnitIter; typedef CompileUnits::const_iterator CompileUnitConstIter; @@ -162,15 +153,13 @@ protected: // case it isn't the same as the module // object file (debug symbols in a separate // file) - std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses + std::unique_ptr<SymbolFile> m_sym_file_up; // A single symbol file. Subclasses // can add more of these if needed. Symtab *m_symtab; // Save a symtab once to not pass it through `AddSymbols` of // the symbol file each time when it is needed private: - //------------------------------------------------------------------ // For SymbolVendor only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(SymbolVendor); }; diff --git a/include/lldb/Symbol/Symtab.h b/include/lldb/Symbol/Symtab.h index 286e4f48c2e8..868edcdc9290 100644 --- a/include/lldb/Symbol/Symtab.h +++ b/include/lldb/Symbol/Symtab.h @@ -1,22 +1,20 @@ //===-- Symtab.h ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_Symtab_h_ #define liblldb_Symtab_h_ -#include <mutex> -#include <vector> - -#include "lldb/Core/RangeMap.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Symbol/Symbol.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" +#include <mutex> +#include <vector> namespace lldb_private { @@ -25,17 +23,13 @@ public: typedef std::vector<uint32_t> IndexCollection; typedef UniqueCStringMap<uint32_t> NameToIndexMap; - typedef enum Debug { + enum Debug { eDebugNo, // Not a debug symbol eDebugYes, // A debug symbol eDebugAny - } Debug; + }; - typedef enum Visibility { - eVisibilityAny, - eVisibilityExtern, - eVisibilityPrivate - } Visibility; + enum Visibility { eVisibilityAny, eVisibilityExtern, eVisibilityPrivate }; Symtab(ObjectFile *objfile); ~Symtab(); @@ -56,13 +50,11 @@ public: Symbol *FindSymbolWithType(lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx); - //---------------------------------------------------------------------- /// Get the parent symbol for the given symbol. /// /// Many symbols in symbol tables are scoped by other symbols that /// contain one or more symbol. This function will look for such a /// containing symbol and return it if there is one. - //---------------------------------------------------------------------- const Symbol *GetParent(Symbol *symbol) const; uint32_t AppendSymbolIndexesWithType(lldb::SymbolType symbol_type, std::vector<uint32_t> &indexes, @@ -78,16 +70,16 @@ public: std::vector<uint32_t> &matches, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const; - uint32_t AppendSymbolIndexesWithName(const ConstString &symbol_name, + uint32_t AppendSymbolIndexesWithName(ConstString symbol_name, std::vector<uint32_t> &matches); - uint32_t AppendSymbolIndexesWithName(const ConstString &symbol_name, + uint32_t AppendSymbolIndexesWithName(ConstString symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t> &matches); - uint32_t AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name, + uint32_t AppendSymbolIndexesWithNameAndType(ConstString symbol_name, lldb::SymbolType symbol_type, std::vector<uint32_t> &matches); - uint32_t AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name, + uint32_t AppendSymbolIndexesWithNameAndType(ConstString symbol_name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, @@ -100,10 +92,10 @@ public: const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t> &indexes); - size_t FindAllSymbolsWithNameAndType(const ConstString &name, + size_t FindAllSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, std::vector<uint32_t> &symbol_indexes); - size_t FindAllSymbolsWithNameAndType(const ConstString &name, + size_t FindAllSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, @@ -112,7 +104,7 @@ public: const RegularExpression ®ex, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t> &symbol_indexes); - Symbol *FindFirstSymbolWithNameAndType(const ConstString &name, + Symbol *FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility); @@ -120,7 +112,7 @@ public: Symbol *FindSymbolContainingFileAddress(lldb::addr_t file_addr); void ForEachSymbolContainingFileAddress( lldb::addr_t file_addr, std::function<bool(Symbol *)> const &callback); - size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask, + size_t FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list); void CalculateSymbolSizes(); @@ -198,7 +190,7 @@ private: SymbolContextList &sc_list); void RegisterMangledNameEntry( - NameToIndexMap::Entry &entry, std::set<const char *> &class_contexts, + uint32_t value, std::set<const char *> &class_contexts, std::vector<std::pair<NameToIndexMap::Entry, const char *>> &backlog, RichManglingContext &rmc); diff --git a/include/lldb/Symbol/TaggedASTType.h b/include/lldb/Symbol/TaggedASTType.h index eabd41ebbf29..043a9138e07b 100644 --- a/include/lldb/Symbol/TaggedASTType.h +++ b/include/lldb/Symbol/TaggedASTType.h @@ -1,9 +1,8 @@ //===-- TaggedASTType.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/Type.h b/include/lldb/Symbol/Type.h index fec2578c9fec..efc9bf049a35 100644 --- a/include/lldb/Symbol/Type.h +++ b/include/lldb/Symbol/Type.h @@ -1,9 +1,8 @@ //===-- Type.h --------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,12 +22,10 @@ #include <set> namespace lldb_private { -//---------------------------------------------------------------------- // CompilerContext allows an array of these items to be passed to perform // detailed lookups in SymbolVendor and SymbolFile functions. -//---------------------------------------------------------------------- struct CompilerContext { - CompilerContext(CompilerContextKind t, const ConstString &n) + CompilerContext(CompilerContextKind t, ConstString n) : type(t), name(n) {} bool operator==(const CompilerContext &rhs) const { @@ -62,25 +59,25 @@ protected: class Type : public std::enable_shared_from_this<Type>, public UserID { public: - typedef enum EncodingDataTypeTag { + enum EncodingDataType { eEncodingInvalid, eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid - ///with the const qualifier added + /// with the const qualifier added eEncodingIsRestrictUID, ///< This type is the type whose UID is - ///m_encoding_uid with the restrict qualifier added + /// m_encoding_uid with the restrict qualifier added eEncodingIsVolatileUID, ///< This type is the type whose UID is - ///m_encoding_uid with the volatile qualifier added + /// m_encoding_uid with the volatile qualifier added eEncodingIsTypedefUID, ///< This type is pointer to a type whose UID is - ///m_encoding_uid + /// m_encoding_uid eEncodingIsPointerUID, ///< This type is pointer to a type whose UID is - ///m_encoding_uid + /// m_encoding_uid eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type - ///whose UID is m_encoding_uid + /// whose UID is m_encoding_uid eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type - ///whose UID is m_encoding_uid + /// whose UID is m_encoding_uid eEncodingIsSyntheticUID - } EncodingDataType; + }; // We must force the underlying type of the enum to be unsigned here. Not // all compilers behave the same with regards to the default underlying type @@ -95,8 +92,8 @@ public: eResolveStateFull = 3 } ResolveState; - Type(lldb::user_id_t uid, SymbolFile *symbol_file, const ConstString &name, - uint64_t byte_size, SymbolContextScope *context, + Type(lldb::user_id_t uid, SymbolFile *symbol_file, ConstString name, + llvm::Optional<uint64_t> byte_size, SymbolContextScope *context, lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, ResolveState compiler_type_resolve_state); @@ -105,10 +102,6 @@ public: // they get an error. Type(); - Type(const Type &rhs); - - const Type &operator=(const Type &rhs); - void Dump(Stream *s, bool show_context); void DumpTypeName(Stream *s); @@ -126,9 +119,9 @@ public: TypeList *GetTypeList(); - const ConstString &GetName(); + ConstString GetName(); - uint64_t GetByteSize(); + llvm::Optional<uint64_t> GetByteSize(); uint32_t GetNumChildren(bool omit_empty_base_classes); @@ -140,7 +133,7 @@ public: lldb::TypeSP GetTypedefType(); - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } ConstString GetQualifiedName(); @@ -218,7 +211,8 @@ protected: Type *m_encoding_type; lldb::user_id_t m_encoding_uid; EncodingDataType m_encoding_uid_type; - uint64_t m_byte_size; + uint64_t m_byte_size : 63; + uint64_t m_byte_size_has_value : 1; Declaration m_decl; CompilerType m_compiler_type; @@ -237,142 +231,15 @@ protected: bool ResolveClangType(ResolveState compiler_type_resolve_state); }; -// these classes are used to back the SBType* objects - -class TypePair { -public: - TypePair() : compiler_type(), type_sp() {} - - TypePair(CompilerType type) : compiler_type(type), type_sp() {} - - TypePair(lldb::TypeSP type) : compiler_type(), type_sp(type) { - compiler_type = type_sp->GetForwardCompilerType(); - } - - bool IsValid() const { - return compiler_type.IsValid() || (type_sp.get() != nullptr); - } - - explicit operator bool() const { return IsValid(); } - - bool operator==(const TypePair &rhs) const { - return compiler_type == rhs.compiler_type && - type_sp.get() == rhs.type_sp.get(); - } - - bool operator!=(const TypePair &rhs) const { - return compiler_type != rhs.compiler_type || - type_sp.get() != rhs.type_sp.get(); - } - - void Clear() { - compiler_type.Clear(); - type_sp.reset(); - } - - ConstString GetName() const { - if (type_sp) - return type_sp->GetName(); - if (compiler_type) - return compiler_type.GetTypeName(); - return ConstString(); - } - - ConstString GetDisplayTypeName() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetDisplayTypeName(); - if (compiler_type) - return compiler_type.GetDisplayTypeName(); - return ConstString(); - } - - void SetType(CompilerType type) { - type_sp.reset(); - compiler_type = type; - } - - void SetType(lldb::TypeSP type) { - type_sp = type; - if (type_sp) - compiler_type = type_sp->GetForwardCompilerType(); - else - compiler_type.Clear(); - } - - lldb::TypeSP GetTypeSP() const { return type_sp; } - - CompilerType GetCompilerType() const { return compiler_type; } - - CompilerType GetPointerType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetPointerType(); - return compiler_type.GetPointerType(); - } - - CompilerType GetPointeeType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetPointeeType(); - return compiler_type.GetPointeeType(); - } - - CompilerType GetReferenceType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetLValueReferenceType(); - else - return compiler_type.GetLValueReferenceType(); - } - - CompilerType GetTypedefedType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetTypedefedType(); - else - return compiler_type.GetTypedefedType(); - } - - CompilerType GetDereferencedType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetNonReferenceType(); - else - return compiler_type.GetNonReferenceType(); - } - - CompilerType GetUnqualifiedType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetFullyUnqualifiedType(); - else - return compiler_type.GetFullyUnqualifiedType(); - } - - CompilerType GetCanonicalType() const { - if (type_sp) - return type_sp->GetForwardCompilerType().GetCanonicalType(); - return compiler_type.GetCanonicalType(); - } - - TypeSystem *GetTypeSystem() const { return compiler_type.GetTypeSystem(); } - - lldb::ModuleSP GetModule() const { - if (type_sp) - return type_sp->GetModule(); - return lldb::ModuleSP(); - } - -protected: - CompilerType compiler_type; - lldb::TypeSP type_sp; -}; - // the two classes here are used by the public API as a backend to the SBType // and SBTypeList classes class TypeImpl { public: - TypeImpl(); + TypeImpl() = default; ~TypeImpl() {} - TypeImpl(const TypeImpl &rhs); - TypeImpl(const lldb::TypeSP &type_sp); TypeImpl(const CompilerType &compiler_type); @@ -381,8 +248,6 @@ public: TypeImpl(const CompilerType &compiler_type, const CompilerType &dynamic); - TypeImpl(const TypePair &pair, const CompilerType &dynamic); - void SetType(const lldb::TypeSP &type_sp); void SetType(const CompilerType &compiler_type); @@ -391,10 +256,6 @@ public: void SetType(const CompilerType &compiler_type, const CompilerType &dynamic); - void SetType(const TypePair &pair, const CompilerType &dynamic); - - TypeImpl &operator=(const TypeImpl &rhs); - bool operator==(const TypeImpl &rhs) const; bool operator!=(const TypeImpl &rhs) const; @@ -434,7 +295,7 @@ private: bool CheckModule(lldb::ModuleSP &module_sp) const; lldb::ModuleWP m_module_wp; - TypePair m_static_type; + CompilerType m_static_type; CompilerType m_dynamic_type; }; @@ -478,7 +339,7 @@ public: {} TypeMemberImpl(const lldb::TypeImplSP &type_impl_sp, uint64_t bit_offset, - const ConstString &name, uint32_t bitfield_bit_size = 0, + ConstString name, uint32_t bitfield_bit_size = 0, bool is_bitfield = false) : m_type_impl_sp(type_impl_sp), m_bit_offset(bit_offset), m_name(name), m_bitfield_bit_size(bitfield_bit_size), m_is_bitfield(is_bitfield) {} @@ -492,7 +353,7 @@ public: const lldb::TypeImplSP &GetTypeImpl() { return m_type_impl_sp; } - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } uint64_t GetBitOffset() const { return m_bit_offset; } @@ -526,26 +387,21 @@ protected: class TypeAndOrName { public: - TypeAndOrName(); + TypeAndOrName() = default; TypeAndOrName(lldb::TypeSP &type_sp); TypeAndOrName(const CompilerType &compiler_type); TypeAndOrName(const char *type_str); - TypeAndOrName(const TypeAndOrName &rhs); TypeAndOrName(ConstString &type_const_string); - TypeAndOrName &operator=(const TypeAndOrName &rhs); - bool operator==(const TypeAndOrName &other) const; bool operator!=(const TypeAndOrName &other) const; ConstString GetName() const; - lldb::TypeSP GetTypeSP() const { return m_type_pair.GetTypeSP(); } + CompilerType GetCompilerType() const { return m_compiler_type; } - CompilerType GetCompilerType() const { return m_type_pair.GetCompilerType(); } - - void SetName(const ConstString &type_name); + void SetName(ConstString type_name); void SetName(const char *type_name_cstr); @@ -557,18 +413,16 @@ public: bool HasName() const; - bool HasTypeSP() const; - bool HasCompilerType() const; - bool HasType() const { return HasTypeSP() || HasCompilerType(); } + bool HasType() const { return HasCompilerType(); } void Clear(); explicit operator bool() { return !IsEmpty(); } private: - TypePair m_type_pair; + CompilerType m_compiler_type; ConstString m_type_name; }; @@ -617,17 +471,15 @@ public: : m_integer_type_sp(), m_name("<invalid>"), m_value(), m_valid(false) {} TypeEnumMemberImpl(const lldb::TypeImplSP &integer_type_sp, - const ConstString &name, const llvm::APSInt &value); + ConstString name, const llvm::APSInt &value); - TypeEnumMemberImpl(const TypeEnumMemberImpl &rhs) - : m_integer_type_sp(rhs.m_integer_type_sp), m_name(rhs.m_name), - m_value(rhs.m_value), m_valid(rhs.m_valid) {} + TypeEnumMemberImpl(const TypeEnumMemberImpl &rhs) = default; TypeEnumMemberImpl &operator=(const TypeEnumMemberImpl &rhs); bool IsValid() { return m_valid; } - const ConstString &GetName() const { return m_name; } + ConstString GetName() const { return m_name; } const lldb::TypeImplSP &GetIntegerType() const { return m_integer_type_sp; } diff --git a/include/lldb/Symbol/TypeList.h b/include/lldb/Symbol/TypeList.h index b6a4e41ff301..982f673fff6e 100644 --- a/include/lldb/Symbol/TypeList.h +++ b/include/lldb/Symbol/TypeList.h @@ -1,9 +1,8 @@ //===-- TypeList.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,9 +19,7 @@ namespace lldb_private { class TypeList { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ TypeList(); virtual ~TypeList(); @@ -34,7 +31,7 @@ public: // lldb::TypeSP // FindType(lldb::user_id_t uid); - TypeList FindTypes(const ConstString &name); + TypeList FindTypes(ConstString name); void Insert(const lldb::TypeSP &type); diff --git a/include/lldb/Symbol/TypeMap.h b/include/lldb/Symbol/TypeMap.h index 6bf9831c1389..e7d2b254cbf3 100644 --- a/include/lldb/Symbol/TypeMap.h +++ b/include/lldb/Symbol/TypeMap.h @@ -1,9 +1,8 @@ //===-- TypeMap.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -20,9 +19,7 @@ namespace lldb_private { class TypeMap { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ TypeMap(); virtual ~TypeMap(); @@ -31,7 +28,7 @@ public: void Dump(Stream *s, bool show_context); - TypeMap FindTypes(const ConstString &name); + TypeMap FindTypes(ConstString name); void Insert(const lldb::TypeSP &type); diff --git a/include/lldb/Symbol/TypeSystem.h b/include/lldb/Symbol/TypeSystem.h index 6afbd188a234..4bef2a4446eb 100644 --- a/include/lldb/Symbol/TypeSystem.h +++ b/include/lldb/Symbol/TypeSystem.h @@ -1,9 +1,8 @@ //===-- TypeSystem.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -26,15 +25,13 @@ class DWARFDIE; class DWARFASTParser; +class PDBASTParser; namespace lldb_private { -//---------------------------------------------------------------------- // Interface for representing the Type Systems in different languages. -//---------------------------------------------------------------------- class TypeSystem : public PluginInterface { public: - //---------------------------------------------------------------------- // Intrusive type system that allows us to use llvm casting. // // To add a new type system: @@ -64,7 +61,6 @@ public: // // Then you can use the llvm casting on any "TypeSystem *" to get an instance // of your subclass. - //---------------------------------------------------------------------- enum LLVMCastKind { eKindClang, eKindSwift, @@ -72,9 +68,7 @@ public: kNumKinds }; - //---------------------------------------------------------------------- // Constructors and Destructors - //---------------------------------------------------------------------- TypeSystem(LLVMCastKind kind); ~TypeSystem() override; @@ -92,15 +86,14 @@ public: virtual void Finalize() {} virtual DWARFASTParser *GetDWARFParser() { return nullptr; } + virtual PDBASTParser *GetPDBParser() { return nullptr; } virtual SymbolFile *GetSymbolFile() const { return m_sym_file; } // Returns true if the symbol file changed during the set accessor. virtual void SetSymbolFile(SymbolFile *sym_file) { m_sym_file = sym_file; } - //---------------------------------------------------------------------- // CompilerDecl functions - //---------------------------------------------------------------------- virtual ConstString DeclGetName(void *opaque_decl) = 0; virtual ConstString DeclGetMangledName(void *opaque_decl); @@ -114,9 +107,7 @@ public: virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl, size_t arg_idx); - //---------------------------------------------------------------------- // CompilerDeclContext functions - //---------------------------------------------------------------------- virtual std::vector<CompilerDecl> DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, @@ -133,9 +124,10 @@ public: void *opaque_decl_ctx, lldb::LanguageType *language_ptr, bool *is_instance_method_ptr, ConstString *language_object_name_ptr) = 0; - //---------------------------------------------------------------------- + virtual bool DeclContextIsContainedInLookup(void *opaque_decl_ctx, + void *other_opaque_decl_ctx) = 0; + // Tests - //---------------------------------------------------------------------- virtual bool IsArrayType(lldb::opaque_compiler_type_t type, CompilerType *element_type, uint64_t *size, @@ -189,24 +181,20 @@ public: virtual bool IsVoidType(lldb::opaque_compiler_type_t type) = 0; + virtual bool CanPassInRegisters(const CompilerType &type) = 0; + // TypeSystems can support more than one language virtual bool SupportsLanguage(lldb::LanguageType language) = 0; - //---------------------------------------------------------------------- // Type Completion - //---------------------------------------------------------------------- virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0; - //---------------------------------------------------------------------- // AST related queries - //---------------------------------------------------------------------- virtual uint32_t GetPointerByteSize() = 0; - //---------------------------------------------------------------------- // Accessors - //---------------------------------------------------------------------- virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0; @@ -219,9 +207,7 @@ public: virtual lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) = 0; - //---------------------------------------------------------------------- // Creating related types - //---------------------------------------------------------------------- virtual CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, uint64_t *stride) = 0; @@ -267,12 +253,11 @@ public: const char *name, const CompilerDeclContext &decl_ctx); - //---------------------------------------------------------------------- // Exploring the type - //---------------------------------------------------------------------- - virtual uint64_t GetBitSize(lldb::opaque_compiler_type_t type, - ExecutionContextScope *exe_scope) = 0; + virtual llvm::Optional<uint64_t> + GetBitSize(lldb::opaque_compiler_type_t type, + ExecutionContextScope *exe_scope) = 0; virtual lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, uint64_t &count) = 0; @@ -283,7 +268,7 @@ public: bool omit_empty_base_classes, const ExecutionContext *exe_ctx) = 0; - virtual CompilerType GetBuiltinTypeByName(const ConstString &name); + virtual CompilerType GetBuiltinTypeByName(ConstString name); virtual lldb::BasicType GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) = 0; @@ -291,7 +276,7 @@ public: virtual void ForEachEnumerator( lldb::opaque_compiler_type_t type, std::function<bool(const CompilerType &integer_type, - const ConstString &name, + ConstString name, const llvm::APSInt &value)> const &callback) {} virtual uint32_t GetNumFields(lldb::opaque_compiler_type_t type) = 0; @@ -351,10 +336,14 @@ public: virtual llvm::Optional<CompilerType::IntegralTemplateArgument> GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx); - //---------------------------------------------------------------------- // Dumping types - //---------------------------------------------------------------------- +#ifndef NDEBUG + /// Convenience LLVM-style dump method for use in the debugger only. + LLVM_DUMP_METHOD virtual void + dump(lldb::opaque_compiler_type_t type) const = 0; +#endif + virtual void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, @@ -376,9 +365,7 @@ public: virtual void DumpTypeDescription(lldb::opaque_compiler_type_t type, Stream *s) = 0; - //---------------------------------------------------------------------- // TODO: These methods appear unused. Should they be removed? - //---------------------------------------------------------------------- virtual bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) = 0; @@ -394,9 +381,7 @@ public: const char *s, uint8_t *dst, size_t dst_size) = 0; - //---------------------------------------------------------------------- // TODO: Determine if these methods should move to ClangASTContext. - //---------------------------------------------------------------------- virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, CompilerType *pointee_type) = 0; @@ -449,7 +434,8 @@ public: GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, Expression::ResultType desired_type, - const EvaluateExpressionOptions &options) { + const EvaluateExpressionOptions &options, + ValueObject *ctx_obj) { return nullptr; } diff --git a/include/lldb/Symbol/UnwindPlan.h b/include/lldb/Symbol/UnwindPlan.h index 7a5cf7f02a67..2b49acaafa04 100644 --- a/include/lldb/Symbol/UnwindPlan.h +++ b/include/lldb/Symbol/UnwindPlan.h @@ -1,9 +1,8 @@ //===-- UnwindPlan.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// diff --git a/include/lldb/Symbol/UnwindTable.h b/include/lldb/Symbol/UnwindTable.h index 061e7ddc0f99..b4d7f0661d5b 100644 --- a/include/lldb/Symbol/UnwindTable.h +++ b/include/lldb/Symbol/UnwindTable.h @@ -1,9 +1,8 @@ -//===-- Symtab.h ------------------------------------------------*- C++ -*-===// +//===-- UnwindTable.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -23,7 +22,9 @@ namespace lldb_private { class UnwindTable { public: - UnwindTable(ObjectFile &objfile); + /// Create an Unwind table using the data in the given module. + explicit UnwindTable(Module &module); + ~UnwindTable(); lldb_private::DWARFCallFrameInfo *GetEHFrameInfo(); @@ -32,6 +33,7 @@ public: lldb_private::CompactUnwindInfo *GetCompactUnwindInfo(); ArmUnwindInfo *GetArmUnwindInfo(); + SymbolFile *GetSymbolFile(); lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc); @@ -63,7 +65,7 @@ private: typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; - ObjectFile &m_object_file; + Module &m_module; collection m_unwinds; bool m_initialized; // delay some initialization until ObjectFile is set up diff --git a/include/lldb/Symbol/Variable.h b/include/lldb/Symbol/Variable.h index 531312e63591..12daecfc04e6 100644 --- a/include/lldb/Symbol/Variable.h +++ b/include/lldb/Symbol/Variable.h @@ -1,26 +1,24 @@ //===-- Variable.h -----------------------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef liblldb_Variable_h_ #define liblldb_Variable_h_ -#include <memory> -#include <vector> - #include "lldb/Core/Mangled.h" -#include "lldb/Core/RangeMap.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/Declaration.h" #include "lldb/Utility/CompletionRequest.h" +#include "lldb/Utility/RangeMap.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private.h" +#include <memory> +#include <vector> namespace lldb_private { @@ -28,9 +26,7 @@ class Variable : public UserID, public std::enable_shared_from_this<Variable> { public: typedef RangeVector<lldb::addr_t, lldb::addr_t> RangeList; - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ Variable(lldb::user_id_t uid, const char *name, const char *mangled, // The mangled or fully qualified name of the variable. @@ -59,7 +55,7 @@ public: // namespace)::i", this function will allow a generic match function that can // be called by commands and expression parsers to make sure we match // anything we come across. - bool NameMatches(const ConstString &name) const; + bool NameMatches(ConstString name) const; bool NameMatches(const RegularExpression ®ex) const; @@ -132,8 +128,8 @@ protected: m_static_member : 1; // Non-zero if variable is static member of a class // or struct. private: - Variable(const Variable &rhs); - Variable &operator=(const Variable &rhs); + Variable(const Variable &rhs) = delete; + Variable &operator=(const Variable &rhs) = delete; }; } // namespace lldb_private diff --git a/include/lldb/Symbol/VariableList.h b/include/lldb/Symbol/VariableList.h index 6729a9c108a9..54d27583cd7b 100644 --- a/include/lldb/Symbol/VariableList.h +++ b/include/lldb/Symbol/VariableList.h @@ -1,9 +1,8 @@ //===-- VariableList.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -18,9 +17,7 @@ namespace lldb_private { class VariableList { public: - //------------------------------------------------------------------ // Constructors and Destructors - //------------------------------------------------------------------ // VariableList(const SymbolContext &symbol_context); VariableList(); virtual ~VariableList(); @@ -39,10 +36,10 @@ public: lldb::VariableSP RemoveVariableAtIndex(size_t idx); - lldb::VariableSP FindVariable(const ConstString &name, + lldb::VariableSP FindVariable(ConstString name, bool include_static_members = true); - lldb::VariableSP FindVariable(const ConstString &name, + lldb::VariableSP FindVariable(ConstString name, lldb::ValueType value_type, bool include_static_members = true); @@ -76,9 +73,7 @@ protected: collection m_variables; private: - //------------------------------------------------------------------ // For VariableList only - //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN(VariableList); }; diff --git a/include/lldb/Symbol/VerifyDecl.h b/include/lldb/Symbol/VerifyDecl.h index f4b61e6355ce..f412b94a7859 100644 --- a/include/lldb/Symbol/VerifyDecl.h +++ b/include/lldb/Symbol/VerifyDecl.h @@ -1,9 +1,8 @@ //===-- VerifyDecl.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// |