[Lldb-commits] [lldb] r252024 - Actually implement Section::GetSectionData.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 3 17:02:43 PST 2015


Author: jingham
Date: Tue Nov  3 19:02:43 2015
New Revision: 252024

URL: http://llvm.org/viewvc/llvm-project?rev=252024&view=rev
Log:
Actually implement Section::GetSectionData.

Modified:
    lldb/trunk/include/lldb/Core/Section.h
    lldb/trunk/source/Core/Section.cpp

Modified: lldb/trunk/include/lldb/Core/Section.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=252024&r1=252023&r2=252024&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Section.h (original)
+++ lldb/trunk/include/lldb/Core/Section.h Tue Nov  3 19:02:43 2015
@@ -64,9 +64,6 @@ public:
     lldb::SectionSP
     FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT32_MAX) const;
 
-    bool
-    GetSectionData (const DataExtractor& module_data, DataExtractor& section_data) const;
-
     // Get the number of sections in this list only
     size_t
     GetSize () const
@@ -288,6 +285,46 @@ public:
         return m_obj_file;
     }
 
+    //------------------------------------------------------------------
+    /// Read the section data from the object file that the section
+    /// resides in.
+    ///
+    /// @param[in] dst
+    ///     Where to place the data
+    ///
+    /// @param[in] dst_len
+    ///     How many bytes of section data to read
+    ///
+    /// @param[in] offset
+    ///     The offset in bytes within this section's data at which to
+    ///     start copying data from.
+    ///
+    /// @return
+    ///     The number of bytes read from the section, or zero if the
+    ///     section has no data or \a offset is not a valid offset
+    ///     in this section.
+    //------------------------------------------------------------------
+    lldb::offset_t
+    GetSectionData (void *dst, lldb::offset_t dst_len, lldb::offset_t offset = 0);
+    
+    //------------------------------------------------------------------
+    /// Get the shared reference to the section data from the object
+    /// file that the section resides in. No copies of the data will be
+    /// make unless the object file has been read from memory. If the
+    /// object file is on disk, it will shared the mmap data for the
+    /// entire object file.
+    ///
+    /// @param[in] data
+    ///     Where to place the data, address byte size, and byte order
+    ///
+    /// @return
+    ///     The number of bytes read from the section, or zero if the
+    ///     section has no data or \a offset is not a valid offset
+    ///     in this section.
+    //------------------------------------------------------------------
+    lldb::offset_t
+    GetSectionData (DataExtractor& data) const;
+
     uint32_t GetLog2Align()
     {
         return m_log2align;

Modified: lldb/trunk/source/Core/Section.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=252024&r1=252023&r2=252024&view=diff
==============================================================================
--- lldb/trunk/source/Core/Section.cpp (original)
+++ lldb/trunk/source/Core/Section.cpp Tue Nov  3 19:02:43 2015
@@ -319,6 +319,25 @@ Section::Slide (addr_t slide_amount, boo
     return false;
 }
 
+lldb::offset_t
+Section::GetSectionData (void *dst, lldb::offset_t dst_len, lldb::offset_t offset)
+{
+    if (m_obj_file)
+        return m_obj_file->ReadSectionData (this,
+                                            offset,
+                                            dst,
+                                            dst_len);
+    return 0;
+}
+
+lldb::offset_t
+Section::GetSectionData (DataExtractor& section_data) const
+{
+    if (m_obj_file)
+        return m_obj_file->ReadSectionData (this, section_data);
+    return 0;
+}
+
 #pragma mark SectionList
 
 SectionList::SectionList () :




More information about the lldb-commits mailing list