summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/API/SBTarget.h40
-rw-r--r--lldb/include/lldb/Core/ModuleList.h10
-rw-r--r--lldb/include/lldb/lldb-enumerations.h10
-rw-r--r--lldb/scripts/Python/interface/SBTarget.i9
-rw-r--r--lldb/source/API/SBTarget.cpp84
-rw-r--r--lldb/source/Core/ModuleList.cpp20
6 files changed, 173 insertions, 0 deletions
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 370d40d0454..6b9a3c584f0 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -683,7 +683,47 @@ public:
//------------------------------------------------------------------
lldb::SBValue
FindFirstGlobalVariable (const char* name);
+
+ //------------------------------------------------------------------
+ /// Find global and static variables by pattern.
+ ///
+ /// @param[in] name
+ /// The pattern to search for global or static variables
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a max_matches.
+ ///
+ /// @param[in] matchtype
+ /// The match type to use.
+ ///
+ /// @return
+ /// A list of matched variables in an SBValueList.
+ //------------------------------------------------------------------
+ lldb::SBValueList
+ FindGlobalVariables(const char *name,
+ uint32_t max_matches,
+ MatchType matchtype);
+ //------------------------------------------------------------------
+ /// Find global functions by their name with pattern matching.
+ ///
+ /// @param[in] name
+ /// The pattern to search for global or static variables
+ ///
+ /// @param[in] max_matches
+ /// Allow the number of matches to be limited to \a max_matches.
+ ///
+ /// @param[in] matchtype
+ /// The match type to use.
+ ///
+ /// @return
+ /// A list of matched variables in an SBValueList.
+ //------------------------------------------------------------------
+ lldb::SBSymbolContextList
+ FindGlobalFunctions(const char *name,
+ uint32_t max_matches,
+ MatchType matchtype);
+
void
Clear ();
diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h
index fcc1b99c31c..a46e212da9b 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -279,6 +279,16 @@ public:
SymbolContextList& sc_list);
//------------------------------------------------------------------
+ /// @see Module::FindFunctions ()
+ //------------------------------------------------------------------
+ size_t
+ FindFunctions(const RegularExpression &name,
+ bool include_symbols,
+ bool include_inlines,
+ bool append,
+ SymbolContextList& sc_list);
+
+ //------------------------------------------------------------------
/// Find global and static variables by name.
///
/// @param[in] name
diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h
index 45e81b741cb..5164326c895 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -864,6 +864,16 @@ namespace lldb {
eMemberFunctionKindStaticMethod // A function that applies to a type rather than any instance
} MemberFunctionKind;
+
+ //----------------------------------------------------------------------
+ // String matching algorithm used by SBTarget
+ //----------------------------------------------------------------------
+ typedef enum MatchType {
+ eMatchTypeNormal,
+ eMatchTypeRegex,
+ eMatchTypeStartsWith
+ } MatchType;
+
} // namespace lldb
diff --git a/lldb/scripts/Python/interface/SBTarget.i b/lldb/scripts/Python/interface/SBTarget.i
index bbf1f74faa5..4de442e0b8b 100644
--- a/lldb/scripts/Python/interface/SBTarget.i
+++ b/lldb/scripts/Python/interface/SBTarget.i
@@ -113,6 +113,15 @@ public:
void
SetDetachOnError(bool enable);
+ lldb::SBValueList
+ FindGlobalVariables(const char *name,
+ uint32_t max_matches,
+ MatchType matchtype);
+
+ lldb::SBSymbolContextList
+ FindGlobalFunctions(const char *name,
+ uint32_t max_matches,
+ MatchType matchtype);
};
class SBAttachInfo
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 3d5828c5fe0..e26692d9d8c 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -58,6 +58,7 @@
#include "lldb/Interpreter/CommandReturnObject.h"
#include "../source/Commands/CommandObjectBreakpoint.h"
+#include "llvm/Support/Regex.h"
using namespace lldb;
@@ -2154,6 +2155,34 @@ SBTarget::FindFunctions (const char *name, uint32_t name_type_mask)
return sb_sc_list;
}
+lldb::SBSymbolContextList
+SBTarget::FindGlobalFunctions(const char *name, uint32_t max_matches, MatchType matchtype)
+{
+ lldb::SBSymbolContextList sb_sc_list;
+ if (name && name[0])
+ {
+ TargetSP target_sp(GetSP());
+ if (target_sp)
+ {
+ std::string regexstr;
+ switch (matchtype)
+ {
+ case eMatchTypeRegex:
+ target_sp->GetImages().FindFunctions(RegularExpression(name), true, true, true, *sb_sc_list);
+ break;
+ case eMatchTypeStartsWith:
+ regexstr = llvm::Regex::escape(name) + ".*";
+ target_sp->GetImages().FindFunctions(RegularExpression(regexstr.c_str()), true, true, true, *sb_sc_list);
+ break;
+ default:
+ target_sp->GetImages().FindFunctions(ConstString(name), eFunctionNameTypeAny, true, true, true, *sb_sc_list);
+ break;
+ }
+ }
+ }
+ return sb_sc_list;
+}
+
lldb::SBType
SBTarget::FindFirstType (const char* typename_cstr)
{
@@ -2321,6 +2350,61 @@ SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches)
return sb_value_list;
}
+SBValueList
+SBTarget::FindGlobalVariables(const char *name, uint32_t max_matches, MatchType matchtype)
+{
+ SBValueList sb_value_list;
+
+ TargetSP target_sp(GetSP());
+ if (name && target_sp)
+ {
+ VariableList variable_list;
+ const bool append = true;
+
+ std::string regexstr;
+ uint32_t match_count;
+ switch (matchtype)
+ {
+ case eMatchTypeNormal:
+ match_count = target_sp->GetImages().FindGlobalVariables(ConstString(name),
+ append,
+ max_matches,
+ variable_list);
+ break;
+ case eMatchTypeRegex:
+ match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(name),
+ append,
+ max_matches,
+ variable_list);
+ break;
+ case eMatchTypeStartsWith:
+ regexstr = llvm::Regex::escape(name) + ".*";
+ match_count = target_sp->GetImages().FindGlobalVariables(RegularExpression(regexstr.c_str()),
+ append,
+ max_matches,
+ variable_list);
+ break;
+ }
+
+
+ if (match_count > 0)
+ {
+ ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
+ if (exe_scope == NULL)
+ exe_scope = target_sp.get();
+ for (uint32_t i = 0; i<match_count; ++i)
+ {
+ lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(exe_scope, variable_list.GetVariableAtIndex(i)));
+ if (valobj_sp)
+ sb_value_list.Append(SBValue(valobj_sp));
+ }
+ }
+ }
+
+ return sb_value_list;
+}
+
+
lldb::SBValue
SBTarget::FindFirstGlobalVariable (const char* name)
{
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 156f3cf9d0a..879eb9bd182 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -484,6 +484,26 @@ ModuleList::FindFunctionSymbols (const ConstString &name,
return sc_list.GetSize() - old_size;
}
+
+size_t
+ModuleList::FindFunctions(const RegularExpression &name,
+ bool include_symbols,
+ bool include_inlines,
+ bool append,
+ SymbolContextList& sc_list)
+{
+ const size_t old_size = sc_list.GetSize();
+
+ Mutex::Locker locker(m_modules_mutex);
+ collection::const_iterator pos, end = m_modules.end();
+ for (pos = m_modules.begin(); pos != end; ++pos)
+ {
+ (*pos)->FindFunctions (name, include_symbols, include_inlines, append, sc_list);
+ }
+
+ return sc_list.GetSize() - old_size;
+}
+
size_t
ModuleList::FindCompileUnits (const FileSpec &path,
bool append,
OpenPOWER on IntegriCloud