summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2020-05-14 13:59:53 +0200
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2020-05-14 13:59:53 +0200
commit293b3ebcba93960b4e39b27eeddaa4a01f024d0c (patch)
treef3aa0332d2141f8e7cb096ac73216023fb0154f2
parent7ca9b62a2b63ae04d554053c2a2053d13a9d8c92 (diff)
downloadbinutils-gdb-293b3ebcba93960b4e39b27eeddaa4a01f024d0c.tar.gz
gdb/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: 2020-05-14 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
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/infrun.c77
2 files changed, 48 insertions, 35 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8b756c451b4..c27876b5c81 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2020-05-14 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.
+
+2020-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
* infrun.c (resume_1): Move a 'regcache_read_pc' call down to first
use.
diff --git a/gdb/infrun.c b/gdb/infrun.c
index db88a1eef15..c5bf2d0ad74 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4712,6 +4712,47 @@ save_waitstatus (struct thread_info *tp, const target_waitstatus *ws)
}
}
+/* 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
@@ -5145,41 +5186,7 @@ handle_inferior_event (struct execution_control_state *ecs)
}
}
- /* 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)
{