Skip to content

Commit

Permalink
Revert "gdb: remove unnecessary parameter wait_ptid from do_target_wait"
Browse files Browse the repository at this point in the history
This reverts commit ac0d67e.

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.

This is not a straight revert of the above commit.  Reverting the
above commit replaces a 'nullptr' with 'NULL', I've gone in and
changed that, preserving the 'nullptr'.

Reviewed-By: Tankut Baris Aktemur <[email protected]>
Tested-By: Luis Machado <[email protected]>
Tested-By: Keith Seitz <[email protected]>
  • Loading branch information
T-J-Teru committed Mar 25, 2024
1 parent 198ff6f commit 07505b6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gdb/infrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -4125,7 +4125,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;
Expand All @@ -4135,9 +4136,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 () != nullptr
&& ptid_t (inf->pid).matches (wait_ptid));
};

/* First see how many matching inferiors we have. */
Expand Down Expand Up @@ -4176,7 +4178,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);
};
Expand Down Expand Up @@ -4626,7 +4628,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 ();
Expand Down

0 comments on commit 07505b6

Please sign in to comment.