* [review] infrun: extract out a code piece into 'mark_non_executing_threads' fu...
@ 2019-11-04 10:23 Tankut Baris Aktemur (Code Review)
2019-12-06 15:36 ` Pedro Alves (Code Review)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tankut Baris Aktemur (Code Review) @ 2019-11-04 10:23 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/507
......................................................................
infrun: extract out a code piece into 'mark_non_executing_threads' function
This is a refactoring. The extracted function is placed deliberately
before 'stop_all_threads' because the function will be re-used there
in a subsequent patch for handling an exit status kind received from
a thread that GDB attempted to stop.
gdb/ChangeLog:
2019-11-04 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (handle_inferior_event): Extract out a piece of code
into...
(mark_non_executing_threads): ...this new function.
Change-Id: I2b088f4a724f4260cb37068264964525cf62a118
---
M gdb/infrun.c
1 file changed, 41 insertions(+), 35 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 66a066f..57405d7 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4277,6 +4277,46 @@
}
}
+/* Mark the non-executing threads accordingly. In all-stop, all
+ threads of all processes are stopped when we get any event
+ reported. In non-stop mode, only the event thread stops. */
+
+static void
+mark_non_executing_threads (ptid_t event_ptid,
+ struct target_waitstatus ws)
+{
+ ptid_t mark_ptid;
+
+ if (!target_is_non_stop_p ())
+ mark_ptid = minus_one_ptid;
+ else if (ws.kind == TARGET_WAITKIND_SIGNALLED
+ || ws.kind == TARGET_WAITKIND_EXITED)
+ {
+ /* If we're handling a process exit in non-stop mode, even
+ though threads haven't been deleted yet, one would think
+ that there is nothing to do, as threads of the dead process
+ will be soon deleted, and threads of any other process were
+ left running. However, on some targets, threads survive a
+ process exit event. E.g., for the "checkpoint" command,
+ when the current checkpoint/fork exits, linux-fork.c
+ automatically switches to another fork from within
+ target_mourn_inferior, by associating the same
+ inferior/thread to another fork. We haven't mourned yet at
+ this point, but we must mark any threads left in the
+ process as not-executing so that finish_thread_state marks
+ them stopped (in the user's perspective) if/when we present
+ the stop to the user. */
+ mark_ptid = ptid_t (event_ptid.pid ());
+ }
+ else
+ mark_ptid = event_ptid;
+
+ set_executing (mark_ptid, 0);
+
+ /* Likewise the resumed flag. */
+ set_resumed (mark_ptid, 0);
+}
+
/* See infrun.h. */
void
@@ -4703,41 +4743,7 @@
}
}
- /* Mark the non-executing threads accordingly. In all-stop, all
- threads of all processes are stopped when we get any event
- reported. In non-stop mode, only the event thread stops. */
- {
- ptid_t mark_ptid;
-
- if (!target_is_non_stop_p ())
- mark_ptid = minus_one_ptid;
- else if (ecs->ws.kind == TARGET_WAITKIND_SIGNALLED
- || ecs->ws.kind == TARGET_WAITKIND_EXITED)
- {
- /* If we're handling a process exit in non-stop mode, even
- though threads haven't been deleted yet, one would think
- that there is nothing to do, as threads of the dead process
- will be soon deleted, and threads of any other process were
- left running. However, on some targets, threads survive a
- process exit event. E.g., for the "checkpoint" command,
- when the current checkpoint/fork exits, linux-fork.c
- automatically switches to another fork from within
- target_mourn_inferior, by associating the same
- inferior/thread to another fork. We haven't mourned yet at
- this point, but we must mark any threads left in the
- process as not-executing so that finish_thread_state marks
- them stopped (in the user's perspective) if/when we present
- the stop to the user. */
- mark_ptid = ptid_t (ecs->ptid.pid ());
- }
- else
- mark_ptid = ecs->ptid;
-
- set_executing (mark_ptid, 0);
-
- /* Likewise the resumed flag. */
- set_resumed (mark_ptid, 0);
- }
+ mark_non_executing_threads (ecs->ptid, ecs->ws);
switch (ecs->ws.kind)
{
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2b088f4a724f4260cb37068264964525cf62a118
Gerrit-Change-Number: 507
Gerrit-PatchSet: 1
Gerrit-Owner: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review] infrun: extract out a code piece into 'mark_non_executing_threads' fu...
2019-11-04 10:23 [review] infrun: extract out a code piece into 'mark_non_executing_threads' fu Tankut Baris Aktemur (Code Review)
@ 2019-12-06 15:36 ` Pedro Alves (Code Review)
2020-02-05 13:19 ` [review v2] " Tankut Baris Aktemur (Code Review)
2020-02-07 12:11 ` Tankut Baris Aktemur (Code Review)
2 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves (Code Review) @ 2019-12-06 15:36 UTC (permalink / raw)
To: Tankut Baris Aktemur, gdb-patches
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/507
......................................................................
Patch Set 1: Code-Review+2
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2b088f4a724f4260cb37068264964525cf62a118
Gerrit-Change-Number: 507
Gerrit-PatchSet: 1
Gerrit-Owner: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Comment-Date: Fri, 06 Dec 2019 15:36:03 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review v2] infrun: extract out a code piece into 'mark_non_executing_threads' fu...
2019-11-04 10:23 [review] infrun: extract out a code piece into 'mark_non_executing_threads' fu Tankut Baris Aktemur (Code Review)
2019-12-06 15:36 ` Pedro Alves (Code Review)
@ 2020-02-05 13:19 ` Tankut Baris Aktemur (Code Review)
2020-02-07 12:11 ` Tankut Baris Aktemur (Code Review)
2 siblings, 0 replies; 4+ messages in thread
From: Tankut Baris Aktemur (Code Review) @ 2020-02-05 13:19 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/507
......................................................................
infrun: extract out a code piece into 'mark_non_executing_threads' function
This is a refactoring. The extracted function is placed deliberately
before 'stop_all_threads' because the function will be re-used there
in a subsequent patch for handling an exit status kind received from
a thread that GDB attempted to stop.
gdb/ChangeLog:
2019-11-04 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* infrun.c (handle_inferior_event): Extract out a piece of code
into...
(mark_non_executing_threads): ...this new function.
Change-Id: I2b088f4a724f4260cb37068264964525cf62a118
---
M gdb/infrun.c
1 file changed, 42 insertions(+), 35 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index fd72a74..9224376 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4673,6 +4673,47 @@
}
}
+/* Mark the non-executing threads accordingly. In all-stop, all
+ threads of all processes are stopped when we get any event
+ reported. In non-stop mode, only the event thread stops. */
+
+static void
+mark_non_executing_threads (process_stratum_target *target,
+ ptid_t event_ptid,
+ struct target_waitstatus ws)
+{
+ ptid_t mark_ptid;
+
+ if (!target_is_non_stop_p ())
+ mark_ptid = minus_one_ptid;
+ else if (ws.kind == TARGET_WAITKIND_SIGNALLED
+ || ws.kind == TARGET_WAITKIND_EXITED)
+ {
+ /* If we're handling a process exit in non-stop mode, even
+ though threads haven't been deleted yet, one would think
+ that there is nothing to do, as threads of the dead process
+ will be soon deleted, and threads of any other process were
+ left running. However, on some targets, threads survive a
+ process exit event. E.g., for the "checkpoint" command,
+ when the current checkpoint/fork exits, linux-fork.c
+ automatically switches to another fork from within
+ target_mourn_inferior, by associating the same
+ inferior/thread to another fork. We haven't mourned yet at
+ this point, but we must mark any threads left in the
+ process as not-executing so that finish_thread_state marks
+ them stopped (in the user's perspective) if/when we present
+ the stop to the user. */
+ mark_ptid = ptid_t (event_ptid.pid ());
+ }
+ else
+ mark_ptid = event_ptid;
+
+ set_executing (target, mark_ptid, false);
+
+ /* Likewise the resumed flag. */
+ set_resumed (target, mark_ptid, false);
+}
+
/* See infrun.h. */
void
@@ -5107,41 +5148,7 @@
}
}
- /* Mark the non-executing threads accordingly. In all-stop, all
- threads of all processes are stopped when we get any event
- reported. In non-stop mode, only the event thread stops. */
- {
- ptid_t mark_ptid;
-
- if (!target_is_non_stop_p ())
- mark_ptid = minus_one_ptid;
- else if (ecs->ws.kind == TARGET_WAITKIND_SIGNALLED
- || ecs->ws.kind == TARGET_WAITKIND_EXITED)
- {
- /* If we're handling a process exit in non-stop mode, even
- though threads haven't been deleted yet, one would think
- that there is nothing to do, as threads of the dead process
- will be soon deleted, and threads of any other process were
- left running. However, on some targets, threads survive a
- process exit event. E.g., for the "checkpoint" command,
- when the current checkpoint/fork exits, linux-fork.c
- automatically switches to another fork from within
- target_mourn_inferior, by associating the same
- inferior/thread to another fork. We haven't mourned yet at
- this point, but we must mark any threads left in the
- process as not-executing so that finish_thread_state marks
- them stopped (in the user's perspective) if/when we present
- the stop to the user. */
- mark_ptid = ptid_t (ecs->ptid.pid ());
- }
- else
- mark_ptid = ecs->ptid;
-
- set_executing (ecs->target, mark_ptid, false);
-
- /* Likewise the resumed flag. */
- set_resumed (ecs->target, mark_ptid, false);
- }
+ mark_non_executing_threads (ecs->target, ecs->ptid, ecs->ws);
switch (ecs->ws.kind)
{
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2b088f4a724f4260cb37068264964525cf62a118
Gerrit-Change-Number: 507
Gerrit-PatchSet: 2
Gerrit-Owner: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-MessageType: newpatchset
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review v2] infrun: extract out a code piece into 'mark_non_executing_threads' fu...
2019-11-04 10:23 [review] infrun: extract out a code piece into 'mark_non_executing_threads' fu Tankut Baris Aktemur (Code Review)
2019-12-06 15:36 ` Pedro Alves (Code Review)
2020-02-05 13:19 ` [review v2] " Tankut Baris Aktemur (Code Review)
@ 2020-02-07 12:11 ` Tankut Baris Aktemur (Code Review)
2 siblings, 0 replies; 4+ messages in thread
From: Tankut Baris Aktemur (Code Review) @ 2020-02-07 12:11 UTC (permalink / raw)
To: gdb-patches; +Cc: Pedro Alves
Tankut Baris Aktemur has abandoned this change. ( https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/507 )
Change subject: infrun: extract out a code piece into 'mark_non_executing_threads' function
......................................................................
Abandoned
Migrated to https://sourceware.org/ml/gdb-patches/2020-02/msg00153.html
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I2b088f4a724f4260cb37068264964525cf62a118
Gerrit-Change-Number: 507
Gerrit-PatchSet: 2
Gerrit-Owner: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-MessageType: abandon
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-02-07 12:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 10:23 [review] infrun: extract out a code piece into 'mark_non_executing_threads' fu Tankut Baris Aktemur (Code Review)
2019-12-06 15:36 ` Pedro Alves (Code Review)
2020-02-05 13:19 ` [review v2] " Tankut Baris Aktemur (Code Review)
2020-02-07 12:11 ` Tankut Baris Aktemur (Code Review)
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).