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
This commit is contained in:
Greg Clayton 2011-06-21 01:34:41 +00:00
parent 27029885f0
commit fe356d356a
9 changed files with 91 additions and 23 deletions

View File

@ -53,6 +53,7 @@ class SBStream;
class SBStringList;
class SBSymbol;
class SBSymbolContext;
class SBSymbolContextList;
class SBTarget;
class SBThread;
class SBValue;

View File

@ -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;

View File

@ -38,8 +38,14 @@ public:
SBSymbolContext
GetContextAtIndex (uint32_t idx);
void
Clear();
protected:
friend class SBModule;
friend class SBTarget;
#ifndef SWIG
lldb_private::SymbolContextList*

View File

@ -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 ();

View File

@ -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

View File

@ -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.
///

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}