[Lldb-commits] [lldb] r149755 - in /lldb/trunk: include/lldb/API/SBAddress.h scripts/Python/interface/SBAddress.i scripts/Python/interface/SBModule.i scripts/Python/interface/SBSection.i source/API/SBAddress.cpp

Greg Clayton gclayton at apple.com
Fri Feb 3 18:58:17 PST 2012


Author: gclayton
Date: Fri Feb  3 20:58:17 2012
New Revision: 149755

URL: http://llvm.org/viewvc/llvm-project?rev=149755&view=rev
Log:
Allow a SBAddress to be created from a SBSection and an offset.

Changed the lldb.SBModule.section[<str>] property to return a single section.

Added a lldb.SBSection.addr property which returns an lldb.SBAddress object.


Modified:
    lldb/trunk/include/lldb/API/SBAddress.h
    lldb/trunk/scripts/Python/interface/SBAddress.i
    lldb/trunk/scripts/Python/interface/SBModule.i
    lldb/trunk/scripts/Python/interface/SBSection.i
    lldb/trunk/source/API/SBAddress.cpp

Modified: lldb/trunk/include/lldb/API/SBAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=149755&r1=149754&r2=149755&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBAddress.h (original)
+++ lldb/trunk/include/lldb/API/SBAddress.h Fri Feb  3 20:58:17 2012
@@ -23,6 +23,8 @@
 
     SBAddress (const lldb::SBAddress &rhs);
 
+    SBAddress (lldb::SBSection section, lldb::addr_t offset);
+
     // Create an address by resolving a load address using the supplied target
     SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
 
@@ -46,6 +48,9 @@
     GetLoadAddress (const lldb::SBTarget &target) const;
 
     void
+    SetAddress (lldb::SBSection section, lldb::addr_t offset);
+
+    void
     SetLoadAddress (lldb::addr_t load_addr, 
                     lldb::SBTarget &target);
     bool

Modified: lldb/trunk/scripts/Python/interface/SBAddress.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBAddress.i?rev=149755&r1=149754&r2=149755&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBAddress.i (original)
+++ lldb/trunk/scripts/Python/interface/SBAddress.i Fri Feb  3 20:58:17 2012
@@ -50,6 +50,9 @@
 
     SBAddress (const lldb::SBAddress &rhs);
 
+    SBAddress (lldb::SBSection section,
+               lldb::addr_t offset);
+    
     %feature("docstring", "
     Create an address by resolving a load address using the supplied target.
     ") SBAddress;
@@ -85,6 +88,11 @@
     lldb::addr_t
     SBAddress::GetOffset ();
 
+    void
+    SetAddress (lldb::SBSection section, 
+                lldb::addr_t offset);
+             
+
     %feature("docstring", "
     //------------------------------------------------------------------
     /// GetSymbolContext() and the following can lookup symbol information for a given address.

Modified: lldb/trunk/scripts/Python/interface/SBModule.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBModule.i?rev=149755&r1=149754&r2=149755&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBModule.i (original)
+++ lldb/trunk/scripts/Python/interface/SBModule.i Fri Feb  3 20:58:17 2012
@@ -320,12 +320,10 @@
                     if key < count:
                         return self.sbmodule.GetSectionAtIndex(key)
                 elif type(key) is str:
-                    matches = []
                     for idx in range(count):
                         section = self.sbmodule.GetSectionAtIndex(idx)
                         if section.name == key:
-                            matches.append(section)
-                    return matches
+                            return section
                 elif isinstance(key, self.re_compile_type):
                     matches = []
                     for idx in range(count):

Modified: lldb/trunk/scripts/Python/interface/SBSection.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBSection.i?rev=149755&r1=149754&r2=149755&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBSection.i (original)
+++ lldb/trunk/scripts/Python/interface/SBSection.i Fri Feb  3 20:58:17 2012
@@ -88,9 +88,15 @@
     GetDescription (lldb::SBStream &description);
     
     %pythoncode %{
+        def get_addr(self):
+            return SBAddress(self, 0)
+
         __swig_getmethods__["name"] = GetName
         if _newclass: x = property(GetName, None)
 
+        __swig_getmethods__["addr"] = get_addr
+        if _newclass: x = property(get_addr, None)
+
         __swig_getmethods__["file_addr"] = GetFileAddress
         if _newclass: x = property(GetFileAddress, None)
 

Modified: lldb/trunk/source/API/SBAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=149755&r1=149754&r2=149755&view=diff
==============================================================================
--- lldb/trunk/source/API/SBAddress.cpp (original)
+++ lldb/trunk/source/API/SBAddress.cpp Fri Feb  3 20:58:17 2012
@@ -103,6 +103,12 @@
         m_opaque_ap.reset (new AddressImpl(*rhs.m_opaque_ap.get()));
 }
 
+
+SBAddress::SBAddress (lldb::SBSection section, lldb::addr_t offset) :
+    m_opaque_ap(new AddressImpl (Address(section.GetSection(), offset)))
+{
+}
+
 // Create an address by resolving a load address using the supplied target
 SBAddress::SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target) :
     m_opaque_ap()
@@ -142,6 +148,15 @@
 }
 
 void
+SBAddress::SetAddress (lldb::SBSection section, lldb::addr_t offset)
+{
+    Address &addr = ref();
+    addr.SetSection (section.GetSection());
+    addr.SetOffset (offset);
+}
+
+
+void
 SBAddress::SetAddress (const Address *lldb_object_ptr)
 {
     if (lldb_object_ptr)





More information about the lldb-commits mailing list