binutils-gdb/gdb/python/py-all-events.def
Andrew Burgess b1f0f28418 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.
2021-10-05 10:05:40 +01:00

42 lines
1.5 KiB
C++

/* Python event definitions -*- c++ -*-
Copyright (C) 2017-2021 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* To use this file, define GDB_PY_DEFINE_EVENT to expand how you
like, then include the file.
GDB_PY_DEFINE_EVENT has one parameter, the name of the event.
*/
GDB_PY_DEFINE_EVENT(stop)
GDB_PY_DEFINE_EVENT(cont)
GDB_PY_DEFINE_EVENT(exited)
GDB_PY_DEFINE_EVENT(new_objfile)
GDB_PY_DEFINE_EVENT(clear_objfiles)
GDB_PY_DEFINE_EVENT(new_inferior)
GDB_PY_DEFINE_EVENT(inferior_deleted)
GDB_PY_DEFINE_EVENT(new_thread)
GDB_PY_DEFINE_EVENT(inferior_call)
GDB_PY_DEFINE_EVENT(memory_changed)
GDB_PY_DEFINE_EVENT(register_changed)
GDB_PY_DEFINE_EVENT(breakpoint_created)
GDB_PY_DEFINE_EVENT(breakpoint_deleted)
GDB_PY_DEFINE_EVENT(breakpoint_modified)
GDB_PY_DEFINE_EVENT(before_prompt)
GDB_PY_DEFINE_EVENT(gdb_exiting)