Re: [PATCH 2/2] gdb: share some thread proceed related code between CLI and MI

Tom de Vries <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
On 8/6/26 10:54 PM, Andrew Burgess wrote:
> +	  if (inf == nullptr)
> +	    proceed_all_threads ();
> +	  else
> +	    {
> +	      for (thread_info &thread : inf->threads ())
> +		proceed_one_thread (thread);
>   	    }

FWIW, also I wonder if it makes sense to fold this logic into 
proceed_all_threads:
...
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 23e93587874..d2301ddf093 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -743,10 +743,18 @@ proceed_one_thread (thread_info &thread)
  /* See inferior.h.  */

  void
-proceed_all_threads ()
+proceed_all_threads (inferior *inf)
  {
    gdb_assert (non_stop);

+  if (inf != nullptr)
+    {
+      for (thread_info &thread : inf->threads ())
+	proceed_one_thread (thread);
+
+      return;
+    }
+
    for (thread_info &thread : all_threads ())
      {
        /* We go through all threads individually instead of compressing
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 8255654d9b8..2067f60ab7d 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -230,7 +230,7 @@ extern void continue_1 (bool all_threads_p);
  /* For use only when non_stop is true.  Proceed all threads in every
     inferior.  */

-extern void proceed_all_threads ();
+extern void proceed_all_threads (inferior *inf = nullptr);

  /* For use only when non_stop is true.  If THREAD is stopped, and is in an
     inferior that has_execution then switch to THREAD, clear its proceed
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index e110b029e1e..1eb087b85db 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -259,13 +259,7 @@ exec_continue (const char *const *argv, int argc)
  	  if (!current_context->all)
  	    inf = find_inferior_id (current_context->thread_group);

-	  if (inf == nullptr)
-	    proceed_all_threads ();
-	  else
-	    {
-	      for (thread_info &thread : inf->threads ())
-		proceed_one_thread (thread);
-	    }
+	  proceed_all_threads (inf);

  	  disable_commit_resumed.reset_and_commit ();
  	}
...

Thanks,
- Tom
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.