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. https://reviews.llvm.org/D58405 Files: source/Core/Module.cpp source/Target/Process.cpp 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", file_spec.GetPath().c_str()); } - 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"); }
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", file_spec.GetPath().c_str()); } - 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"); }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits