[Lldb-commits] [PATCH] D105914: [lldb] Make TargetList iterable
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 14 13:36:10 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGde448c0a9e50: [lldb] Make TargetList iterable (NFC) (authored by JDevlieghere).
Herald added a project: LLDB.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105914/new/
https://reviews.llvm.org/D105914
Files:
lldb/include/lldb/Target/TargetList.h
lldb/source/Core/Debugger.cpp
Index: lldb/source/Core/Debugger.cpp
===================================================================
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -773,12 +773,9 @@
StopIOHandlerThread();
StopEventHandlerThread();
m_listener_sp->Clear();
- int num_targets = m_target_list.GetNumTargets();
- for (int i = 0; i < num_targets; i++) {
- TargetSP target_sp(m_target_list.GetTargetAtIndex(i));
+ for (TargetSP target_sp : m_target_list.Targets()) {
if (target_sp) {
- ProcessSP process_sp(target_sp->GetProcessSP());
- if (process_sp)
+ if (ProcessSP process_sp = target_sp->GetProcessSP())
process_sp->Finalize();
target_sp->Destroy();
}
Index: lldb/include/lldb/Target/TargetList.h
===================================================================
--- lldb/include/lldb/Target/TargetList.h
+++ lldb/include/lldb/Target/TargetList.h
@@ -14,6 +14,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/Broadcaster.h"
+#include "lldb/Utility/Iterable.h"
namespace lldb_private {
@@ -42,6 +43,11 @@
return GetStaticBroadcasterClass();
}
+ typedef std::vector<lldb::TargetSP> collection;
+ typedef LockingAdaptedIterable<collection, lldb::TargetSP, vector_adapter,
+ std::recursive_mutex>
+ TargetIterable;
+
/// Create a new Target.
///
/// Clients must use this function to create a Target. This allows
@@ -179,14 +185,15 @@
lldb::TargetSP GetSelectedTarget();
-protected:
- typedef std::vector<lldb::TargetSP> collection;
- // Member variables.
+ TargetIterable Targets() {
+ return TargetIterable(m_target_list, m_target_list_mutex);
+ }
+
+private:
collection m_target_list;
mutable std::recursive_mutex m_target_list_mutex;
uint32_t m_selected_target_idx;
-private:
static Status CreateTargetInternal(
Debugger &debugger, llvm::StringRef user_exe_path,
llvm::StringRef triple_str, LoadDependentFiles load_dependent_files,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105914.358730.patch
Type: text/x-patch
Size: 2048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210714/2482746a/attachment.bin>
More information about the lldb-commits
mailing list