summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBTarget.cpp
diff options
context:
space:
mode:
authorCarlo Kok <ck@remobjects.com>2014-09-19 19:38:19 +0000
committerCarlo Kok <ck@remobjects.com>2014-09-19 19:38:19 +0000
commit0fd6fd4fd45be23c885f6fa0654c780773ce9517 (patch)
treec3dac23c0b930778d660f4ff96a0abdac6f2adc4 /lldb/source/API/SBTarget.cpp
parent5a6edad3d8c09c6fc6122bf048da81028a7e994c (diff)
downloadbcm5719-llvm-0fd6fd4fd45be23c885f6fa0654c780773ce9517.tar.gz
bcm5719-llvm-0fd6fd4fd45be23c885f6fa0654c780773ce9517.zip
Adds two new functions to SBTarget FindGlobalVariables and FindGlobalFunctions that lets you search by name, by regular expression and by starts with.
llvm-svn: 218140
Diffstat (limited to 'lldb/source/API/SBTarget.cpp')
-rw-r--r--lldb/source/API/SBTarget.cpp84
1 files changed, 84 insertions, 0 deletions
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)
{
OpenPOWER on IntegriCloud