diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-09-07 11:45:55 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-10-05 10:05:40 +0100 |
commit | b1f0f2841871f407d116e3e7f0dfca3e410633d4 (patch) | |
tree | afec47062fce39a7b8973b7b5d48703803525a40 /gdb/top.c | |
parent | 1cb56ad3f3bd378a5adde648c56c48b0a293e2b9 (diff) | |
download | fsf-binutils-gdb-b1f0f2841871f407d116e3e7f0dfca3e410633d4.zip fsf-binutils-gdb-b1f0f2841871f407d116e3e7f0dfca3e410633d4.tar.gz fsf-binutils-gdb-b1f0f2841871f407d116e3e7f0dfca3e410633d4.tar.bz2 |
gdb/python: add a new gdb_exiting event
Add a new event, gdb.events.gdb_exiting, which is called once GDB
decides it is going to exit.
This event is not triggered in the case that GDB performs a hard
abort, for example, when handling an internal error and the user
decides to quit the debug session, or if GDB hits an unexpected,
fatal, signal.
This event is triggered if the user just types 'quit' at the command
prompt, or if GDB is run with '-batch' and has processed all of the
required commands.
The new event type is gdb.GdbExitingEvent, and it has a single
attribute exit_code, which is the value that GDB is about to exit
with.
The event is triggered before GDB starts dismantling any of its own
internal state, so, my expectation is that most Python calls should
work just fine at this point.
When considering this functionality I wondered about using the
'atexit' Python module. However, this is triggered when the Python
environment is shut down, which is done from a final cleanup. At
this point we don't know for sure what other GDB state has already
been cleaned up.
Diffstat (limited to 'gdb/top.c')
-rw-r--r-- | gdb/top.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1761,8 +1761,6 @@ quit_force (int *exit_arg, int from_tty) { int exit_code = 0; - undo_terminal_modifications_before_exit (); - /* An optional expression may be used to cause gdb to terminate with the value of that expression. */ if (exit_arg) @@ -1770,6 +1768,10 @@ quit_force (int *exit_arg, int from_tty) else if (return_child_result) exit_code = return_child_result_value; + gdb::observers::gdb_exiting.notify (exit_code); + + undo_terminal_modifications_before_exit (); + /* We want to handle any quit errors and exit regardless. */ /* Get out of tfind mode, and kill or detach all inferiors. */ |