fjricci created this revision.
fjricci added reviewers: tberghammer, ADodds, tfiala.
fjricci added subscribers: sas, lldb-commits.

The logic to read modules from memory was added to LoadModuleAtAddress
in the dynamic loader, but not in process gdb remote. This means that when
the remote uses svr4 packets to give library info, libraries only present
on the remote will not be loaded.

This patch therefore involves some code duplication from LoadModuleAtAddress
in the dynamic loader, but removing this would require some amount of code
refactoring.

http://reviews.llvm.org/D18531

Files:
  source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4821,6 +4821,25 @@
     {
         module_sp->SetLoadAddress (target, base_addr, value_is_offset, 
changed);
     }
+    else
+    {
+        if (value_is_offset)
+        {
+            // Try to fetch the load address of the file from the process as 
we need absolute load
+            // address to read the file out of the memory instead of a load 
bias.
+            bool is_loaded;
+            lldb::addr_t load_addr;
+            Error error = GetFileLoadAddress (file, is_loaded, load_addr);
+            if (error.Success() && is_loaded)
+                base_addr = load_addr;
+        }
+
+        if ((module_sp = ReadModuleFromMemory (file, base_addr)))
+        {
+            module_sp->SetLoadAddress (target, base_addr, false, changed);
+            target.GetImages().AppendIfNeeded (module_sp);
+        }
+    }
 
     return module_sp;
 }


Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4821,6 +4821,25 @@
     {
         module_sp->SetLoadAddress (target, base_addr, value_is_offset, changed);
     }
+    else
+    {
+        if (value_is_offset)
+        {
+            // Try to fetch the load address of the file from the process as we need absolute load
+            // address to read the file out of the memory instead of a load bias.
+            bool is_loaded;
+            lldb::addr_t load_addr;
+            Error error = GetFileLoadAddress (file, is_loaded, load_addr);
+            if (error.Success() && is_loaded)
+                base_addr = load_addr;
+        }
+
+        if ((module_sp = ReadModuleFromMemory (file, base_addr)))
+        {
+            module_sp->SetLoadAddress (target, base_addr, false, changed);
+            target.GetImages().AppendIfNeeded (module_sp);
+        }
+    }
 
     return module_sp;
 }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to