[Lldb-commits] [lldb] r186114 - Adds methods to ObjectFileELF to access data in ELF segments

Ashok Thirumurthi ashok.thirumurthi at intel.com
Thu Jul 11 13:39:00 PDT 2013


Author: athirumu
Date: Thu Jul 11 15:39:00 2013
New Revision: 186114

URL: http://llvm.org/viewvc/llvm-project?rev=186114&view=rev
Log:
Adds methods to ObjectFileELF to access data in ELF segments
in preparation to add support for ELF core files.

Patch by Samuel Jacob!

Modified:
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=186114&r1=186113&r2=186114&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Jul 11 15:39:00 2013
@@ -801,6 +801,33 @@ ObjectFileELF::GetSectionHeaderInfo(Sect
     return 0;
 }
 
+size_t
+ObjectFileELF::GetProgramHeaderCount()
+{
+    return ParseProgramHeaders();
+}
+
+const elf::ELFProgramHeader *
+ObjectFileELF::GetProgramHeaderByIndex(lldb::user_id_t id)
+{
+    if (!id || !ParseProgramHeaders())
+        return NULL;
+
+    if (--id < m_program_headers.size())
+        return &m_program_headers[id];
+
+    return NULL;
+}
+
+DataExtractor 
+ObjectFileELF::GetSegmentDataByIndex(lldb::user_id_t id)
+{
+    const elf::ELFProgramHeader *segment_header = GetProgramHeaderByIndex(id);
+    if (segment_header == NULL)
+        return DataExtractor();
+    return DataExtractor(m_data, segment_header->p_offset, segment_header->p_filesz);
+}
+
 //----------------------------------------------------------------------
 // ParseSectionHeaders
 //----------------------------------------------------------------------
@@ -813,7 +840,7 @@ ObjectFileELF::ParseSectionHeaders()
 const ObjectFileELF::ELFSectionHeaderInfo *
 ObjectFileELF::GetSectionHeaderByIndex(lldb::user_id_t id)
 {
-    if (!ParseSectionHeaders() || !id)
+    if (!id || !ParseSectionHeaders())
         return NULL;
 
     if (--id < m_section_headers.size())

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h?rev=186114&r1=186113&r2=186114&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h Thu Jul 11 15:39:00 2013
@@ -135,6 +135,18 @@ public:
     virtual ObjectFile::Strata
     CalculateStrata();
 
+    // Returns number of program headers found in the ELF file.
+    size_t
+    GetProgramHeaderCount();
+
+    // Returns the program header with the given index.
+    const elf::ELFProgramHeader *
+    GetProgramHeaderByIndex(lldb::user_id_t id);
+
+    // Returns segment data for the given index.
+    lldb_private::DataExtractor
+    GetSegmentDataByIndex(lldb::user_id_t id);
+
 private:
     ObjectFileELF(const lldb::ModuleSP &module_sp,
                   lldb::DataBufferSP& data_sp,





More information about the lldb-commits mailing list