<rdar://problem/13021266>
authorEnrico Granata <egranata@apple.com>
Wed, 16 Jan 2013 18:53:52 +0000 (18:53 +0000)
committerEnrico Granata <egranata@apple.com>
Wed, 16 Jan 2013 18:53:52 +0000 (18:53 +0000)
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/include/lldb/API/SBModule.h
lldb/include/lldb/API/SBTarget.h
lldb/scripts/Python/interface/SBModule.i
lldb/scripts/Python/interface/SBTarget.i
lldb/source/API/SBModule.cpp
lldb/source/API/SBTarget.cpp

index d2e9903..c75c4a1 100644 (file)
@@ -175,6 +175,22 @@ public:
                          const char *name, 
                          uint32_t max_matches);
     
+    //------------------------------------------------------------------
+    /// Find the first global (or static) variable by name.
+    ///
+    /// @param[in] target
+    ///     A valid SBTarget instance representing the debuggee.
+    ///
+    /// @param[in] name
+    ///     The name of the global or static variable we are looking
+    ///     for.
+    ///
+    /// @return
+    ///     An SBValue that gets filled in with the found variable (if any).
+    //------------------------------------------------------------------
+    lldb::SBValue
+    FindFirstGlobalVariable (lldb::SBTarget &target, const char *name);
+    
     lldb::SBType
     FindFirstType (const char* name);
     
index ddc868a..2d8c4b9 100644 (file)
@@ -603,6 +603,19 @@ public:
     FindGlobalVariables (const char *name, 
                          uint32_t max_matches);
 
+    //------------------------------------------------------------------
+    /// Find the first global (or static) variable by name.
+    ///
+    /// @param[in] name
+    ///     The name of the global or static variable we are looking
+    ///     for.
+    ///
+    /// @return
+    ///     An SBValue that gets filled in with the found variable (if any).
+    //------------------------------------------------------------------
+    lldb::SBValue
+    FindFirstGlobalVariable (const char* name);
+    
     void
     Clear ();
 
index ee2d3b4..6142c39 100644 (file)
@@ -248,6 +248,24 @@ public:
                          const char *name, 
                          uint32_t max_matches);
     
+    %feature("docstring", "
+    //------------------------------------------------------------------
+    /// Find the first global (or static) variable by name.
+    ///
+    /// @param[in] target
+    ///     A valid SBTarget instance representing the debuggee.
+    ///
+    /// @param[in] name
+    ///     The name of the global or static variable we are looking
+    ///     for.
+    ///
+    /// @return
+    ///     An SBValue that gets filled in with the found variable (if any).
+    //------------------------------------------------------------------
+    ") FindFirstGlobalVariable;
+    lldb::SBValue
+    FindFirstGlobalVariable (lldb::SBTarget &target, const char *name);
+             
     lldb::ByteOrder
     GetByteOrder ();
     
index 88fcf03..8d681e8 100644 (file)
@@ -586,6 +586,21 @@ public:
     FindGlobalVariables (const char *name, 
                          uint32_t max_matches);
 
+     %feature("docstring", "
+    //------------------------------------------------------------------
+    /// Find the first global (or static) variable by name.
+    ///
+    /// @param[in] name
+    ///     The name of the global or static variable we are looking
+    ///     for.
+    ///
+    /// @return
+    ///     An SBValue that gets filled in with the found variable (if any).
+    //------------------------------------------------------------------
+    ") FindFirstGlobalVariable;
+    lldb::SBValue
+    FindFirstGlobalVariable (const char* name);
+
     void
     Clear ();
 
index f0c916e..219870c 100644 (file)
@@ -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)
 {
index 4641437..79b038b 100644 (file)
@@ -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()
 {