* [review] infrun: extract out a code piece into the 'handle_inferior_exit' func...
@ 2019-11-04 10:23 Tankut Baris Aktemur (Code Review)
2019-12-06 15:45 ` Pedro Alves (Code Review)
2020-02-07 12:11 ` Tankut Baris Aktemur (Code Review)
0 siblings, 2 replies; 3+ 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/+/508
......................................................................
infrun: extract out a code piece into the 'handle_inferior_exit' function
This is a refactoring. The extracted function is placed deliberately
before 'stop_all_threads' because the the function will be re-used
there in a subsequent patch for handling a TARGET_WAITKIND_EXITED or
TARGET_WAITKIND_SIGNALLED 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...
(handle_inferior_exit): ...this new function.
Change-Id: Id8c7d485805cf39623c3e06b4a565515b7e9625c
---
M gdb/infrun.c
1 file changed, 69 insertions(+), 56 deletions(-)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 57405d7..f628fd1 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4317,6 +4317,74 @@
set_resumed (mark_ptid, 0);
}
+/* Handle a TARGET_WAITKIND_EXITED or TARGET_WAITKIND_SIGNALLED
+ event. */
+
+static void
+handle_inferior_exit (ptid_t event_ptid,
+ struct target_waitstatus ws)
+{
+ gdb_assert (ws.kind == TARGET_WAITKIND_EXITED
+ || ws.kind == TARGET_WAITKIND_SIGNALLED);
+
+ inferior_ptid = event_ptid;
+ set_current_inferior (find_inferior_ptid (event_ptid));
+ set_current_program_space (current_inferior ()->pspace);
+ handle_vfork_child_exec_or_exit (0);
+ target_terminal::ours (); /* Must do this before mourn anyway. */
+
+ /* Clearing any previous state of convenience variables. */
+ clear_exit_convenience_vars ();
+
+ if (ws.kind == TARGET_WAITKIND_EXITED)
+ {
+ /* Record the exit code in the convenience variable $_exitcode, so
+ that the user can inspect this again later. */
+ set_internalvar_integer (lookup_internalvar ("_exitcode"),
+ (LONGEST) ws.value.integer);
+
+ /* Also record this in the inferior itself. */
+ current_inferior ()->has_exit_code = 1;
+ current_inferior ()->exit_code = (LONGEST) ws.value.integer;
+
+ /* Support the --return-child-result option. */
+ return_child_result_value = ws.value.integer;
+
+ gdb::observers::exited.notify (ws.value.integer);
+ }
+ else
+ {
+ struct gdbarch *gdbarch = current_inferior ()->gdbarch;
+
+ if (gdbarch_gdb_signal_to_target_p (gdbarch))
+ {
+ /* Set the value of the internal variable $_exitsignal,
+ which holds the signal uncaught by the inferior. */
+ set_internalvar_integer (lookup_internalvar ("_exitsignal"),
+ gdbarch_gdb_signal_to_target (gdbarch,
+ ws.value.sig));
+ }
+ else
+ {
+ /* We don't have access to the target's method used for
+ converting between signal numbers (GDB's internal
+ representation <-> target's representation).
+ Therefore, we cannot do a good job at displaying this
+ information to the user. It's better to just warn
+ her about it (if infrun debugging is enabled), and
+ give up. */
+ if (debug_infrun)
+ fprintf_filtered (gdb_stdlog, _("\
+Cannot fill $_exitsignal with the correct signal number.\n"));
+ }
+
+ gdb::observers::signal_exited.notify (ws.value.sig);
+ }
+
+ gdb_flush (gdb_stdout);
+ target_mourn_inferior (inferior_ptid);
+}
+
/* See infrun.h. */
void
@@ -4842,62 +4910,7 @@
case TARGET_WAITKIND_EXITED:
case TARGET_WAITKIND_SIGNALLED:
- inferior_ptid = ecs->ptid;
- set_current_inferior (find_inferior_ptid (ecs->ptid));
- set_current_program_space (current_inferior ()->pspace);
- handle_vfork_child_exec_or_exit (0);
- target_terminal::ours (); /* Must do this before mourn anyway. */
-
- /* Clearing any previous state of convenience variables. */
- clear_exit_convenience_vars ();
-
- if (ecs->ws.kind == TARGET_WAITKIND_EXITED)
- {
- /* Record the exit code in the convenience variable $_exitcode, so
- that the user can inspect this again later. */
- set_internalvar_integer (lookup_internalvar ("_exitcode"),
- (LONGEST) ecs->ws.value.integer);
-
- /* Also record this in the inferior itself. */
- current_inferior ()->has_exit_code = 1;
- current_inferior ()->exit_code = (LONGEST) ecs->ws.value.integer;
-
- /* Support the --return-child-result option. */
- return_child_result_value = ecs->ws.value.integer;
-
- gdb::observers::exited.notify (ecs->ws.value.integer);
- }
- else
- {
- struct gdbarch *gdbarch = current_inferior ()->gdbarch;
-
- if (gdbarch_gdb_signal_to_target_p (gdbarch))
- {
- /* Set the value of the internal variable $_exitsignal,
- which holds the signal uncaught by the inferior. */
- set_internalvar_integer (lookup_internalvar ("_exitsignal"),
- gdbarch_gdb_signal_to_target (gdbarch,
- ecs->ws.value.sig));
- }
- else
- {
- /* We don't have access to the target's method used for
- converting between signal numbers (GDB's internal
- representation <-> target's representation).
- Therefore, we cannot do a good job at displaying this
- information to the user. It's better to just warn
- her about it (if infrun debugging is enabled), and
- give up. */
- if (debug_infrun)
- fprintf_filtered (gdb_stdlog, _("\
-Cannot fill $_exitsignal with the correct signal number.\n"));
- }
-
- gdb::observers::signal_exited.notify (ecs->ws.value.sig);
- }
-
- gdb_flush (gdb_stdout);
- target_mourn_inferior (inferior_ptid);
+ handle_inferior_exit (ecs->ptid, ecs->ws);
stop_print_frame = 0;
stop_waiting (ecs);
return;
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Id8c7d485805cf39623c3e06b4a565515b7e9625c
Gerrit-Change-Number: 508
Gerrit-PatchSet: 1
Gerrit-Owner: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 3+ messages in thread
* [review] infrun: extract out a code piece into the 'handle_inferior_exit' func...
2019-11-04 10:23 [review] infrun: extract out a code piece into the 'handle_inferior_exit' func Tankut Baris Aktemur (Code Review)
@ 2019-12-06 15:45 ` Pedro Alves (Code Review)
2020-02-07 12:11 ` Tankut Baris Aktemur (Code Review)
1 sibling, 0 replies; 3+ messages in thread
From: Pedro Alves (Code Review) @ 2019-12-06 15:45 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/+/508
......................................................................
Patch Set 1: Code-Review+2
(2 comments)
LGTM. See nits below.
| --- /dev/null
| +++ /COMMIT_MSG
| @@ -1,0 +1,19 @@
| +Parent: f5da53f6 (infrun: extract out a code piece into 'mark_non_executing_threads' function)
| +Author: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
| +AuthorDate: 2019-11-04 11:21:38 +0100
| +Commit: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
| +CommitDate: 2019-11-04 11:21:38 +0100
| +
| +infrun: extract out a code piece into the 'handle_inferior_exit' function
| +
| +This is a refactoring. The extracted function is placed deliberately
| +before 'stop_all_threads' because the the function will be re-used
PS1, Line 10:
typo: "the the"
| +there in a subsequent patch for handling a TARGET_WAITKIND_EXITED or
| +TARGET_WAITKIND_SIGNALLED 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...
| --- gdb/infrun.c
| +++ gdb/infrun.c
| @@ -4316,4 +4316,19 @@ mark_non_executing_threads (ptid_t event_ptid,
| /* Likewise the resumed flag. */
| set_resumed (mark_ptid, 0);
| }
|
| +/* Handle a TARGET_WAITKIND_EXITED or TARGET_WAITKIND_SIGNALLED
| + event. */
| +
| +static void
| +handle_inferior_exit (ptid_t event_ptid,
| + struct target_waitstatus ws)
PS1, Line 4325:
This all fits in a single line. Even more so if you remove the
redundant "struct".
(probably the same applies in the previous patch.)
| +{
| + gdb_assert (ws.kind == TARGET_WAITKIND_EXITED
| + || ws.kind == TARGET_WAITKIND_SIGNALLED);
| +
| + inferior_ptid = event_ptid;
| + set_current_inferior (find_inferior_ptid (event_ptid));
| + set_current_program_space (current_inferior ()->pspace);
| + handle_vfork_child_exec_or_exit (0);
| + target_terminal::ours (); /* Must do this before mourn anyway. */
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Id8c7d485805cf39623c3e06b4a565515b7e9625c
Gerrit-Change-Number: 508
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:45:48 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 3+ messages in thread
* [review] infrun: extract out a code piece into the 'handle_inferior_exit' func...
2019-11-04 10:23 [review] infrun: extract out a code piece into the 'handle_inferior_exit' func Tankut Baris Aktemur (Code Review)
2019-12-06 15:45 ` Pedro Alves (Code Review)
@ 2020-02-07 12:11 ` Tankut Baris Aktemur (Code Review)
1 sibling, 0 replies; 3+ 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/+/508 )
Change subject: infrun: extract out a code piece into the 'handle_inferior_exit' function
......................................................................
Abandoned
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Id8c7d485805cf39623c3e06b4a565515b7e9625c
Gerrit-Change-Number: 508
Gerrit-PatchSet: 1
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] 3+ messages in thread
end of thread, other threads:[~2020-02-07 12:11 UTC | newest]
Thread overview: 3+ 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 the 'handle_inferior_exit' func Tankut Baris Aktemur (Code Review)
2019-12-06 15:45 ` Pedro Alves (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).