[PATCHv2,08/13] Revert "gdb: remove unnecessary parameter wait_ptid from do_target_wait"

Message ID 60af9af218f6b6753fec0a9bca8c78b91d54f41e.1674058360.git.aburgess@redhat.com
State New
Headers
Series Infcalls from B/P conditions in multi-threaded inferiors |

Commit Message

Andrew Burgess Jan. 18, 2023, 4:18 p.m. UTC
  This reverts commit ac0d67ed1dcf470bad6a3bc4800c2ddc9bedecca.

There was nothing wrong with the commit which I'm reverting here, but
it removed some functionality that will be needed for a later commit;
that is, the ability for GDB to ask for events from a specific ptid_t
via the do_target_wait function.

In a follow up commit, this functionality will be used to implement
inferior function calls in multi-threaded inferiors.
---
 gdb/infrun.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
  

Comments

Terekhov, Mikhail via Gdb-patches Jan. 19, 2023, 11:05 a.m. UTC | #1
On Wednesday, January 18, 2023 5:18 PM, Andrew Burgess wrote:
> This reverts commit ac0d67ed1dcf470bad6a3bc4800c2ddc9bedecca.
> 
> There was nothing wrong with the commit which I'm reverting here, but
> it removed some functionality that will be needed for a later commit;
> that is, the ability for GDB to ask for events from a specific ptid_t
> via the do_target_wait function.
> 
> In a follow up commit, this functionality will be used to implement
> inferior function calls in multi-threaded inferiors.
> ---
>  gdb/infrun.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index edfb5ab0a91..5af8635a1ab 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -3741,7 +3741,8 @@ do_target_wait_1 (inferior *inf, ptid_t ptid,
>     more events.  Polls for events from all inferiors/targets.  */
> 
>  static bool
> -do_target_wait (execution_control_state *ecs, target_wait_flags options)
> +do_target_wait (ptid_t wait_ptid, execution_control_state *ecs,
> +		target_wait_flags options)
>  {
>    int num_inferiors = 0;
>    int random_selector;
> @@ -3751,9 +3752,10 @@ do_target_wait (execution_control_state *ecs, target_wait_flags
> options)
>       polling the rest of the inferior list starting from that one in a
>       circular fashion until the whole list is polled once.  */
> 
> -  auto inferior_matches = [] (inferior *inf)
> +  auto inferior_matches = [&wait_ptid] (inferior *inf)
>      {
> -      return inf->process_target () != nullptr;
> +      return (inf->process_target () != NULL

Can we please preserve nullptr instead of reverting back to NULL?

> +	      && ptid_t (inf->pid).matches (wait_ptid));
>      };
> 
>    /* First see how many matching inferiors we have.  */
> @@ -3792,7 +3794,7 @@ do_target_wait (execution_control_state *ecs, target_wait_flags
> options)
> 
>    auto do_wait = [&] (inferior *inf)
>    {
> -    ecs->ptid = do_target_wait_1 (inf, minus_one_ptid, &ecs->ws, options);
> +    ecs->ptid = do_target_wait_1 (inf, wait_ptid, &ecs->ws, options);
>      ecs->target = inf->process_target ();
>      return (ecs->ws.kind () != TARGET_WAITKIND_IGNORE);
>    };
> @@ -4169,7 +4171,7 @@ fetch_inferior_event ()
>         the event.  */
>      scoped_disable_commit_resumed disable_commit_resumed ("handling event");
> 
> -    if (!do_target_wait (&ecs, TARGET_WNOHANG))
> +    if (!do_target_wait (minus_one_ptid, &ecs, TARGET_WNOHANG))
>        {
>  	infrun_debug_printf ("do_target_wait returned no event");
>  	disable_commit_resumed.reset_and_commit ();
> --
> 2.25.4

Regards
-Baris


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
  

Patch

diff --git a/gdb/infrun.c b/gdb/infrun.c
index edfb5ab0a91..5af8635a1ab 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3741,7 +3741,8 @@  do_target_wait_1 (inferior *inf, ptid_t ptid,
    more events.  Polls for events from all inferiors/targets.  */
 
 static bool
-do_target_wait (execution_control_state *ecs, target_wait_flags options)
+do_target_wait (ptid_t wait_ptid, execution_control_state *ecs,
+		target_wait_flags options)
 {
   int num_inferiors = 0;
   int random_selector;
@@ -3751,9 +3752,10 @@  do_target_wait (execution_control_state *ecs, target_wait_flags options)
      polling the rest of the inferior list starting from that one in a
      circular fashion until the whole list is polled once.  */
 
-  auto inferior_matches = [] (inferior *inf)
+  auto inferior_matches = [&wait_ptid] (inferior *inf)
     {
-      return inf->process_target () != nullptr;
+      return (inf->process_target () != NULL
+	      && ptid_t (inf->pid).matches (wait_ptid));
     };
 
   /* First see how many matching inferiors we have.  */
@@ -3792,7 +3794,7 @@  do_target_wait (execution_control_state *ecs, target_wait_flags options)
 
   auto do_wait = [&] (inferior *inf)
   {
-    ecs->ptid = do_target_wait_1 (inf, minus_one_ptid, &ecs->ws, options);
+    ecs->ptid = do_target_wait_1 (inf, wait_ptid, &ecs->ws, options);
     ecs->target = inf->process_target ();
     return (ecs->ws.kind () != TARGET_WAITKIND_IGNORE);
   };
@@ -4169,7 +4171,7 @@  fetch_inferior_event ()
        the event.  */
     scoped_disable_commit_resumed disable_commit_resumed ("handling event");
 
-    if (!do_target_wait (&ecs, TARGET_WNOHANG))
+    if (!do_target_wait (minus_one_ptid, &ecs, TARGET_WNOHANG))
       {
 	infrun_debug_printf ("do_target_wait returned no event");
 	disable_commit_resumed.reset_and_commit ();