[Lldb-commits] [lldb] r126892 - in /lldb/trunk: include/lldb/API/SBAddress.h include/lldb/API/SBFunction.h include/lldb/API/SBSymbol.h source/API/SBFunction.cpp source/API/SBSymbol.cpp

Greg Clayton gclayton at apple.com
Wed Mar 2 15:01:18 PST 2011


Author: gclayton
Date: Wed Mar  2 17:01:18 2011
New Revision: 126892

URL: http://llvm.org/viewvc/llvm-project?rev=126892&view=rev
Log:
Export the ability to get the start and end addresses for functions
and symbols, and also allow clients to get the prologue size in bytes:

    SBAddress
    SBFunction::GetStartAddress ();
    
    SBAddress
    SBFunction::GetEndAddress ();
    
    uint32_t
    SBFunction::GetPrologueByteSize ();

    SBAddress
    SBSymbol::GetStartAddress ();
    
    SBAddress
    SBSymbol::GetEndAddress ();
    
    uint32_t
    SBSymbol::GetPrologueByteSize ();


Modified:
    lldb/trunk/include/lldb/API/SBAddress.h
    lldb/trunk/include/lldb/API/SBFunction.h
    lldb/trunk/include/lldb/API/SBSymbol.h
    lldb/trunk/source/API/SBFunction.cpp
    lldb/trunk/source/API/SBSymbol.cpp

Modified: lldb/trunk/include/lldb/API/SBAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=126892&r1=126891&r2=126892&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBAddress.h (original)
+++ lldb/trunk/include/lldb/API/SBAddress.h Wed Mar  2 17:01:18 2011
@@ -50,9 +50,11 @@
 protected:
 
     friend class SBFrame;
+    friend class SBFunction;
     friend class SBLineEntry;
     friend class SBInstruction;
     friend class SBModule;
+    friend class SBSymbol;
     friend class SBSymbolContext;
     friend class SBTarget;
     friend class SBThread;

Modified: lldb/trunk/include/lldb/API/SBFunction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFunction.h?rev=126892&r1=126891&r2=126892&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFunction.h (original)
+++ lldb/trunk/include/lldb/API/SBFunction.h Wed Mar  2 17:01:18 2011
@@ -11,6 +11,7 @@
 #define LLDB_SBFunction_h_
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBAddress.h"
 #include "lldb/API/SBInstructionList.h"
 
 namespace lldb {
@@ -43,6 +44,15 @@
     lldb::SBInstructionList
     GetInstructions (lldb::SBTarget target);
 
+    SBAddress
+    GetStartAddress ();
+
+    SBAddress
+    GetEndAddress ();
+
+    uint32_t
+    GetPrologueByteSize ();
+
 #ifndef SWIG
     bool
     operator == (const lldb::SBFunction &rhs) const;

Modified: lldb/trunk/include/lldb/API/SBSymbol.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbol.h?rev=126892&r1=126891&r2=126892&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSymbol.h (original)
+++ lldb/trunk/include/lldb/API/SBSymbol.h Wed Mar  2 17:01:18 2011
@@ -11,6 +11,7 @@
 #define LLDB_SBSymbol_h_
 
 #include "lldb/API/SBDefines.h"
+#include "lldb/API/SBAddress.h"
 #include "lldb/API/SBInstructionList.h"
 #include "lldb/API/SBTarget.h"
 
@@ -44,6 +45,15 @@
     lldb::SBInstructionList
     GetInstructions (lldb::SBTarget target);
 
+    SBAddress
+    GetStartAddress ();
+    
+    SBAddress
+    GetEndAddress ();
+    
+    uint32_t
+    GetPrologueByteSize ();
+
 #ifndef SWIG
     bool
     operator == (const lldb::SBSymbol &rhs) const;

Modified: lldb/trunk/source/API/SBFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=126892&r1=126891&r2=126892&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFunction.cpp (original)
+++ lldb/trunk/source/API/SBFunction.cpp Wed Mar  2 17:01:18 2011
@@ -156,3 +156,38 @@
     m_opaque_ptr = lldb_object_ptr;
 }
 
+SBAddress
+SBFunction::GetStartAddress ()
+{
+    SBAddress addr;
+    if (m_opaque_ptr)
+        addr.SetAddress (&m_opaque_ptr->GetAddressRange().GetBaseAddress());
+    return addr;
+}
+
+SBAddress
+SBFunction::GetEndAddress ()
+{
+    SBAddress addr;
+    if (m_opaque_ptr)
+    {
+        addr_t byte_size = m_opaque_ptr->GetAddressRange().GetByteSize();
+        if (byte_size > 0)
+        {
+            addr.SetAddress (&m_opaque_ptr->GetAddressRange().GetBaseAddress());
+            addr->Slide (byte_size);
+        }
+    }
+    return addr;
+}
+
+
+uint32_t
+SBFunction::GetPrologueByteSize ()
+{
+    if (m_opaque_ptr)
+        return m_opaque_ptr->GetPrologueByteSize();
+    return 0;
+}
+
+

Modified: lldb/trunk/source/API/SBSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=126892&r1=126891&r2=126892&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSymbol.cpp (original)
+++ lldb/trunk/source/API/SBSymbol.cpp Wed Mar  2 17:01:18 2011
@@ -153,3 +153,47 @@
 {
     m_opaque_ptr = symbol;
 }
+
+SBAddress
+SBSymbol::GetStartAddress ()
+{
+    SBAddress addr;
+    if (m_opaque_ptr)
+    {
+        // Make sure the symbol is an address based symbol first:
+        AddressRange *symbol_arange_ptr = m_opaque_ptr->GetAddressRangePtr();
+        if (symbol_arange_ptr)
+        {
+            addr.SetAddress (&symbol_arange_ptr->GetBaseAddress());
+        }
+    }
+    return addr;
+}
+
+SBAddress
+SBSymbol::GetEndAddress ()
+{
+    SBAddress addr;
+    if (m_opaque_ptr)
+    {
+        AddressRange *symbol_arange_ptr = m_opaque_ptr->GetAddressRangePtr();
+        if (symbol_arange_ptr)
+        {
+            addr_t byte_size = symbol_arange_ptr->GetByteSize();
+            if (byte_size > 0)
+            {
+                addr.SetAddress (&symbol_arange_ptr->GetBaseAddress());
+                addr->Slide (byte_size);
+            }
+        }
+    }
+    return addr;
+}
+
+uint32_t
+SBSymbol::GetPrologueByteSize ()
+{
+    if (m_opaque_ptr)
+        return m_opaque_ptr->GetPrologueByteSize();
+    return 0;
+}





More information about the lldb-commits mailing list