From 672e6f59c5e487b83b81c8b13ce162dfda7fdddf Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Mon, 7 Mar 2011 23:44:08 +0000 Subject: Add a method "GetEntryPoint" to the ObjectFile class, and implement it on MachO & ELF - though the ELF implementation is probably a little weak. Then use this method in place of directly looking for "start" in the ThreadPlanCallFunction constructor to find the stopping point for our function evaluation. llvm-svn: 127194 --- lldb/source/Target/ThreadPlanCallFunction.cpp | 30 ++++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'lldb/source/Target/ThreadPlanCallFunction.cpp') diff --git a/lldb/source/Target/ThreadPlanCallFunction.cpp b/lldb/source/Target/ThreadPlanCallFunction.cpp index d3b62e6c7aaa..a5e1c1a0e794 100644 --- a/lldb/source/Target/ThreadPlanCallFunction.cpp +++ b/lldb/source/Target/ThreadPlanCallFunction.cpp @@ -66,19 +66,33 @@ ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread, lldb::addr_t spBelowRedZone = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize(); - SymbolContextList contexts; - SymbolContext context; ModuleSP executableModuleSP (target.GetExecutableModule()); - if (!executableModuleSP || - !executableModuleSP->FindSymbolsWithNameAndType(ConstString ("start"), eSymbolTypeCode, contexts)) + if (!executableModuleSP) + { + log->Printf ("Can't execute code without an executable module."); return; + } + else + { + ObjectFile *objectFile = executableModuleSP->GetObjectFile(); + if (!objectFile) + { + log->Printf ("Could not find object file for module \"%s\".", + executableModuleSP->GetFileSpec().GetFilename().AsCString()); + return; + } + m_start_addr = objectFile->GetEntryPointAddress(); + if (!m_start_addr.IsValid()) + { + log->Printf ("Could not find entry point address for executable module \"%s\".", + executableModuleSP->GetFileSpec().GetFilename().AsCString()); + return; + } + } - contexts.GetContextAtIndex(0, context); - - m_start_addr = context.symbol->GetValue(); lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&target); - + // Checkpoint the thread state so we can restore it later. if (log && log->GetVerbose()) ReportRegisterState ("About to checkpoint thread before function call. Original register state was:"); -- cgit v1.2.3