From fe356d356ad411306d360da58c9b5fef1175fc95 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 21 Jun 2011 01:34:41 +0000 Subject: [PATCH] Added the ability to find functions from either a SBModule (find functions only in a specific module), or in a SBTarget (all modules for a target). llvm-svn: 133498 --- lldb/include/lldb/API/SBDefines.h | 1 + lldb/include/lldb/API/SBModule.h | 6 +++++ lldb/include/lldb/API/SBSymbolContextList.h | 6 +++++ lldb/include/lldb/API/SBTarget.h | 6 +++++ lldb/include/lldb/lldb-enumerations.h | 17 ++++++++++++++ lldb/include/lldb/lldb-private-enumerations.h | 16 ------------- lldb/source/API/SBModule.cpp | 23 ++++++++++++++++++- lldb/source/API/SBSymbolContextList.cpp | 16 ++++++++----- lldb/source/API/SBTarget.cpp | 23 +++++++++++++++++++ 9 files changed, 91 insertions(+), 23 deletions(-) diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index fb59cc645424..9afd13361a6e 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -53,6 +53,7 @@ class SBStream; class SBStringList; class SBSymbol; class SBSymbolContext; +class SBSymbolContextList; class SBTarget; class SBThread; class SBValue; diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index 4b6f82259d7c..e0252f4d4942 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -74,6 +74,12 @@ public: lldb::SBSymbol GetSymbolAtIndex (size_t idx); + uint32_t + FindFunctions (const char *name, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + bool append, + lldb::SBSymbolContextList& sc_list); + private: friend class SBAddress; friend class SBFrame; diff --git a/lldb/include/lldb/API/SBSymbolContextList.h b/lldb/include/lldb/API/SBSymbolContextList.h index bd26b2b4bbf2..b07f32ebf562 100644 --- a/lldb/include/lldb/API/SBSymbolContextList.h +++ b/lldb/include/lldb/API/SBSymbolContextList.h @@ -38,8 +38,14 @@ public: SBSymbolContext GetContextAtIndex (uint32_t idx); + void + Clear(); + protected: + friend class SBModule; + friend class SBTarget; + #ifndef SWIG lldb_private::SymbolContextList* diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 9937635444cf..94a720f3e8bb 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -183,6 +183,12 @@ public: lldb::SBModule FindModule (const lldb::SBFileSpec &file_spec); + uint32_t + FindFunctions (const char *name, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + bool append, + lldb::SBSymbolContextList& sc_list); + void Clear (); diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index b22046ad3275..aeae2ec3c20d 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -472,6 +472,23 @@ namespace lldb { eEmulateInstructionOptionIgnoreConditions = (1u << 1) } EmulateInstructionOptions; + typedef enum FunctionNameType + { + eFunctionNameTypeNone = 0u, + eFunctionNameTypeAuto = (1u << 1), // Automatically figure out which FunctionNameType + // bits to set based on the function name. + eFunctionNameTypeFull = (1u << 2), // The function name. + // For C this is the same as just the name of the function + // For C++ this is the mangled or demangled version of the mangled name. + // For ObjC this is the full function signature with the + or + // - and the square brackets and the class and selector + eFunctionNameTypeBase = (1u << 3), // The function name only, no namespaces or arguments and no class + // methods or selectors will be searched. + eFunctionNameTypeMethod = (1u << 4), // Find function by method name (C++) with no namespace or arguments + eFunctionNameTypeSelector = (1u << 5) // Find function by selector name (ObjC) names + } FunctionNameType; + + } // namespace lldb diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h index fddc02daefd7..c37890491106 100644 --- a/lldb/include/lldb/lldb-private-enumerations.h +++ b/lldb/include/lldb/lldb-private-enumerations.h @@ -75,22 +75,6 @@ typedef enum ArchitectureType kNumArchTypes } ArchitectureType; -typedef enum FunctionNameType -{ - eFunctionNameTypeNone = 0u, - eFunctionNameTypeAuto = (1u << 1), // Automatically figure out which FunctionNameType - // bits to set based on the function name. - eFunctionNameTypeFull = (1u << 2), // The function name. - // For C this is the same as just the name of the function - // For C++ this is the demangled version of the mangled name. - // For ObjC this is the full function signature with the + or - // - and the square brackets and the class and selector - eFunctionNameTypeBase = (1u << 3), // The function name only, no namespaces or arguments and no class - // methods or selectors will be searched. - eFunctionNameTypeMethod = (1u << 4), // Find function by method name (C++) with no namespace or arguments - eFunctionNameTypeSelector = (1u << 5) // Find function by selector name (ObjC) names -} FunctionNameType; - //---------------------------------------------------------------------- /// Settable state variable types. /// diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 427850ec46c2..f497fd1f012f 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -10,8 +10,8 @@ #include "lldb/API/SBModule.h" #include "lldb/API/SBAddress.h" #include "lldb/API/SBFileSpec.h" -#include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBSymbolContextList.h" #include "lldb/Core/Module.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" @@ -285,3 +285,24 @@ SBModule::GetSymbolAtIndex (size_t idx) } return sb_symbol; } + +uint32_t +SBModule::FindFunctions (const char *name, + uint32_t name_type_mask, + bool append, + lldb::SBSymbolContextList& sc_list) +{ + if (!append) + sc_list.Clear(); + if (m_opaque_sp) + { + const bool symbols_ok = true; + return m_opaque_sp->FindFunctions (ConstString(name), + name_type_mask, + symbols_ok, + append, + *sc_list); + } + return 0; +} + diff --git a/lldb/source/API/SBSymbolContextList.cpp b/lldb/source/API/SBSymbolContextList.cpp index a7871790f552..ca6c80ca9994 100644 --- a/lldb/source/API/SBSymbolContextList.cpp +++ b/lldb/source/API/SBSymbolContextList.cpp @@ -14,15 +14,13 @@ using namespace lldb; using namespace lldb_private; SBSymbolContextList::SBSymbolContextList () : - m_opaque_ap () + m_opaque_ap (new SymbolContextList()) { } SBSymbolContextList::SBSymbolContextList (const SBSymbolContextList& rhs) : - m_opaque_ap () + m_opaque_ap (new SymbolContextList(*rhs.m_opaque_ap)) { - if (rhs.IsValid()) - *m_opaque_ap = *rhs.m_opaque_ap; } SBSymbolContextList::~SBSymbolContextList () @@ -34,8 +32,7 @@ SBSymbolContextList::operator = (const SBSymbolContextList &rhs) { if (this != &rhs) { - if (rhs.IsValid()) - m_opaque_ap.reset (new lldb_private::SymbolContextList(*rhs.m_opaque_ap.get())); + *m_opaque_ap = *rhs.m_opaque_ap; } return *this; } @@ -63,6 +60,13 @@ SBSymbolContextList::GetContextAtIndex (uint32_t idx) return sb_sc; } +void +SBSymbolContextList::Clear() +{ + if (m_opaque_ap.get()) + m_opaque_ap->Clear(); +} + bool SBSymbolContextList::IsValid () const diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 03333d940eb4..8ed525e3d4df 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -14,6 +14,7 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBModule.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBSymbolContextList.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/BreakpointList.h" @@ -784,3 +785,25 @@ SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel descript return true; } + + +uint32_t +SBTarget::FindFunctions (const char *name, + uint32_t name_type_mask, + bool append, + lldb::SBSymbolContextList& sc_list) +{ + if (!append) + sc_list.Clear(); + if (m_opaque_sp) + { + const bool symbols_ok = true; + return m_opaque_sp->GetImages().FindFunctions (ConstString(name), + name_type_mask, + symbols_ok, + append, + *sc_list); + } + return 0; +} +