vsk updated this revision to Diff 303223. vsk added a comment. Delete some dead code.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D90872/new/ https://reviews.llvm.org/D90872 Files: lldb/include/lldb/Target/TargetList.h lldb/source/Target/TargetList.cpp
Index: lldb/source/Target/TargetList.cpp =================================================================== --- lldb/source/Target/TargetList.cpp +++ lldb/source/Target/TargetList.cpp @@ -55,8 +55,8 @@ const OptionGroupPlatform *platform_options, TargetSP &target_sp) { return CreateTargetInternal(debugger, user_exe_path, triple_str, - load_dependent_files, platform_options, target_sp, - false); + load_dependent_files, platform_options, + target_sp); } Status TargetList::CreateTarget(Debugger &debugger, @@ -65,15 +65,24 @@ LoadDependentFiles load_dependent_files, PlatformSP &platform_sp, TargetSP &target_sp) { return CreateTargetInternal(debugger, user_exe_path, specified_arch, - load_dependent_files, platform_sp, target_sp, - false); + load_dependent_files, platform_sp, target_sp); +} + +void TargetList::CreateDummyTarget(Debugger &debugger, ArchSpec arch, + lldb::TargetSP &target_sp) { + assert(!m_dummy_target_sp && "attempted to create a second dummy target"); + const bool is_dummy_target = true; + PlatformSP host_platform_sp(Platform::GetHostPlatform()); + target_sp.reset( + new Target(debugger, arch, host_platform_sp, is_dummy_target)); + // Don't put the dummy target in the target list, it's held separately. + m_dummy_target_sp = target_sp; } Status TargetList::CreateTargetInternal( Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, LoadDependentFiles load_dependent_files, - const OptionGroupPlatform *platform_options, TargetSP &target_sp, - bool is_dummy_target) { + const OptionGroupPlatform *platform_options, TargetSP &target_sp) { Status error; // Let's start by looking at the selected platform. @@ -256,7 +265,7 @@ if (!prefer_platform_arch && arch.IsValid()) { if (!platform_sp->IsCompatibleArchitecture(arch, false, nullptr)) { platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch); - if (!is_dummy_target && platform_sp) + if (platform_sp) debugger.GetPlatformList().SetSelectedPlatform(platform_sp); } } else if (platform_arch.IsValid()) { @@ -266,7 +275,7 @@ if (!platform_sp->IsCompatibleArchitecture(platform_arch, false, nullptr)) { platform_sp = Platform::GetPlatformForArchitecture(platform_arch, &fixed_platform_arch); - if (!is_dummy_target && platform_sp) + if (platform_sp) debugger.GetPlatformList().SetSelectedPlatform(platform_sp); } } @@ -274,45 +283,36 @@ if (!platform_arch.IsValid()) platform_arch = arch; - return TargetList::CreateTargetInternal( - debugger, user_exe_path, platform_arch, load_dependent_files, platform_sp, - target_sp, is_dummy_target); + return TargetList::CreateTargetInternal(debugger, user_exe_path, + platform_arch, load_dependent_files, + platform_sp, target_sp); } lldb::TargetSP TargetList::GetDummyTarget(lldb_private::Debugger &debugger) { // FIXME: Maybe the dummy target should be per-Debugger - if (!m_dummy_target_sp || !m_dummy_target_sp->IsValid()) { + if (!m_dummy_target_sp) { ArchSpec arch(Target::GetDefaultArchitecture()); if (!arch.IsValid()) arch = HostInfo::GetArchitecture(); - Status err = CreateDummyTarget( - debugger, arch.GetTriple().getTriple().c_str(), m_dummy_target_sp); + assert(arch.IsValid() && "No valid default or host archspec"); + CreateDummyTarget(debugger, arch, m_dummy_target_sp); } return m_dummy_target_sp; } -Status TargetList::CreateDummyTarget(Debugger &debugger, - llvm::StringRef specified_arch_name, - lldb::TargetSP &target_sp) { - PlatformSP host_platform_sp(Platform::GetHostPlatform()); - return CreateTargetInternal( - debugger, (const char *)nullptr, specified_arch_name, eLoadDependentsNo, - (const OptionGroupPlatform *)nullptr, target_sp, true); -} - Status TargetList::CreateTargetInternal(Debugger &debugger, llvm::StringRef user_exe_path, const ArchSpec &specified_arch, LoadDependentFiles load_dependent_files, lldb::PlatformSP &platform_sp, - lldb::TargetSP &target_sp, - bool is_dummy_target) { + lldb::TargetSP &target_sp) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer( func_cat, "TargetList::CreateTarget (file = '%s', arch = '%s')", user_exe_path.str().c_str(), specified_arch.GetArchitectureName()); Status error; + const bool is_dummy_target = false; ArchSpec arch(specified_arch); @@ -418,16 +418,11 @@ target_sp->AppendExecutableSearchPaths(file_dir); } - // Don't put the dummy target in the target list, it's held separately. - if (!is_dummy_target) { - std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex); - m_selected_target_idx = m_target_list.size(); - m_target_list.push_back(target_sp); - // Now prime this from the dummy target: - target_sp->PrimeFromDummyTarget(debugger.GetDummyTarget()); - } else { - m_dummy_target_sp = target_sp; - } + std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex); + m_selected_target_idx = m_target_list.size(); + m_target_list.push_back(target_sp); + // Now prime this from the dummy target: + target_sp->PrimeFromDummyTarget(debugger.GetDummyTarget()); return error; } Index: lldb/include/lldb/Target/TargetList.h =================================================================== --- lldb/include/lldb/Target/TargetList.h +++ lldb/include/lldb/Target/TargetList.h @@ -190,21 +190,22 @@ private: lldb::TargetSP GetDummyTarget(lldb_private::Debugger &debugger); - Status CreateDummyTarget(Debugger &debugger, - llvm::StringRef specified_arch_name, - lldb::TargetSP &target_sp); + /// Create a dummy target. Guaranteed to succeed. May only be called once per + /// TargetList. + void CreateDummyTarget(Debugger &debugger, ArchSpec arch, + lldb::TargetSP &target_sp); Status CreateTargetInternal(Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, LoadDependentFiles load_dependent_files, const OptionGroupPlatform *platform_options, - lldb::TargetSP &target_sp, bool is_dummy_target); + lldb::TargetSP &target_sp); Status CreateTargetInternal(Debugger &debugger, llvm::StringRef user_exe_path, const ArchSpec &arch, LoadDependentFiles get_dependent_modules, lldb::PlatformSP &platform_sp, - lldb::TargetSP &target_sp, bool is_dummy_target); + lldb::TargetSP &target_sp); TargetList(const TargetList &) = delete; const TargetList &operator=(const TargetList &) = delete;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits