[Lldb-commits] [lldb] r280924 - LLDB: API for iPermission of object file's sections

Abhishek Aggarwal via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 8 05:22:57 PDT 2016


Author: abhishek
Date: Thu Sep  8 07:22:56 2016
New Revision: 280924

URL: http://llvm.org/viewvc/llvm-project?rev=280924&view=rev
Log:
LLDB: API for iPermission of object file's sections
    
 Summary:
 - Added an API to public interface that provides permissions (RWX) of
   individual sections of an object file
   
 - Earlier, there was no way to find out this information through SB
   APIs
    
 - A possible use case of this API is:
   when a user wants to know the sections that have executable machine
   instructions and want to write a tool on top of LLDB based on this
   information

 - Differential Revision: https://reviews.llvm.org/D24251


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

Modified: lldb/trunk/include/lldb/API/SBSection.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSection.h?rev=280924&r1=280923&r2=280924&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSection.h (original)
+++ lldb/trunk/include/lldb/API/SBSection.h Thu Sep  8 07:22:56 2016
@@ -54,6 +54,21 @@ public:
   SectionType GetSectionType();
 
   //------------------------------------------------------------------
+  /// Gets the permissions (RWX) of the section of the object file
+  ///
+  /// Returns a mask of bits of enum lldb::Permissions for this section.
+  /// Sections for which permissions are not defined, 0 is returned for
+  /// them. The binary representation of this value corresponds to [XRW]
+  /// i.e. for a section having read and execute permissions, the value
+  /// returned is 6
+  ///
+  /// @return
+  ///     Returns an unsigned value for Permissions for the section.
+  //------------------------------------------------------------------
+  uint32_t
+  GetPermissions() const;
+
+  //------------------------------------------------------------------
   /// Return the size of a target's byte represented by this section
   /// in numbers of host bytes. Note that certain architectures have
   /// varying minimum addressable unit (i.e. byte) size for their

Modified: lldb/trunk/scripts/interface/SBSection.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBSection.i?rev=280924&r1=280923&r2=280924&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBSection.i (original)
+++ lldb/trunk/scripts/interface/SBSection.i Thu Sep  8 07:22:56 2016
@@ -90,6 +90,9 @@ public:
     SectionType
     GetSectionType ();
 
+    uint32_t
+    GetPermissions() const;
+
     %feature("docstring", "
     //------------------------------------------------------------------
     /// Return the size of a target's byte represented by this section

Modified: lldb/trunk/source/API/SBSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSection.cpp?rev=280924&r1=280923&r2=280924&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSection.cpp (original)
+++ lldb/trunk/source/API/SBSection.cpp Thu Sep  8 07:22:56 2016
@@ -188,6 +188,15 @@ SectionType SBSection::GetSectionType()
   return eSectionTypeInvalid;
 }
 
+uint32_t
+SBSection::GetPermissions() const
+{
+    SectionSP section_sp(GetSP());
+    if (section_sp)
+        return section_sp->GetPermissions();
+    return 0;
+}
+
 uint32_t SBSection::GetTargetByteSize() {
   SectionSP section_sp(GetSP());
   if (section_sp.get())




More information about the lldb-commits mailing list