forked from Imagelibrary/binutils-gdb
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.
This commit is contained in:
@@ -3418,6 +3418,16 @@ This has a single attribute:
|
||||
The new thread.
|
||||
@end defvar
|
||||
|
||||
@item events.gdb_exiting
|
||||
This is emitted when @value{GDBN} exits. This event is not emitted if
|
||||
@value{GDBN} exits as a result of an internal error, or after an
|
||||
unexpected signal. The event is of type @code{gdb.GdbExitingEvent},
|
||||
which has a single attribute:
|
||||
|
||||
@defvar GdbExitingEvent.exit_code
|
||||
An integer, the value of the exit code @value{GDBN} will return.
|
||||
@end defvar
|
||||
|
||||
@end table
|
||||
|
||||
@node Threads In Python
|
||||
|
||||
Reference in New Issue
Block a user