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.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@127194 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index d3b62e6..a5e1c1a 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -66,19 +66,33 @@
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:");