forked from OSchip/llvm-project
[lldb] Make TargetList iterable (NFC)
Make it possible to iterate over the TargetList. Differential revision: https://reviews.llvm.org/D105914
This commit is contained in:
parent
1e4a417ee6
commit
de448c0a9e
|
@ -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 @@ public:
|
|||
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 @@ public:
|
|||
|
||||
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,
|
||||
|
|
|
@ -773,12 +773,9 @@ void Debugger::Clear() {
|
|||
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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue