@@ -6975,44 +6975,81 @@ ObjectFileMachO::GetCorefileAllImageInfos() {
6975
6975
bool ObjectFileMachO::LoadCoreFileImages (lldb_private::Process &process) {
6976
6976
MachOCorefileAllImageInfos image_infos = GetCorefileAllImageInfos ();
6977
6977
Log *log = GetLog (LLDBLog::DynamicLoader);
6978
+ Status error;
6978
6979
6980
+ bool found_platform_binary = false ;
6979
6981
ModuleList added_modules;
6980
- for (const MachOCorefileImageEntry &image : image_infos.all_image_infos ) {
6981
- ModuleSP module_sp;
6982
+ for (MachOCorefileImageEntry &image : image_infos.all_image_infos ) {
6983
+ ModuleSP module_sp, local_filesystem_module_sp;
6984
+
6985
+ // If this is a platform binary, it has been loaded (or registered with
6986
+ // the DynamicLoader to be loaded), we don't need to do any further
6987
+ // processing. We're not going to call ModulesDidLoad on this in this
6988
+ // method, so notify==true.
6989
+ if (process.GetTarget ()
6990
+ .GetDebugger ()
6991
+ .GetPlatformList ()
6992
+ .LoadPlatformBinaryAndSetup (&process, image.load_address ,
6993
+ true /* notify */ )) {
6994
+ LLDB_LOGF (log,
6995
+ " ObjectFileMachO::%s binary at 0x%" PRIx64
6996
+ " is a platform binary, has been handled by a Platform plugin." ,
6997
+ __FUNCTION__, image.load_address );
6998
+ continue ;
6999
+ }
6982
7000
6983
- if (!image.filename .empty ()) {
6984
- Status error;
7001
+ // If this binary is currently executing, we want to force a
7002
+ // possibly expensive search for the binary and its dSYM.
7003
+ if (image.currently_executing && image.uuid .IsValid ()) {
6985
7004
ModuleSpec module_spec;
6986
7005
module_spec.GetUUID () = image.uuid ;
6987
- module_spec.GetFileSpec () = FileSpec (image.filename .c_str ());
6988
- if (image.currently_executing ) {
6989
- Symbols::DownloadObjectAndSymbolFile (module_spec, error, true );
6990
- if (FileSystem::Instance ().Exists (module_spec.GetFileSpec ())) {
6991
- process.GetTarget ().GetOrCreateModule (module_spec, false );
6992
- }
7006
+ Symbols::DownloadObjectAndSymbolFile (module_spec, error, true );
7007
+ if (FileSystem::Instance ().Exists (module_spec.GetFileSpec ())) {
7008
+ module_sp = process.GetTarget ().GetOrCreateModule (module_spec, false );
7009
+ process.GetTarget ().GetImages ().AppendIfNeeded (module_sp,
7010
+ false /* notify */ );
6993
7011
}
7012
+ }
7013
+
7014
+ // We have an address, that's the best way to discover the binary.
7015
+ if (!module_sp && image.load_address != LLDB_INVALID_ADDRESS) {
7016
+ module_sp = DynamicLoader::LoadBinaryWithUUIDAndAddress (
7017
+ &process, image.filename , image.uuid , image.load_address ,
7018
+ false /* value_is_offset */ , image.currently_executing ,
7019
+ false /* notify */ );
7020
+ }
7021
+
7022
+ // If we have a slide, we need to find the original binary
7023
+ // by UUID, then we can apply the slide value.
7024
+ if (!module_sp && image.uuid .IsValid () &&
7025
+ image.slide != LLDB_INVALID_ADDRESS) {
7026
+ module_sp = DynamicLoader::LoadBinaryWithUUIDAndAddress (
7027
+ &process, image.filename , image.uuid , image.slide ,
7028
+ true /* value_is_offset */ , image.currently_executing ,
7029
+ false /* notify */ );
7030
+ }
7031
+
7032
+ // Try to find the binary by UUID or filename on the local
7033
+ // filesystem or in lldb's global module cache.
7034
+ if (!module_sp) {
7035
+ Status error;
7036
+ ModuleSpec module_spec;
7037
+ if (image.uuid .IsValid ())
7038
+ module_spec.GetUUID () = image.uuid ;
7039
+ if (!image.filename .empty ())
7040
+ module_spec.GetFileSpec () = FileSpec (image.filename .c_str ());
6994
7041
module_sp =
6995
7042
process.GetTarget ().GetOrCreateModule (module_spec, false , &error);
6996
7043
process.GetTarget ().GetImages ().AppendIfNeeded (module_sp,
6997
7044
false /* notify */ );
6998
- } else {
6999
- if (image.load_address != LLDB_INVALID_ADDRESS) {
7000
- module_sp = DynamicLoader::LoadBinaryWithUUIDAndAddress (
7001
- &process, image.uuid , image.load_address ,
7002
- false /* value_is_offset */ , image.currently_executing ,
7003
- false /* notify */ );
7004
- } else if (image.slide != LLDB_INVALID_ADDRESS) {
7005
- module_sp = DynamicLoader::LoadBinaryWithUUIDAndAddress (
7006
- &process, image.uuid , image.slide , true /* value_is_offset */ ,
7007
- image.currently_executing , false /* notify */ );
7008
- }
7009
7045
}
7010
7046
7011
- if (module_sp.get ()) {
7012
- // Will call ModulesDidLoad with all modules once they've all
7013
- // been added to the Target with load addresses. Don't notify
7014
- // here, before the load address is set.
7047
+ // We have a ModuleSP to load in the Target. Load it at the
7048
+ // correct address/slide and notify/load scripting resources.
7049
+ if (module_sp) {
7015
7050
added_modules.Append (module_sp, false /* notify */ );
7051
+
7052
+ // We have a list of segment load address
7016
7053
if (image.segment_load_addresses .size () > 0 ) {
7017
7054
if (log) {
7018
7055
std::string uuidstr = image.uuid .GetAsString ();
@@ -7073,5 +7110,11 @@ bool ObjectFileMachO::LoadCoreFileImages(lldb_private::Process &process) {
7073
7110
process.Flush ();
7074
7111
return true ;
7075
7112
}
7113
+ // Return true if the only binary we found was the platform binary,
7114
+ // and it was loaded outside the scope of this method.
7115
+ if (found_platform_binary)
7116
+ return true ;
7117
+
7118
+ // No binaries.
7076
7119
return false ;
7077
7120
}
0 commit comments