From 73b29de6b97acc477f131d4e26919395e8953f04 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 11 Jan 2021 13:55:27 -0500 Subject: [PATCH] Test returning something else than std::set in all_process_targets Change-Id: Ieb9ab1997824c8d7ef8e2bc998a4131b97b1b434 --- gdb/infrun.c | 8 +++++++- gdb/process-stratum-target.c | 10 +++++----- gdb/process-stratum-target.h | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 92a1102cb59..ab619814420 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2826,6 +2826,8 @@ scoped_disable_commit_resumed::scoped_disable_commit_resumed for (process_stratum_target *target : all_process_targets ()) { + if (target == nullptr) + break; if (scoped_disable_commit_resumed_depth == 0) { /* This is the outermost instance. */ @@ -2860,7 +2862,11 @@ scoped_disable_commit_resumed::~scoped_disable_commit_resumed () /* This is not the outermost instance, we expect COMMIT_RESUMED_STATE to still be false. */ for (process_stratum_target *target : all_process_targets ()) - gdb_assert (!target->commit_resumed_state); + { + if (target == nullptr) + break; + gdb_assert (!target->commit_resumed_state); + } } } diff --git a/gdb/process-stratum-target.c b/gdb/process-stratum-target.c index 9877f0d8193..184450e99f9 100644 --- a/gdb/process-stratum-target.c +++ b/gdb/process-stratum-target.c @@ -99,16 +99,16 @@ all_non_exited_process_targets () /* See process-stratum-target.h. */ -std::set +std::array all_process_targets () { - /* Inferiors may share targets. To eliminate duplicates, use a set. */ - std::set targets; + std::array array; + array[0] = nullptr; for (inferior *inf : all_inferiors ()) if (inf->process_target () != nullptr) - targets.insert (inf->process_target ()); + array[0] = inf->process_target (); - return targets; + return array; } /* See process-stratum-target.h. */ diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h index 3cea911dee0..c387c0ec11d 100644 --- a/gdb/process-stratum-target.h +++ b/gdb/process-stratum-target.h @@ -123,7 +123,7 @@ extern std::set all_non_exited_process_targets (); /* Return a collection of all existing process stratum targets. */ -extern std::set all_process_targets (); +extern std::array all_process_targets (); /* Switch to the first inferior (and program space) of TARGET, and switch to no thread selected. */ -- 2.29.2