> Changed name of Section::GetOffset to Section::GetMemoryOffset
> Added comment for Section::GetFileOffset to make it clear that the offset is 
> always from the beginning of the file, not the parent section.
> Changed comment for Section::GetMemoryOffset so it's clear that the offset in 
> memory is from the parent section if there is a parent section.
> The code change in SymbolFileDWARF::GetCachedSectionData was not changed from 
> my earlier revision.
Gary asked me to check the JIT processing. Running lldb on a C program produced 
the same result both with and without my patch:
(lldb) expr -g -- (int)printf("Hello world\n")
error: Execution was halted at the first instruction of the expression function 
because "debug" was requested.
Use "thread return -x" to return to the state before expression evaluation.

http://reviews.llvm.org/D5568

Files:
  include/lldb/Core/Section.h
  source/Core/Section.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Index: include/lldb/Core/Section.h
===================================================================
--- include/lldb/Core/Section.h
+++ include/lldb/Core/Section.h
@@ -170,6 +170,7 @@
     bool
     ResolveContainedAddress (lldb::addr_t offset, Address &so_addr) const;
 
+    // The offset between the start of the section and the start of the file.
     lldb::offset_t
     GetFileOffset () const
     {
@@ -200,8 +201,10 @@
     bool
     SetFileAddress (lldb::addr_t file_addr);
 
+    // The offset in virtual memory between this section and its parent. 
+    // If this section does not have a parent, returns the starting virtual memory address of this section.
     lldb::addr_t
-    GetOffset () const;
+    GetMemoryOffset () const;
 
 
     lldb::addr_t
Index: source/Core/Section.cpp
===================================================================
--- source/Core/Section.cpp
+++ source/Core/Section.cpp
@@ -128,7 +128,7 @@
 }
 
 lldb::addr_t
-Section::GetOffset () const
+Section::GetMemoryOffset () const
 {
     // This section has a parent which means m_file_addr is an offset.
     SectionSP parent_sp (GetParent ());
@@ -148,7 +148,7 @@
     {
         load_base_addr = parent_sp->GetLoadBaseAddress (target);
         if (load_base_addr != LLDB_INVALID_ADDRESS)
-            load_base_addr += GetOffset();
+            load_base_addr += GetMemoryOffset();
     }
     if (load_base_addr == LLDB_INVALID_ADDRESS)
     {
@@ -167,7 +167,7 @@
         {
             Section* child_section = m_children.GetSectionAtIndex (i).get();
 
-            addr_t child_offset = child_section->GetOffset();
+            addr_t child_offset = child_section->GetMemoryOffset();
             if (child_offset <= offset && offset - child_offset < child_section->GetByteSize())
                 return child_section->ResolveContainedAddress (offset - child_offset, so_addr);
         }
Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -746,7 +746,16 @@
                 // See if we memory mapped the DWARF segment?
                 if (m_dwarf_data.GetByteSize())
                 {
-                    data.SetData(m_dwarf_data, section_sp->GetOffset (), section_sp->GetFileSize());
+                    // Get the offset of this section from the beginning of the file.
+                    lldb::offset_t offset = section_sp->GetFileOffset();
+                    SectionSP parent_sp (section_sp->GetParent());
+                    // If this section has a parent then we need the offset in the file from
+                    // the beginning of the parent section.
+                    if (parent_sp)
+                    {
+                        offset = offset - parent_sp->GetFileOffset();
+                    }
+                    data.SetData(m_dwarf_data, offset, section_sp->GetFileSize());
                 }
                 else
                 {
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to