[Lldb-commits] [PATCH] D58405: Make educated guess when constructing module from memory

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 19 13:46:18 PST 2019

xiaobai created this revision.
xiaobai added reviewers: clayborg, zturner, JDevlieghere, compnerd, aprantl, labath.
Herald added a subscriber: jdoerfert.

While debugging an android process remotely from a windows machine, I
noticed that the modules constructed from an object file in memory only had
information about the architecture. Without knowledge of the OS or environment,
expression evaluation sometimes leads to incorrectly generated code or a
debugger crash. While we cannot know for certain what triple a module
constructed from an in-memory object file will have, a good guess is the triple
that the target executable was compiled for.



Index: source/Target/Process.cpp
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -2635,7 +2635,8 @@
     log->Printf("Process::ReadModuleFromMemory reading %s binary from memory",
-  ModuleSP module_sp(new Module(file_spec, ArchSpec()));
+  ModuleSP module_sp(new Module(
+      file_spec, GetTarget().GetExecutableModule()->GetArchitecture()));
   if (module_sp) {
     Status error;
     ObjectFile *objfile = module_sp->GetMemoryObjectFile(
Index: source/Core/Module.cpp
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -308,7 +308,7 @@
           // Once we get the object file, update our module with the object
           // file's architecture since it might differ in vendor/os if some
           // parts were unknown.
-          m_arch = m_objfile_sp->GetArchitecture();
+          m_arch.MergeFrom(m_objfile_sp->GetArchitecture());
         } else {
           error.SetErrorString("unable to find suitable object file plug-in");

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58405.187438.patch
Type: text/x-patch
Size: 1163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190219/84bae9b1/attachment.bin>

More information about the lldb-commits mailing list