gdb/python: add a 'connection_num' attribute to Inferior objects
Define a 'connection_num' attribute for Inferior objects. The read-only attribute is the ID of the connection of an inferior, as printed by "info inferiors". In GDB's internal terminology, that's the process stratum target of the inferior. If the inferior has no target connection, the attribute is None. gdb/ChangeLog: 2021-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * python/py-inferior.c (infpy_get_connection_num): New function. (inferior_object_getset): Add a new element for 'connection_num'. * NEWS: Mention the 'connection_num' attribute of Inferior objects. gdb/doc/ChangeLog: 2021-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * python.texi (Inferiors In Python): Mention the 'connection_num' attribute. gdb/testsuite/ChangeLog: 2021-05-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.python/py-inferior.exp: Add test cases for 'connection_num'.
This commit is contained in:
parent
2f63ec5ccc
commit
55789354fc
7 changed files with 70 additions and 1 deletions
|
@ -427,6 +427,23 @@ infpy_get_num (PyObject *self, void *closure)
|
|||
return gdb_py_object_from_longest (inf->inferior->num).release ();
|
||||
}
|
||||
|
||||
/* Return the connection number of the given inferior, or None if a
|
||||
connection does not exist. */
|
||||
|
||||
static PyObject *
|
||||
infpy_get_connection_num (PyObject *self, void *closure)
|
||||
{
|
||||
inferior_object *inf = (inferior_object *) self;
|
||||
|
||||
INFPY_REQUIRE_VALID (inf);
|
||||
|
||||
process_stratum_target *target = inf->inferior->process_target ();
|
||||
if (target == nullptr)
|
||||
Py_RETURN_NONE;
|
||||
|
||||
return PyLong_FromLong (target->connection_number);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
infpy_get_pid (PyObject *self, void *closure)
|
||||
{
|
||||
|
@ -943,6 +960,8 @@ gdbpy_initialize_inferior (void)
|
|||
static gdb_PyGetSetDef inferior_object_getset[] =
|
||||
{
|
||||
{ "num", infpy_get_num, NULL, "ID of inferior, as assigned by GDB.", NULL },
|
||||
{ "connection_num", infpy_get_connection_num, NULL,
|
||||
"ID of inferior's connection, as assigned by GDB.", NULL },
|
||||
{ "pid", infpy_get_pid, NULL, "PID of inferior, as assigned by the OS.",
|
||||
NULL },
|
||||
{ "was_attached", infpy_get_was_attached, NULL,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue