[Lldb-commits] [PATCH] D128069: [lldb] add SBSection.alignment to python bindings

David M. Lary via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 17 09:49:30 PDT 2022


dmlary created this revision.
dmlary added a reviewer: clayborg.
dmlary added a project: LLDB.
Herald added subscribers: Michael137, JDevlieghere.
Herald added a project: All.
dmlary requested review of this revision.

This commit adds SBSection.GetAlignment(), and SBSection.alignment as a python property to lldb.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128069

Files:
  lldb/bindings/interface/SBSection.i
  lldb/include/lldb/API/SBSection.h
  lldb/source/API/SBSection.cpp


Index: lldb/source/API/SBSection.cpp
===================================================================
--- lldb/source/API/SBSection.cpp
+++ lldb/source/API/SBSection.cpp
@@ -242,6 +242,15 @@
   return 0;
 }
 
+uint32_t SBSection::GetAlignment() {
+  LLDB_INSTRUMENT_VA(this);
+
+  SectionSP section_sp(GetSP());
+  if (section_sp.get())
+    return (1 << section_sp->GetLog2Align());
+  return 0;
+}
+
 bool SBSection::operator==(const SBSection &rhs) {
   LLDB_INSTRUMENT_VA(this, rhs);
 
Index: lldb/include/lldb/API/SBSection.h
===================================================================
--- lldb/include/lldb/API/SBSection.h
+++ lldb/include/lldb/API/SBSection.h
@@ -76,6 +76,12 @@
   ///     The number of host (8-bit) bytes needed to hold a target byte
   uint32_t GetTargetByteSize();
 
+  /// Return the alignment of the section in bytes
+  ///
+  /// \return
+  ///     The alignment of the section in bytes
+  uint32_t GetAlignment();
+
   bool operator==(const lldb::SBSection &rhs);
 
   bool operator!=(const lldb::SBSection &rhs);
Index: lldb/bindings/interface/SBSection.i
===================================================================
--- lldb/bindings/interface/SBSection.i
+++ lldb/bindings/interface/SBSection.i
@@ -105,6 +105,9 @@
     uint32_t
     GetTargetByteSize ();
 
+    uint32_t
+    GetAlignment ();
+
     bool
     GetDescription (lldb::SBStream &description);
 
@@ -138,6 +141,7 @@
         data = property(GetSectionData, None, doc='''A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.''')
         type = property(GetSectionType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSectionType") that represents the type of this section (code, data, etc.).''')
         target_byte_size = property(GetTargetByteSize, None, doc='''A read only property that returns the size of a target byte represented by this section as a number of host bytes.''')
+        alignment = property(GetAlignment, None, doc='''A read only property that returns the alignment of this section as a number of host bytes.''')
     %}
 #endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128069.437941.patch
Type: text/x-patch
Size: 2205 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220617/d7fd8542/attachment.bin>


More information about the lldb-commits mailing list