aboutsummaryrefslogtreecommitdiff
path: root/gdb/doc
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2021-09-01 15:33:19 +0100
committerAndrew Burgess <aburgess@redhat.com>2021-11-30 12:10:33 +0000
commit0e3b7c25eea80717638617ebafac611ed970def8 (patch)
tree65eaac6eb07c906b3c18903ede558ea8138ad830 /gdb/doc
parentabfdb09f011ac7c76321843d9d0b395ca96e3fef (diff)
downloadgdb-0e3b7c25eea80717638617ebafac611ed970def8.zip
gdb-0e3b7c25eea80717638617ebafac611ed970def8.tar.gz
gdb-0e3b7c25eea80717638617ebafac611ed970def8.tar.bz2
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'.
Diffstat (limited to 'gdb/doc')
-rw-r--r--gdb/doc/python.texi93
1 files changed, 91 insertions, 2 deletions
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 9a76813..33748ee 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -220,6 +220,7 @@ optional arguments while skipping others. Example:
* Lazy Strings In Python:: Python representation of lazy strings.
* Architectures In Python:: Python representation of architectures.
* Registers In Python:: Python representation of registers.
+* Connections In Python:: Python representation of connections.
* TUI Windows In Python:: Implementing new TUI windows.
@end menu
@@ -565,6 +566,13 @@ returned from @code{gdb.Architecture.name}
(@pxref{gdbpy_architecture_name,,Architecture.name}).
@end defun
+@anchor{gdbpy_connections}
+@defun gdb.connections
+Return a list of @code{gdb.TargetConnection} objects, one for each
+currently active connection (@pxref{Connections In Python}). The
+connection objects are in no particular order in the returned list.
+@end defun
+
@node Exception Handling
@subsubsection Exception Handling
@cindex python exceptions
@@ -3095,10 +3103,18 @@ A @code{gdb.Inferior} object has the following attributes:
ID of inferior, as assigned by GDB.
@end defvar
+@anchor{gdbpy_inferior_connection}
+@defvar Inferior.connection
+The @code{gdb.TargetConnection} for this inferior (@pxref{Connections
+In Python}), or @code{None} if this inferior has no connection.
+@end defvar
+
@defvar Inferior.connection_num
ID of inferior's connection as assigned by @value{GDBN}, or None if
-the inferior is not connected to a target.
-@xref{Inferiors Connections and Programs}.
+the inferior is not connected to a target. @xref{Inferiors Connections
+and Programs}. This is equivalent to
+@code{gdb.Inferior.connection.num} in the case where
+@code{gdb.Inferior.connection} is not @code{None}.
@end defvar
@defvar Inferior.pid
@@ -3439,6 +3455,15 @@ which has a single attribute:
An integer, the value of the exit code @value{GDBN} will return.
@end defvar
+@item events.connection_removed
+This is emitted when @value{GDBN} removes a connection
+(@pxref{Connections In Python}). The event is of type
+@code{gdb.ConnectionEvent}. This has a single read-only attribute:
+
+@defvar ConnectionEvent.connection
+The @code{gdb.TargetConnection} that is being removed.
+@end defvar
+
@end table
@node Threads In Python
@@ -5973,6 +5998,70 @@ properties:
A string that is the name of this register group.
@end defvar
+@node Connections In Python
+@subsubsection Connections In Python
+@cindex connections in python
+@value{GDBN} lets you run and debug multiple programs in a single
+session. Each program being debugged has a connection, the connection
+describes how @value{GDBN} controls the program being debugged.
+Examples of different connection types are @samp{native} and
+@samp{remote}. @xref{Inferiors Connections and Programs}.
+
+@value{GDBN} uses the @code{gdb.TargetConnection} object type to
+represent a connection in Python code. To get a list of all
+connections use @code{gdb.connections}
+(@pxref{gdbpy_connections,,gdb.connections}).
+
+To get the connection for a single @code{gdb.Inferior} read its
+@code{gdb.Inferior.connection} attribute
+(@pxref{gdbpy_inferior_connection,,gdb.Inferior.connection}).
+
+A @code{gdb.TargetConnection} has the following method:
+
+@defun TargetConnection.is_valid ()
+Return @code{True} if the @code{gdb.TargetConnection} object is valid,
+@code{False} if not. A @code{gdb.TargetConnection} will become
+invalid if the connection no longer exists within @value{GDBN}, this
+might happen when no inferiors are using the connection, but could be
+delayed until the user replaces the current target.
+
+Reading any of the @code{gdb.TargetConnection} properties will throw
+an exception if the connection is invalid.
+@end defun
+
+A @code{gdb.TargetConnection} has the following read-only properties:
+
+@defvar TargetConnection.num
+An integer assigned by @value{GDBN} to uniquely identify this
+connection. This is the same value as displayed in the @samp{Num}
+column of the @code{info connections} command output (@pxref{Inferiors
+Connections and Programs,,info connections}).
+@end defvar
+
+@defvar TargetConnection.type
+A string that describes what type of connection this is. This string
+will be one of the valid names that can be passed to the @code{target}
+command (@pxref{Target Commands,,target command}).
+@end defvar
+
+@defvar TargetConnection.description
+A string that gives a short description of this target type. This is
+the same string that is displayed in the @samp{Description} column of
+the @code{info connection} command output (@pxref{Inferiors
+Connections and Programs,,info connections}).
+@end defvar
+
+@defvar TargetConnection.details
+An optional string that gives additional information about this
+connection. This attribute can be @code{None} if there are no
+additional details for this connection.
+
+An example of a connection type that might have additional details is
+the @samp{remote} connection, in this case the details string can
+contain the @samp{@var{hostname}:@var{port}} that was used to connect
+to the remote target.
+@end defvar
+
@node TUI Windows In Python
@subsubsection Implementing new TUI windows
@cindex Python TUI Windows