13
13
#include " lldb/Core/Module.h"
14
14
#include " lldb/Core/ModuleSpec.h"
15
15
#include " lldb/Core/PluginManager.h"
16
+ #include " lldb/Core/Progress.h"
16
17
#include " lldb/Core/Section.h"
17
18
#include " lldb/Interpreter/OptionValueProperties.h"
18
19
#include " lldb/Symbol/ObjectFile.h"
@@ -714,7 +715,7 @@ void DynamicLoaderDarwinKernel::KextImageInfo::SetIsKernel(bool is_kernel) {
714
715
}
715
716
716
717
bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule (
717
- Process *process) {
718
+ Process *process, Progress *progress ) {
718
719
Log *log = GetLog (LLDBLog::DynamicLoader);
719
720
if (IsLoaded ())
720
721
return true ;
@@ -757,11 +758,37 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
757
758
const ModuleList &target_images = target.GetImages ();
758
759
m_module_sp = target_images.FindModule (m_uuid);
759
760
761
+ StreamString prog_str;
762
+ // 'mach_kernel' is a fake name we make up to find kernels
763
+ // that were located by the local filesystem scan.
764
+ if (GetName () != " mach_kernel" )
765
+ prog_str << GetName () << " " ;
766
+ if (GetUUID ().IsValid ())
767
+ prog_str << GetUUID ().GetAsString () << " " ;
768
+ if (GetLoadAddress () != LLDB_INVALID_ADDRESS) {
769
+ prog_str << " at 0x" ;
770
+ prog_str.PutHex64 (GetLoadAddress ());
771
+ }
772
+
773
+ std::unique_ptr<Progress> progress_up;
774
+ if (progress)
775
+ progress->Increment (1 , prog_str.GetString ().str ());
776
+ else {
777
+ if (IsKernel ())
778
+ progress_up = std::make_unique<Progress>(" Loading kernel" ,
779
+ prog_str.GetString ().str ());
780
+ else
781
+ progress_up = std::make_unique<Progress>(" Loading kext" ,
782
+ prog_str.GetString ().str ());
783
+ }
784
+
760
785
// Search for the kext on the local filesystem via the UUID
761
786
if (!m_module_sp && m_uuid.IsValid ()) {
762
787
ModuleSpec module_spec;
763
788
module_spec.GetUUID () = m_uuid;
764
- module_spec.GetArchitecture () = target.GetArchitecture ();
789
+ if (!m_uuid.IsValid ())
790
+ module_spec.GetArchitecture () = target.GetArchitecture ();
791
+ module_spec.GetFileSpec () = FileSpec (m_name);
765
792
766
793
// If the current platform is PlatformDarwinKernel, create a ModuleSpec
767
794
// with the filename set to be the bundle ID for this kext, e.g.
@@ -770,17 +797,9 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
770
797
// system.
771
798
PlatformSP platform_sp (target.GetPlatform ());
772
799
if (platform_sp) {
773
- static ConstString g_platform_name (
774
- PlatformDarwinKernel::GetPluginNameStatic ());
775
- if (platform_sp->GetPluginName () == g_platform_name.GetStringRef ()) {
776
- ModuleSpec kext_bundle_module_spec (module_spec);
777
- FileSpec kext_filespec (m_name.c_str ());
778
- FileSpecList search_paths = target.GetExecutableSearchPaths ();
779
- kext_bundle_module_spec.GetFileSpec () = kext_filespec;
780
- platform_sp->GetSharedModule (kext_bundle_module_spec, process,
781
- m_module_sp, &search_paths, nullptr ,
782
- nullptr );
783
- }
800
+ FileSpecList search_paths = target.GetExecutableSearchPaths ();
801
+ platform_sp->GetSharedModule (module_spec, process, m_module_sp,
802
+ &search_paths, nullptr , nullptr );
784
803
}
785
804
786
805
// Ask the Target to find this file on the local system, if possible.
@@ -1058,12 +1077,9 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() {
1058
1077
}
1059
1078
}
1060
1079
}
1061
-
1062
- if (m_kernel.GetLoadAddress () != LLDB_INVALID_ADDRESS) {
1063
- if (!m_kernel.LoadImageUsingMemoryModule (m_process)) {
1080
+ if (m_kernel.GetLoadAddress () != LLDB_INVALID_ADDRESS)
1081
+ if (!m_kernel.LoadImageUsingMemoryModule (m_process))
1064
1082
m_kernel.LoadImageAtFileAddress (m_process);
1065
- }
1066
- }
1067
1083
1068
1084
// The operating system plugin gets loaded and initialized in
1069
1085
// LoadImageUsingMemoryModule when we discover the kernel dSYM. For a core
@@ -1347,19 +1363,18 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries(
1347
1363
std::vector<std::pair<std::string, UUID>> kexts_failed_to_load;
1348
1364
if (number_of_new_kexts_being_added > 0 ) {
1349
1365
ModuleList loaded_module_list;
1366
+ Progress progress (" Loading kext" , " " , number_of_new_kexts_being_added);
1350
1367
1351
1368
const uint32_t num_of_new_kexts = kext_summaries.size ();
1352
1369
for (uint32_t new_kext = 0 ; new_kext < num_of_new_kexts; new_kext++) {
1353
1370
if (to_be_added[new_kext]) {
1354
1371
KextImageInfo &image_info = kext_summaries[new_kext];
1355
- bool kext_successfully_added = true ;
1356
1372
if (load_kexts) {
1357
- if (!image_info.LoadImageUsingMemoryModule (m_process)) {
1373
+ if (!image_info.LoadImageUsingMemoryModule (m_process, &progress )) {
1358
1374
kexts_failed_to_load.push_back (std::pair<std::string, UUID>(
1359
1375
kext_summaries[new_kext].GetName (),
1360
1376
kext_summaries[new_kext].GetUUID ()));
1361
1377
image_info.LoadImageAtFileAddress (m_process);
1362
- kext_successfully_added = false ;
1363
1378
}
1364
1379
}
1365
1380
@@ -1369,13 +1384,6 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries(
1369
1384
m_process->GetStopID () == image_info.GetProcessStopId ())
1370
1385
loaded_module_list.AppendIfNeeded (image_info.GetModule ());
1371
1386
1372
- if (load_kexts) {
1373
- if (kext_successfully_added)
1374
- s.Printf (" ." );
1375
- else
1376
- s.Printf (" -" );
1377
- }
1378
-
1379
1387
if (log)
1380
1388
kext_summaries[new_kext].PutToLog (log);
1381
1389
}
0 commit comments