[Lldb-commits] [PATCH] D18531: Allow gdbremote process to read modules from memory

Francis Ricci via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 28 16:47:24 PDT 2016

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



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;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18531.51854.patch
Type: text/x-patch
Size: 1110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160328/1bd0568b/attachment.bin>

More information about the lldb-commits mailing list