[Lldb-commits] [lldb] r182065 - Implement ObjectFileELF::GetModuleSpecifications(), and add PlatformLinux code to deal with unknown arch properties.
Mike Sartain
mikesart at valvesoftware.com
Thu May 16 21:58:17 PDT 2013
From: Malea, Daniel [daniel.malea at intel.com]
> Hey Mike, this commit seems to have caused some issues (at first glance,
> related to expression evaluation) on the clang buildbot:
>
> http://lab.llvm.org:8011/builders/lldb-x86_64-debian-clang/builds/3349
TargetList::CreateTarget() calls ObjectFile::GetModuleSpecifications() on Linux, and it is now returning something. Ie, platform_arch used to be invalid, but now it's x86_64/unknown/unknown.
That heads down and calls the next TargetList::CreateTarget() function, which has this bit of code in it:
1012│ // If we haven't set an architecture yet, reset our architecture based on what we found in the executable module.
1013│ if (!m_arch.IsValid())
1014│ {
1015├> m_arch = executable_sp->GetArchitecture();
1016│ if (log)
1017│ log->Printf ("Target::SetExecutableModule setting architecture to %s (%s) based on executable file", m_arch.GetArchitectureName(), m_arch.GetTriple().g
1018│ }
Since we've now got an arch, that code doesn't run, and we are left with x86_64-unknown-unknown instead of x86_64--linux. Full log of the two paths (working & not) are down below.
The below patch will fix up the vendor & os in Target::SetExecutableModule() if either are unknown. I've got a couple of questions / concerns though:
- The code below will run on all platforms. That scares me.
- This is the 2nd spot where we have to fix this arch stuff up for Linux. This scares me a bit as well.
How big of a can of worms are we opening by returning x86_64-unknown-unknown for elf files (since that's all the info we have in ObjectFileELF), and then expect everyone to fix up the vendor/os later on?
Thanks much.
-Mike
Index: source/Target/Target.cpp
===================================================================
--- source/Target/Target.cpp (revision 182073)
+++ source/Target/Target.cpp (working copy)
@@ -1016,6 +1016,17 @@
if (log)
log->Printf ("Target::SetExecutableModule setting architecture to %s (%s) based on executable file", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
}
+ else
+ {
+ llvm::Triple &arch_triple = m_arch.GetTriple();
+ const llvm::Triple &exe_triple = executable_sp->GetArchitecture().GetTriple();
+ if (arch_triple.getVendor() == llvm::Triple::UnknownVendor)
+ arch_triple.setVendorName (exe_triple.getVendorName());
+ if (arch_triple.getOS() == llvm::Triple::UnknownOS)
+ arch_triple.setOSName (exe_triple.getOSName());
+ if (log)
+ log->Printf ("Target::SetExecutableModule setting vendor/os architecture to %s (%s) based on executable file", m_arch.GetArchitectureName(), m_arch.GetTriple().getTriple().c_str());
+ }
FileSpecList dependent_files;
ObjectFile *executable_objfile = executable_sp->GetObjectFile();
############ working run ############
0x21b9c20 Target::Target()
Target::SetExecutableModule setting architecture to x86_64 (x86_64--linux-gnu) based on executable file
(lldb) p str.c_str()
ABISysV_x86_64::PrepareTrivialCall
(
thread = 0x7f58400008f0
sp = 0x7fff2e5510d0
func_addr = 0x7fbf9424c070
return_addr = 0x400a9c
arg1_ptr = 0x7fffe24af668 (0x0)
arg2_ptr = 0x7fffe24af660 (0x1000)
arg3_ptr = 0x7fffe24af850 (0x7)
)
About to write arg1 (0x0) into rdi
About to write arg2 (0x1000) into rsi
About to write arg3 (0x7) into rdx
About to write arg4 (0x22) into rcx
About to write arg5 (0xffffffffffffffff) into r8
About to write arg6 (0x0) into r9
16-byte aligning SP: 0x7fff2e5510d0 to 0x7fff2e5510d0
Pushing the return address onto the stack: new SP 0x7fff2e5510c8, return address 0x400a9c
Writing SP (0x7fff2e5510c8) down
Writing new IP (0x7fbf9424c070) down
0x7fffe24af4c0 Listener::Listener('lldb.process.listener.run-thread-plan')
0x7fffe24af4c0 Listener::~Listener('lldb.process.listener.run-thread-plan')
== [ClangUserExpression::Evaluate] Parsing expression str.c_str() ==
Found function _Z12$__lldb_exprPv for $__lldb_expr
Module as passed in to IRForTarget:
"; ModuleID = '$__lldb_module'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64--linux"
############ not working run ############
0x1af8d80 Target::Target()
Target::Target created with architecture x86_64 (x86_64-unknown-unknown)
(lldb) p str.c_str()
== [ClangUserExpression::Evaluate] Parsing expression str.c_str() ==
Found function _Z12$__lldb_exprPv for $__lldb_expr
Module as passed in to IRForTarget:
"; ModuleID = '$__lldb_module'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-unknown"
More information about the lldb-commits
mailing list