This revision was automatically updated to reflect the committed changes.
Closed by commit rL264173: Implement ObjectFilePECOFF::GetEntryPointAddress. 
(authored by sas).

Changed prior to commit:
  http://reviews.llvm.org/D17970?vs=50978&id=51449#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17970

Files:
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h

Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -144,8 +144,8 @@
     uint32_t
     GetDependentModules(lldb_private::FileSpecList& files) override;
     
-//    virtual lldb_private::Address
-//    GetEntryPointAddress ();
+    virtual lldb_private::Address
+    GetEntryPointAddress () override;
     
     ObjectFile::Type
     CalculateType() override;
@@ -301,6 +301,7 @@
        coff_opt_header_t       m_coff_header_opt;
        SectionHeaderColl       m_sect_headers;
     lldb::addr_t               m_image_base;
+    lldb_private::Address      m_entry_point_address;
 };
 
 #endif // liblldb_ObjectFilePECOFF_h_
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -192,7 +192,8 @@
     m_dos_header (),
     m_coff_header (),
     m_coff_header_opt (),
-    m_sect_headers ()
+    m_sect_headers (),
+    m_entry_point_address ()
 {
     ::memset (&m_dos_header, 0, sizeof(m_dos_header));
     ::memset (&m_coff_header, 0, sizeof(m_coff_header));
@@ -814,6 +815,25 @@
     return 0;
 }
 
+lldb_private::Address
+ObjectFilePECOFF::GetEntryPointAddress ()
+{
+    if (m_entry_point_address.IsValid())
+        return m_entry_point_address;
+
+    if (!ParseHeader() || !IsExecutable())
+        return m_entry_point_address;
+
+    SectionList *section_list = GetSectionList();
+    addr_t offset = m_coff_header_opt.entry;
+
+    if (!section_list)
+        m_entry_point_address.SetOffset(offset);
+    else
+        m_entry_point_address.ResolveAddressUsingFileSections(offset, 
section_list);
+    return m_entry_point_address;
+}
+
 
 //----------------------------------------------------------------------
 // Dump


Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
===================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
@@ -144,8 +144,8 @@
     uint32_t
     GetDependentModules(lldb_private::FileSpecList& files) override;
     
-//    virtual lldb_private::Address
-//    GetEntryPointAddress ();
+    virtual lldb_private::Address
+    GetEntryPointAddress () override;
     
     ObjectFile::Type
     CalculateType() override;
@@ -301,6 +301,7 @@
 	coff_opt_header_t	m_coff_header_opt;
 	SectionHeaderColl	m_sect_headers;
     lldb::addr_t		m_image_base;
+    lldb_private::Address	m_entry_point_address;
 };
 
 #endif // liblldb_ObjectFilePECOFF_h_
Index: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -192,7 +192,8 @@
     m_dos_header (),
     m_coff_header (),
     m_coff_header_opt (),
-    m_sect_headers ()
+    m_sect_headers (),
+    m_entry_point_address ()
 {
     ::memset (&m_dos_header, 0, sizeof(m_dos_header));
     ::memset (&m_coff_header, 0, sizeof(m_coff_header));
@@ -814,6 +815,25 @@
     return 0;
 }
 
+lldb_private::Address
+ObjectFilePECOFF::GetEntryPointAddress ()
+{
+    if (m_entry_point_address.IsValid())
+        return m_entry_point_address;
+
+    if (!ParseHeader() || !IsExecutable())
+        return m_entry_point_address;
+
+    SectionList *section_list = GetSectionList();
+    addr_t offset = m_coff_header_opt.entry;
+
+    if (!section_list)
+        m_entry_point_address.SetOffset(offset);
+    else
+        m_entry_point_address.ResolveAddressUsingFileSections(offset, section_list);
+    return m_entry_point_address;
+}
+
 
 //----------------------------------------------------------------------
 // Dump
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to