Skip to content

Commit 8760017

Browse files
committed
Merge commit 'b618cf7a378d' from llvm.org/release/11.x into apple/stable/20200714
2 parents 8711013 + b618cf7 commit 8760017

File tree

13 files changed

+165
-112
lines changed

13 files changed

+165
-112
lines changed

lldb/include/lldb/Core/ModuleList.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,11 @@ class ModuleList {
443443

444444
static bool ModuleIsInCache(const Module *module_ptr);
445445

446-
static Status GetSharedModule(const ModuleSpec &module_spec,
447-
lldb::ModuleSP &module_sp,
448-
const FileSpecList *module_search_paths_ptr,
449-
lldb::ModuleSP *old_module_sp_ptr,
450-
bool *did_create_ptr,
451-
bool always_create = false);
446+
static Status
447+
GetSharedModule(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
448+
const FileSpecList *module_search_paths_ptr,
449+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
450+
bool *did_create_ptr, bool always_create = false);
452451

453452
static bool RemoveSharedModule(lldb::ModuleSP &module_sp);
454453

lldb/include/lldb/Target/Platform.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,10 @@ class Platform : public PluginInterface {
301301
LocateExecutableScriptingResources(Target *target, Module &module,
302302
Stream *feedback_stream);
303303

304-
virtual Status GetSharedModule(const ModuleSpec &module_spec,
305-
Process *process, lldb::ModuleSP &module_sp,
306-
const FileSpecList *module_search_paths_ptr,
307-
lldb::ModuleSP *old_module_sp_ptr,
308-
bool *did_create_ptr);
304+
virtual Status GetSharedModule(
305+
const ModuleSpec &module_spec, Process *process,
306+
lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr,
307+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr);
309308

310309
virtual bool GetModuleSpec(const FileSpec &module_file_spec,
311310
const ArchSpec &arch, ModuleSpec &module_spec);

lldb/source/Core/ModuleList.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,11 @@ size_t ModuleList::RemoveOrphanSharedModules(bool mandatory) {
732732
return GetSharedModuleList().RemoveOrphans(mandatory);
733733
}
734734

735-
Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
736-
ModuleSP &module_sp,
737-
const FileSpecList *module_search_paths_ptr,
738-
ModuleSP *old_module_sp_ptr,
739-
bool *did_create_ptr, bool always_create) {
735+
Status
736+
ModuleList::GetSharedModule(const ModuleSpec &module_spec, ModuleSP &module_sp,
737+
const FileSpecList *module_search_paths_ptr,
738+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
739+
bool *did_create_ptr, bool always_create) {
740740
ModuleList &shared_module_list = GetSharedModuleList();
741741
std::lock_guard<std::recursive_mutex> guard(
742742
shared_module_list.m_modules_mutex);
@@ -748,8 +748,6 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
748748

749749
if (did_create_ptr)
750750
*did_create_ptr = false;
751-
if (old_module_sp_ptr)
752-
old_module_sp_ptr->reset();
753751

754752
const UUID *uuid_ptr = module_spec.GetUUIDPtr();
755753
const FileSpec &module_file_spec = module_spec.GetFileSpec();
@@ -770,8 +768,8 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
770768

771769
// Make sure the file for the module hasn't been modified
772770
if (module_sp->FileHasChanged()) {
773-
if (old_module_sp_ptr && !*old_module_sp_ptr)
774-
*old_module_sp_ptr = module_sp;
771+
if (old_modules)
772+
old_modules->push_back(module_sp);
775773

776774
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES));
777775
if (log != nullptr)
@@ -925,8 +923,8 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
925923
located_binary_modulespec.GetFileSpec());
926924
if (file_spec_mod_time != llvm::sys::TimePoint<>()) {
927925
if (file_spec_mod_time != module_sp->GetModificationTime()) {
928-
if (old_module_sp_ptr)
929-
*old_module_sp_ptr = module_sp;
926+
if (old_modules)
927+
old_modules->push_back(module_sp);
930928
shared_module_list.Remove(module_sp);
931929
module_sp.reset();
932930
}

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ BringInRemoteFile(Platform *platform,
221221
lldb_private::Status PlatformDarwin::GetSharedModuleWithLocalCache(
222222
const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
223223
const lldb_private::FileSpecList *module_search_paths_ptr,
224-
lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr) {
224+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr) {
225225

226226
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
227227
LLDB_LOGF(log,
@@ -262,7 +262,7 @@ lldb_private::Status PlatformDarwin::GetSharedModuleWithLocalCache(
262262
}
263263

264264
err = ModuleList::GetSharedModule(module_spec, module_sp,
265-
module_search_paths_ptr, old_module_sp_ptr,
265+
module_search_paths_ptr, old_modules,
266266
did_create_ptr);
267267
if (module_sp)
268268
return err;
@@ -365,8 +365,8 @@ lldb_private::Status PlatformDarwin::GetSharedModuleWithLocalCache(
365365

366366
Status PlatformDarwin::GetSharedModule(
367367
const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
368-
const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
369-
bool *did_create_ptr) {
368+
const FileSpecList *module_search_paths_ptr,
369+
llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
370370
Status error;
371371
module_sp.reset();
372372

@@ -375,16 +375,16 @@ Status PlatformDarwin::GetSharedModule(
375375
// module first.
376376
if (m_remote_platform_sp) {
377377
error = m_remote_platform_sp->GetSharedModule(
378-
module_spec, process, module_sp, module_search_paths_ptr,
379-
old_module_sp_ptr, did_create_ptr);
378+
module_spec, process, module_sp, module_search_paths_ptr, old_modules,
379+
did_create_ptr);
380380
}
381381
}
382382

383383
if (!module_sp) {
384384
// Fall back to the local platform and find the file locally
385385
error = Platform::GetSharedModule(module_spec, process, module_sp,
386-
module_search_paths_ptr,
387-
old_module_sp_ptr, did_create_ptr);
386+
module_search_paths_ptr, old_modules,
387+
did_create_ptr);
388388

389389
const FileSpec &platform_file = module_spec.GetFileSpec();
390390
if (!module_sp && module_search_paths_ptr && platform_file) {
@@ -397,7 +397,7 @@ Status PlatformDarwin::GetSharedModule(
397397
new_module_spec.GetFileSpec() = bundle_directory;
398398
if (Host::ResolveExecutableInBundle(new_module_spec.GetFileSpec())) {
399399
Status new_error(Platform::GetSharedModule(
400-
new_module_spec, process, module_sp, nullptr, old_module_sp_ptr,
400+
new_module_spec, process, module_sp, nullptr, old_modules,
401401
did_create_ptr));
402402

403403
if (module_sp)
@@ -424,8 +424,8 @@ Status PlatformDarwin::GetSharedModule(
424424
ModuleSpec new_module_spec(module_spec);
425425
new_module_spec.GetFileSpec() = new_file_spec;
426426
Status new_error(Platform::GetSharedModule(
427-
new_module_spec, process, module_sp, nullptr,
428-
old_module_sp_ptr, did_create_ptr));
427+
new_module_spec, process, module_sp, nullptr, old_modules,
428+
did_create_ptr));
429429

430430
if (module_sp) {
431431
module_sp->SetPlatformFileSpec(new_file_spec);
@@ -1683,8 +1683,8 @@ PlatformDarwin::LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) {
16831683

16841684
lldb_private::Status PlatformDarwin::FindBundleBinaryInExecSearchPaths(
16851685
const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
1686-
const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
1687-
bool *did_create_ptr) {
1686+
const FileSpecList *module_search_paths_ptr,
1687+
llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
16881688
const FileSpec &platform_file = module_spec.GetFileSpec();
16891689
// See if the file is present in any of the module_search_paths_ptr
16901690
// directories.
@@ -1741,9 +1741,9 @@ lldb_private::Status PlatformDarwin::FindBundleBinaryInExecSearchPaths(
17411741
if (FileSystem::Instance().Exists(path_to_try)) {
17421742
ModuleSpec new_module_spec(module_spec);
17431743
new_module_spec.GetFileSpec() = path_to_try;
1744-
Status new_error(Platform::GetSharedModule(
1745-
new_module_spec, process, module_sp, nullptr, old_module_sp_ptr,
1746-
did_create_ptr));
1744+
Status new_error(
1745+
Platform::GetSharedModule(new_module_spec, process, module_sp,
1746+
nullptr, old_modules, did_create_ptr));
17471747

17481748
if (module_sp) {
17491749
module_sp->SetPlatformFileSpec(path_to_try);

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class PlatformDarwin : public PlatformPOSIX {
4646
GetSharedModule(const lldb_private::ModuleSpec &module_spec,
4747
lldb_private::Process *process, lldb::ModuleSP &module_sp,
4848
const lldb_private::FileSpecList *module_search_paths_ptr,
49-
lldb::ModuleSP *old_module_sp_ptr,
49+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
5050
bool *did_create_ptr) override;
5151

5252
size_t GetSoftwareBreakpointTrapOpcode(
@@ -132,7 +132,7 @@ class PlatformDarwin : public PlatformPOSIX {
132132
virtual lldb_private::Status GetSharedModuleWithLocalCache(
133133
const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
134134
const lldb_private::FileSpecList *module_search_paths_ptr,
135-
lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr);
135+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr);
136136

137137
struct SDKEnumeratorInfo {
138138
lldb_private::FileSpec found_path;
@@ -158,7 +158,7 @@ class PlatformDarwin : public PlatformPOSIX {
158158
const lldb_private::ModuleSpec &module_spec,
159159
lldb_private::Process *process, lldb::ModuleSP &module_sp,
160160
const lldb_private::FileSpecList *module_search_paths_ptr,
161-
lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr);
161+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr);
162162

163163
static std::string FindComponentInPath(llvm::StringRef path,
164164
llvm::StringRef component);

lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,8 @@ PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(FileSpec dsym_bundle) {
727727

728728
Status PlatformDarwinKernel::GetSharedModule(
729729
const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
730-
const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
731-
bool *did_create_ptr) {
730+
const FileSpecList *module_search_paths_ptr,
731+
llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
732732
Status error;
733733
module_sp.reset();
734734
const FileSpec &platform_file = module_spec.GetFileSpec();
@@ -740,26 +740,26 @@ Status PlatformDarwinKernel::GetSharedModule(
740740
if (!kext_bundle_id.empty() && module_spec.GetUUID().IsValid()) {
741741
if (kext_bundle_id == "mach_kernel") {
742742
return GetSharedModuleKernel(module_spec, process, module_sp,
743-
module_search_paths_ptr, old_module_sp_ptr,
743+
module_search_paths_ptr, old_modules,
744744
did_create_ptr);
745745
} else {
746746
return GetSharedModuleKext(module_spec, process, module_sp,
747-
module_search_paths_ptr, old_module_sp_ptr,
747+
module_search_paths_ptr, old_modules,
748748
did_create_ptr);
749749
}
750750
} else {
751751
// Give the generic methods, including possibly calling into DebugSymbols
752752
// framework on macOS systems, a chance.
753753
return PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
754-
module_search_paths_ptr,
755-
old_module_sp_ptr, did_create_ptr);
754+
module_search_paths_ptr, old_modules,
755+
did_create_ptr);
756756
}
757757
}
758758

759759
Status PlatformDarwinKernel::GetSharedModuleKext(
760760
const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
761-
const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
762-
bool *did_create_ptr) {
761+
const FileSpecList *module_search_paths_ptr,
762+
llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
763763
Status error;
764764
module_sp.reset();
765765
const FileSpec &platform_file = module_spec.GetFileSpec();
@@ -785,8 +785,8 @@ Status PlatformDarwinKernel::GetSharedModuleKext(
785785
// Give the generic methods, including possibly calling into DebugSymbols
786786
// framework on macOS systems, a chance.
787787
error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
788-
module_search_paths_ptr,
789-
old_module_sp_ptr, did_create_ptr);
788+
module_search_paths_ptr, old_modules,
789+
did_create_ptr);
790790
if (error.Success() && module_sp.get()) {
791791
return error;
792792
}
@@ -811,8 +811,8 @@ Status PlatformDarwinKernel::GetSharedModuleKext(
811811

812812
Status PlatformDarwinKernel::GetSharedModuleKernel(
813813
const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
814-
const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
815-
bool *did_create_ptr) {
814+
const FileSpecList *module_search_paths_ptr,
815+
llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
816816
Status error;
817817
module_sp.reset();
818818

@@ -878,8 +878,8 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
878878
// Give the generic methods, including possibly calling into DebugSymbols
879879
// framework on macOS systems, a chance.
880880
error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp,
881-
module_search_paths_ptr,
882-
old_module_sp_ptr, did_create_ptr);
881+
module_search_paths_ptr, old_modules,
882+
did_create_ptr);
883883
if (error.Success() && module_sp.get()) {
884884
return error;
885885
}

lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class PlatformDarwinKernel : public PlatformDarwin {
5757
GetSharedModule(const lldb_private::ModuleSpec &module_spec,
5858
lldb_private::Process *process, lldb::ModuleSP &module_sp,
5959
const lldb_private::FileSpecList *module_search_paths_ptr,
60-
lldb::ModuleSP *old_module_sp_ptr,
60+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
6161
bool *did_create_ptr) override;
6262

6363
bool GetSupportedArchitectureAtIndex(uint32_t idx,

lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ lldb_private::Status PlatformMacOSX::GetSharedModule(
157157
const lldb_private::ModuleSpec &module_spec, Process *process,
158158
lldb::ModuleSP &module_sp,
159159
const lldb_private::FileSpecList *module_search_paths_ptr,
160-
lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr) {
161-
Status error = GetSharedModuleWithLocalCache(
162-
module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
163-
did_create_ptr);
160+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr) {
161+
Status error = GetSharedModuleWithLocalCache(module_spec, module_sp,
162+
module_search_paths_ptr,
163+
old_modules, did_create_ptr);
164164

165165
if (module_sp) {
166166
if (module_spec.GetArchitecture().GetCore() ==
@@ -171,15 +171,16 @@ lldb_private::Status PlatformMacOSX::GetSharedModule(
171171
ModuleSpec module_spec_x86_64(module_spec);
172172
module_spec_x86_64.GetArchitecture() = ArchSpec("x86_64-apple-macosx");
173173
lldb::ModuleSP x86_64_module_sp;
174-
lldb::ModuleSP old_x86_64_module_sp;
174+
llvm::SmallVector<lldb::ModuleSP, 1> old_x86_64_modules;
175175
bool did_create = false;
176176
Status x86_64_error = GetSharedModuleWithLocalCache(
177177
module_spec_x86_64, x86_64_module_sp, module_search_paths_ptr,
178-
&old_x86_64_module_sp, &did_create);
178+
&old_x86_64_modules, &did_create);
179179
if (x86_64_module_sp && x86_64_module_sp->GetObjectFile()) {
180180
module_sp = x86_64_module_sp;
181-
if (old_module_sp_ptr)
182-
*old_module_sp_ptr = old_x86_64_module_sp;
181+
if (old_modules)
182+
old_modules->append(old_x86_64_modules.begin(),
183+
old_x86_64_modules.end());
183184
if (did_create_ptr)
184185
*did_create_ptr = did_create;
185186
return x86_64_error;
@@ -189,7 +190,9 @@ lldb_private::Status PlatformMacOSX::GetSharedModule(
189190
}
190191

191192
if (!module_sp) {
192-
error = FindBundleBinaryInExecSearchPaths (module_spec, process, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
193+
error = FindBundleBinaryInExecSearchPaths(module_spec, process, module_sp,
194+
module_search_paths_ptr,
195+
old_modules, did_create_ptr);
193196
}
194197
return error;
195198
}

lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class PlatformMacOSX : public PlatformDarwin {
4040
GetSharedModule(const lldb_private::ModuleSpec &module_spec,
4141
lldb_private::Process *process, lldb::ModuleSP &module_sp,
4242
const lldb_private::FileSpecList *module_search_paths_ptr,
43-
lldb::ModuleSP *old_module_sp_ptr,
43+
llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules,
4444
bool *did_create_ptr) override;
4545

4646
const char *GetDescription() override { return GetDescriptionStatic(); }

lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ Status PlatformRemoteDarwinDevice::GetSymbolFile(const FileSpec &platform_file,
499499

500500
Status PlatformRemoteDarwinDevice::GetSharedModule(
501501
const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
502-
const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
503-
bool *did_create_ptr) {
502+
const FileSpecList *module_search_paths_ptr,
503+
llvm::SmallVectorImpl<ModuleSP> *old_modules, bool *did_create_ptr) {
504504
// For iOS, the SDK files are all cached locally on the host system. So first
505505
// we ask for the file in the cached SDK, then we attempt to get a shared
506506
// module for the right architecture with the right UUID.
@@ -603,24 +603,25 @@ Status PlatformRemoteDarwinDevice::GetSharedModule(
603603
// This may not be an SDK-related module. Try whether we can bring in the
604604
// thing to our local cache.
605605
error = GetSharedModuleWithLocalCache(module_spec, module_sp,
606-
module_search_paths_ptr,
607-
old_module_sp_ptr, did_create_ptr);
606+
module_search_paths_ptr, old_modules,
607+
did_create_ptr);
608608
if (error.Success())
609609
return error;
610610

611611
// See if the file is present in any of the module_search_paths_ptr
612612
// directories.
613613
if (!module_sp)
614-
error = PlatformDarwin::FindBundleBinaryInExecSearchPaths (module_spec, process, module_sp,
615-
module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
614+
error = PlatformDarwin::FindBundleBinaryInExecSearchPaths(
615+
module_spec, process, module_sp, module_search_paths_ptr, old_modules,
616+
did_create_ptr);
616617

617618
if (error.Success())
618619
return error;
619620

620621
const bool always_create = false;
621-
error = ModuleList::GetSharedModule(
622-
module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr,
623-
did_create_ptr, always_create);
622+
error = ModuleList::GetSharedModule(module_spec, module_sp,
623+
module_search_paths_ptr, old_modules,
624+
did_create_ptr, always_create);
624625

625626
if (module_sp)
626627
module_sp->SetPlatformFileSpec(platform_file);

0 commit comments

Comments
 (0)