Be a little more permissive in DynamicLoaderMacOS::CanLoadImage

If we can't find the "is dyld locked" symbol, assume it is safe
to load the image unless we only have 1 image loaded - in which case
we are in _dyld_start and it is definitely NOT safe.

Also add a little better errors to that function, and better logging
in SBProcess.cpp.

<rdar://problem/30174817>

llvm-svn: 302327
This commit is contained in:
Jim Ingham
2017-05-06 01:15:47 +00:00
parent 88172fb603
commit abc5d72f02
2 changed files with 23 additions and 10 deletions

View File

@@ -1157,22 +1157,34 @@ uint32_t SBProcess::LoadImage(lldb::SBFileSpec &sb_remote_image_spec,
uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec,
const lldb::SBFileSpec &sb_remote_image_spec,
lldb::SBError &sb_error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
ProcessSP process_sp(GetSP());
if (process_sp) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock())) {
if (log)
log->Printf("SBProcess(%p)::LoadImage() => calling Platform::LoadImage"
"for: %s",
static_cast<void *>(process_sp.get()),
sb_local_image_spec.GetFilename());
std::lock_guard<std::recursive_mutex> guard(
process_sp->GetTarget().GetAPIMutex());
process_sp->GetTarget().GetAPIMutex());
PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec,
*sb_remote_image_spec, sb_error.ref());
} else {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
log->Printf("SBProcess(%p)::LoadImage() => error: process is running",
static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
} else {
if (log)
log->Printf("SBProcess(%p)::LoadImage() => error: called with invalid"
" process",
static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is invalid");
}
return LLDB_INVALID_IMAGE_TOKEN;
}