From bcd80b47234b48e42ed9f8d557faef554034c47a Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Wed, 16 Jan 2013 18:53:52 +0000 Subject: Adding FindFirstGlobalVariable to SBModule and SBTarget These calls work like FindGlobalVariables but they only return the first match found and so they can return an SBValue instead of an SBValueList for added convenience of use llvm-svn: 172636 --- lldb/source/API/SBModule.cpp | 9 +++++++++ lldb/source/API/SBTarget.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'lldb/source/API') diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index f0c916ea048..219870c733c 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -480,6 +480,15 @@ SBModule::FindGlobalVariables (SBTarget &target, const char *name, uint32_t max_ return sb_value_list; } +lldb::SBValue +SBModule::FindFirstGlobalVariable (lldb::SBTarget &target, const char *name) +{ + SBValueList sb_value_list(FindGlobalVariables(target, name, 1)); + if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) + return sb_value_list.GetValueAtIndex(0); + return SBValue(); +} + lldb::SBType SBModule::FindFirstType (const char *name_cstr) { diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 464143729fb..79b038b2766 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -2232,6 +2232,15 @@ SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches) return sb_value_list; } +lldb::SBValue +SBTarget::FindFirstGlobalVariable (const char* name) +{ + SBValueList sb_value_list(FindGlobalVariables(name, 1)); + if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0) + return sb_value_list.GetValueAtIndex(0); + return SBValue(); +} + SBSourceManager SBTarget::GetSourceManager() { -- cgit v1.2.3