2017-09-09 05:38:12 +08:00
|
|
|
/* Python event definitions -*- c++ -*-
|
|
|
|
|
2023-01-01 20:49:04 +08:00
|
|
|
Copyright (C) 2017-2023 Free Software Foundation, Inc.
|
2017-09-09 05:38:12 +08:00
|
|
|
|
|
|
|
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)
|
2022-06-21 01:30:04 +08:00
|
|
|
GDB_PY_DEFINE_EVENT(free_objfile)
|
2017-09-09 05:38:12 +08:00
|
|
|
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/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-09-07 18:45:55 +08:00
|
|
|
GDB_PY_DEFINE_EVENT(gdb_exiting)
|
gdb/python: introduce gdb.TargetConnection object type
This commit adds a new object type gdb.TargetConnection. This new
type represents a connection within GDB (a connection as displayed by
'info connections').
There's three ways to find a gdb.TargetConnection, there's a new
'gdb.connections()' function, which returns a list of all currently
active connections.
Or you can read the new 'connection' property on the gdb.Inferior
object type, this contains the connection for that inferior (or None
if the inferior has no connection, for example, it is exited).
Finally, there's a new gdb.events.connection_removed event registry,
this emits a new gdb.ConnectionEvent whenever a connection is removed
from GDB (this can happen when all inferiors using a connection exit,
though this is not always the case, depending on the connection type).
The gdb.ConnectionEvent has a 'connection' property, which is the
gdb.TargetConnection being removed from GDB.
The gdb.TargetConnection has an 'is_valid()' method. A connection
object becomes invalid when the underlying connection is removed from
GDB (as discussed above, this might be when all inferiors using a
connection exit, or it might be when the user explicitly replaces a
connection in GDB by issuing another 'target' command).
The gdb.TargetConnection has the following read-only properties:
'num': The number for this connection,
'type': e.g. 'native', 'remote', 'sim', etc
'description': The longer description as seen in the 'info
connections' command output.
'details': A string or None. Extra details for the connection, for
example, a remote connection's details might be
'hostname:port'.
2021-09-01 22:33:19 +08:00
|
|
|
GDB_PY_DEFINE_EVENT(connection_removed)
|