diff options
Diffstat (limited to 'include/lldb/Core/Module.h')
-rw-r--r-- | include/lldb/Core/Module.h | 150 |
1 files changed, 92 insertions, 58 deletions
diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h index 35b182aa9801..46fa330fb19c 100644 --- a/include/lldb/Core/Module.h +++ b/include/lldb/Core/Module.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <atomic> +#include <mutex> #include <string> #include <vector> @@ -22,11 +23,11 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/UUID.h" #include "lldb/Host/FileSpec.h" -#include "lldb/Host/Mutex.h" #include "lldb/Host/TimeValue.h" #include "lldb/Symbol/SymbolContextScope.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/PathMappingList.h" +#include "llvm/ADT/DenseSet.h" namespace lldb_private { @@ -67,7 +68,7 @@ public: static Module * GetAllocatedModuleAtIndex (size_t idx); - static Mutex * + static std::recursive_mutex & GetAllocationModuleCollectionMutex(); //------------------------------------------------------------------ @@ -498,6 +499,7 @@ public: const ConstString &type_name, bool exact_match, size_t max_matches, + llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeList& types); lldb::TypeSP @@ -984,8 +986,8 @@ public: // SymbolVendor, SymbolFile and ObjectFile member objects should // lock the module mutex to avoid deadlocks. //------------------------------------------------------------------ - Mutex & - GetMutex () const + std::recursive_mutex & + GetMutex() const { return m_mutex; } @@ -1046,65 +1048,96 @@ public: bool RemapSourceFile (const char *path, std::string &new_path) const; - //------------------------------------------------------------------ - /// Prepare to do a function name lookup. - /// - /// Looking up functions by name can be a tricky thing. LLDB requires - /// that accelerator tables contain full names for functions as well - /// as function basenames which include functions, class methods and - /// class functions. When the user requests that an action use a - /// function by name, we are sometimes asked to automatically figure - /// out what a name could possibly map to. A user might request a - /// breakpoint be set on "count". If no options are supplied to limit - /// the scope of where to search for count, we will by default match - /// any function names named "count", all class and instance methods - /// named "count" (no matter what the namespace or contained context) - /// and any selectors named "count". If a user specifies "a::b" we - /// will search for the basename "b", and then prune the results that - /// don't match "a::b" (note that "c::a::b" and "d::e::a::b" will - /// match a query of "a::b". - /// - /// @param[in] name - /// The user supplied name to use in the lookup - /// - /// @param[in] name_type_mask - /// The mask of bits from lldb::FunctionNameType enumerations - /// that tell us what kind of name we are looking for. - /// - /// @param[out] language - /// If known, the language to use for determining the - /// lookup_name_type_mask. - /// - /// @param[out] lookup_name - /// The actual name that will be used when calling - /// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols() - /// - /// @param[out] lookup_name_type_mask - /// The actual name mask that should be used in the calls to - /// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols() - /// - /// @param[out] match_name_after_lookup - /// A boolean that indicates if we need to iterate through any - /// match results obtained from SymbolVendor::FindFunctions() or - /// Symtab::FindFunctionSymbols() to see if the name contains - /// \a name. For example if \a name is "a::b", this function will - /// return a \a lookup_name of "b", with \a match_name_after_lookup - /// set to true to indicate any matches will need to be checked - /// to make sure they contain \a name. - //------------------------------------------------------------------ - static void - PrepareForFunctionNameLookup (const ConstString &name, - uint32_t name_type_mask, - lldb::LanguageType language, - ConstString &lookup_name, - uint32_t &lookup_name_type_mask, - bool &match_name_after_lookup); + //---------------------------------------------------------------------- + /// @class LookupInfo Module.h "lldb/Core/Module.h" + /// @brief A class that encapsulates name lookup information. + /// + /// Users can type a wide variety of partial names when setting + /// breakpoints by name or when looking for functions by name. + /// SymbolVendor and SymbolFile objects are only required to implement + /// name lookup for function basenames and for fully mangled names. + /// This means if the user types in a partial name, we must reduce this + /// to a name lookup that will work with all SymbolFile objects. So we + /// might reduce a name lookup to look for a basename, and then prune + /// out any results that don't match. + /// + /// The "m_name" member variable represents the name as it was typed + /// by the user. "m_lookup_name" will be the name we actually search + /// for through the symbol or objects files. Lanaguage is included in + /// case we need to filter results by language at a later date. The + /// "m_name_type_mask" member variable tells us what kinds of names we + /// are looking for and can help us prune out unwanted results. + /// + /// Function lookups are done in Module.cpp, ModuleList.cpp and in + /// BreakpointResolverName.cpp and they all now use this class to do + /// lookups correctly. + //---------------------------------------------------------------------- + class LookupInfo + { + public: + LookupInfo() : + m_name(), + m_lookup_name(), + m_language(lldb::eLanguageTypeUnknown), + m_name_type_mask(0), + m_match_name_after_lookup(false) + { + } + + LookupInfo(const ConstString &name, uint32_t name_type_mask, lldb::LanguageType language); + + const ConstString & + GetName() const + { + return m_name; + } + + void + SetName(const ConstString &name) + { + m_name = name; + } + + const ConstString & + GetLookupName() const + { + return m_lookup_name; + } + + void + SetLookupName(const ConstString &name) + { + m_lookup_name = name; + } + + uint32_t + GetNameTypeMask() const + { + return m_name_type_mask; + } + + void + SetNameTypeMask(uint32_t mask) + { + m_name_type_mask = mask; + } + + void + Prune(SymbolContextList &sc_list, size_t start_idx) const; + + protected: + ConstString m_name; ///< What the user originally typed + ConstString m_lookup_name; ///< The actual name will lookup when calling in the object or symbol file + lldb::LanguageType m_language; ///< Limit matches to only be for this language + uint32_t m_name_type_mask; ///< One or more bits from lldb::FunctionNameType that indicate what kind of names we are looking for + bool m_match_name_after_lookup; ///< If \b true, then demangled names that match will need to contain "m_name" in order to be considered a match + }; protected: //------------------------------------------------------------------ // Member Variables //------------------------------------------------------------------ - mutable Mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments. + mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments. TimeValue m_mod_time; ///< The modification time for this module when it was created. ArchSpec m_arch; ///< The architecture for this module. UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols. @@ -1194,6 +1227,7 @@ private: const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, + llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap& types); DISALLOW_COPY_AND_ASSIGN (Module); |