public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: iterate over targets, not inferiors, to commit resumed
@ 2024-03-01 15:52 Tankut Baris Aktemur
  2024-03-01 19:02 ` Simon Marchi
  0 siblings, 1 reply; 6+ messages in thread
From: Tankut Baris Aktemur @ 2024-03-01 15:52 UTC (permalink / raw)
  To: gdb-patches

When committing resumed threads of targets, iterate over targets, not
inferiors, so that we don't call commit_resumed multiple times for
targets that have multiple inferiors.  This gives more concise code.

Similarly, iterate over targets when setting the commit_resumed_state
of targets.

No behavioral change is expected or intended with this patch.
---
 gdb/infrun.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index bbb98f6dcdb..af9c00d32e3 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3210,16 +3210,10 @@ maybe_set_commit_resumed_all_targets ()
 {
   scoped_restore_current_thread restore_thread;
 
-  for (inferior *inf : all_non_exited_inferiors ())
+  for (auto *proc_target : all_non_exited_process_targets ())
     {
-      process_stratum_target *proc_target = inf->process_target ();
-
       if (proc_target->commit_resumed_state)
-	{
-	  /* We already set this in a previous iteration, via another
-	     inferior sharing the process_stratum target.  */
-	  continue;
-	}
+	continue;
 
       /* If the target has no resumed threads, it would be useless to
 	 ask it to commit the resumed threads.  */
@@ -3243,7 +3237,7 @@ maybe_set_commit_resumed_all_targets ()
 	  continue;
 	}
 
-      switch_to_inferior_no_thread (inf);
+      switch_to_target_no_thread (proc_target);
 
       if (target_has_pending_events ())
 	{
@@ -3267,14 +3261,12 @@ maybe_call_commit_resumed_all_targets ()
 {
   scoped_restore_current_thread restore_thread;
 
-  for (inferior *inf : all_non_exited_inferiors ())
+  for (auto *proc_target : all_non_exited_process_targets ())
     {
-      process_stratum_target *proc_target = inf->process_target ();
-
       if (!proc_target->commit_resumed_state)
 	continue;
 
-      switch_to_inferior_no_thread (inf);
+      switch_to_target_no_thread (proc_target);
 
       infrun_debug_printf ("calling commit_resumed for target %s",
 			   proc_target->shortname());
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


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

end of thread, other threads:[~2024-03-15 15:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-01 15:52 [PATCH] gdb: iterate over targets, not inferiors, to commit resumed Tankut Baris Aktemur
2024-03-01 19:02 ` Simon Marchi
2024-03-04  9:28   ` Aktemur, Tankut Baris
2024-03-04 16:34     ` Simon Marchi
2024-03-12 19:05       ` Aktemur, Tankut Baris
2024-03-15 15:06         ` Simon Marchi

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).