public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] gdb: introduce 'all_non_exited_process_targets' and 'switch_to_target_no_thread'
@ 2020-05-03 15:37 Tankut Baris Aktemur
  2020-05-12 22:29 ` Christian Biesinger
  0 siblings, 1 reply; 4+ messages in thread
From: Tankut Baris Aktemur @ 2020-05-03 15:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

Introduce two new convenience functions:

1. all_non_exited_process_targets: returns a collection of all process
stratum targets that have non-exited inferiors on them.  Useful for
iterating targets.

2. switch_to_target_no_thread: switch the context to the first
inferior of the given target, and to no selected thread.

gdb/ChangeLog:
2020-04-30  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* process-stratum-target.h (all_non_exited_process_targets): New
	function declaration.
	(switch_to_target_no_thread): New function declaration.
	* process-stratum-target.c (all_non_exited_process_targets): New
	function implementation.
	(switch_to_target_no_thread): New function implementation.
---
 gdb/process-stratum-target.c | 25 +++++++++++++++++++++++++
 gdb/process-stratum-target.h |  9 +++++++++
 2 files changed, 34 insertions(+)

diff --git a/gdb/process-stratum-target.c b/gdb/process-stratum-target.c
index f3fd9ee905d..b9ea5007273 100644
--- a/gdb/process-stratum-target.c
+++ b/gdb/process-stratum-target.c
@@ -20,6 +20,7 @@
 #include "defs.h"
 #include "process-stratum-target.h"
 #include "inferior.h"
+#include <set>
 
 process_stratum_target::~process_stratum_target ()
 {
@@ -83,3 +84,27 @@ process_stratum_target::has_execution (inferior *inf)
      through hoops.  */
   return inf->pid != 0;
 }
+
+/* See process-stratum-target.h.  */
+
+std::set<process_stratum_target *>
+all_non_exited_process_targets ()
+{
+  std::set<process_stratum_target *> targets;
+  for (inferior *inf : all_non_exited_inferiors ())
+    targets.insert (inf->process_target ());
+
+  return targets;
+}
+
+/* See process-stratum-target.h.  */
+
+void
+switch_to_target_no_thread (process_stratum_target *target)
+{
+  for (inferior *inf : all_inferiors (target))
+    {
+      switch_to_inferior_no_thread (inf);
+      break;
+    }
+}
diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h
index 1be02100dcf..6cf99099a24 100644
--- a/gdb/process-stratum-target.h
+++ b/gdb/process-stratum-target.h
@@ -82,4 +82,13 @@ as_process_stratum_target (target_ops *target)
   return static_cast<process_stratum_target *> (target);
 }
 
+/* Return a collection of targets that have non-exited inferiors.  */
+
+extern std::set<process_stratum_target *> all_non_exited_process_targets ();
+
+/* Switch to the first inferior (and program space) of TARGET, and
+   switch to no thread selected.  */
+
+extern void switch_to_target_no_thread (process_stratum_target *target);
+
 #endif /* !defined (PROCESS_STRATUM_TARGET_H) */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-13 18:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-03 15:37 [PATCH 1/2] gdb: introduce 'all_non_exited_process_targets' and 'switch_to_target_no_thread' Tankut Baris Aktemur
2020-05-12 22:29 ` Christian Biesinger
2020-05-13  8:26   ` Aktemur, Tankut Baris
2020-05-13 18:43     ` Christian Biesinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).