This is the LLDB side of http://reviews.llvm.org/D4005

http://reviews.llvm.org/D4006

Files:
  lib/Makefile
  source/Core/Section.cpp
  source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
  source/Plugins/Makefile
  source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
Index: lib/Makefile
===================================================================
--- lib/Makefile
+++ lib/Makefile
@@ -101,7 +101,9 @@
               lldbPluginSymbolVendorMacOSX.a \
               lldbPluginProcessDarwin.a \
               lldbPluginProcessMachCore.a \
-              lldbPluginSystemRuntimeMacOSX.a
+              lldbPluginSystemRuntimeMacOSX.a \
+              lldbPluginProcessElfCore.a \
+              lldbPluginJITLoaderGDB.a
 endif
 
 ifeq ($(HOST_OS),Linux)
Index: source/Core/Section.cpp
===================================================================
--- source/Core/Section.cpp
+++ source/Core/Section.cpp
@@ -142,7 +142,7 @@
         if (load_base_addr != LLDB_INVALID_ADDRESS)
             load_base_addr += GetOffset();
     }
-    else
+    if (load_base_addr == LLDB_INVALID_ADDRESS)
     {
         load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (const_cast<Section *>(this)->shared_from_this());
     }
Index: source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
===================================================================
--- source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -144,6 +144,27 @@
     return instance->ReadJITDescriptor(false);
 }
 
+static void updateSectionLoadAddress(const SectionList &section_list, Target &target, uint64_t symbolfile_addr, uint64_t symbolfile_size)
+{
+    const uint32_t num_sections = section_list.GetSize();
+    for (uint32_t i = 0; i<num_sections; ++i)
+    {
+        SectionSP section_sp(section_list.GetSectionAtIndex(i));
+        if (section_sp)
+        {
+            if(section_sp->IsFake()) {
+                updateSectionLoadAddress(section_sp->GetChildren(), target, symbolfile_addr, symbolfile_size);
+            }
+            else if (section_sp->GetFileAddress() > 0x100000)
+                target.SetSectionLoadAddress(section_sp, section_sp->GetFileAddress(), true);
+            else {
+                section_sp->SetFileAddress(symbolfile_addr+section_sp->GetFileOffset());
+                target.SetSectionLoadAddress(section_sp, symbolfile_addr+section_sp->GetFileOffset(), true);
+            }
+        }
+    }
+}
+
 bool
 JITLoaderGDB::ReadJITDescriptor(bool all_entries)
 {
@@ -212,11 +233,30 @@
                 m_jit_objects.insert(
                     std::pair<lldb::addr_t, const lldb::ModuleSP>(
                         symbolfile_addr, module_sp));
-                module_sp->SetLoadAddress(target, 0, true, changed);
+                if (module_sp->GetObjectFile()->GetPluginName() == ConstString("mach-o"))
+                {
+                    ObjectFile *image_object_file = module_sp->GetObjectFile();
+                    if (image_object_file)
+                    {
+                        const SectionList *section_list = image_object_file->GetSectionList ();
+                        if (section_list)
+                        {
+                            updateSectionLoadAddress(*section_list, target, symbolfile_addr, symbolfile_size);
+                        }
+                    }
+                }
+                else
+                {
+                    module_sp->SetLoadAddress(target, 0, true, changed);
+                }
 
                 // load the symbol table right away
                 module_sp->GetObjectFile()->GetSymtab();
 
+                module_sp->GetSymbolVendor()->GetNumCompileUnits();
+                module_sp->GetSymbolVendor()->GetCompileUnitAtIndex(0);
+                module_sp->ParseAllDebugSymbols();
+
                 module_list.AppendIfNeeded(module_sp);
 
                 ModuleList module_list;
@@ -295,9 +335,7 @@
 JITLoaderGDB::CreateInstance(Process *process, bool force)
 {
     JITLoaderSP jit_loader_sp;
-    ArchSpec arch (process->GetTarget().GetArchitecture());
-    if (arch.GetTriple().getVendor() != llvm::Triple::Apple)
-        jit_loader_sp.reset(new JITLoaderGDB(process));
+    jit_loader_sp.reset(new JITLoaderGDB(process));
     return jit_loader_sp;
 }
 
Index: source/Plugins/Makefile
===================================================================
--- source/Plugins/Makefile
+++ source/Plugins/Makefile
@@ -33,6 +33,8 @@
 #DIRS += Process/MacOSX-User
 DIRS += Process/mach-core
 DIRS += SystemRuntime/MacOSX
+DIRS += Process/elf-core
+DIRS += JITLoader/GDB
 endif
 
 ifeq ($(HOST_OS),Linux)
Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===================================================================
--- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1986,37 +1986,37 @@
                     }
                 }
             }
+
         }
-        else
+
+        nlist_data.SetData (m_data,
+                            symtab_load_command.symoff,
+                            nlist_data_byte_size);
+        strtab_data.SetData (m_data,
+                             symtab_load_command.stroff,
+                             strtab_data_byte_size);
+        
+        if (dyld_info.export_size > 0)
         {
-            nlist_data.SetData (m_data,
-                                symtab_load_command.symoff,
-                                nlist_data_byte_size);
-            strtab_data.SetData (m_data,
-                                 symtab_load_command.stroff,
-                                 strtab_data_byte_size);
-            
-            if (dyld_info.export_size > 0)
-            {
-                dyld_trie_data.SetData (m_data,
-                                        dyld_info.export_off,
-                                        dyld_info.export_size);
-            }
+            dyld_trie_data.SetData (m_data,
+                                    dyld_info.export_off,
+                                    dyld_info.export_size);
+        }
 
-            if (m_dysymtab.nindirectsyms != 0)
-            {
-                indirect_symbol_index_data.SetData (m_data,
-                                                    m_dysymtab.indirectsymoff,
-                                                    m_dysymtab.nindirectsyms * 4);
-            }
-            if (function_starts_load_command.cmd)
-            {
-                function_starts_data.SetData (m_data,
-                                              function_starts_load_command.dataoff,
-                                              function_starts_load_command.datasize);
-            }
+        if (m_dysymtab.nindirectsyms != 0)
+        {
+            indirect_symbol_index_data.SetData (m_data,
+                                                m_dysymtab.indirectsymoff,
+                                                m_dysymtab.nindirectsyms * 4);
+        }
+        if (function_starts_load_command.cmd)
+        {
+            function_starts_data.SetData (m_data,
+                                          function_starts_load_command.dataoff,
+                                          function_starts_load_command.datasize);
         }
 
+
         if (nlist_data.GetByteSize() == 0 && memory_module_load_level == eMemoryModuleLoadLevelComplete)
         {
             if (log)
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to