+2018-09-13 Simon Marchi <simon.marchi@ericsson.com>
+
+ * python/py-inferior.c (infpy_get_progspace): New function.
+ (inferior_object_getset): Add progspace property.
+ * NEWS: Mention the new property.
+
2018-09-13 Tom Tromey <tom@tromey.com>
PR rust/23650:
CSKY ELF csky*-*-elf
CSKY GNU/LINUX csky*-*-linux
+* Python API
+
+ ** The gdb.Inferior type has a new 'progspace' property, which is the program
+ space associated to that inferior.
+
*** Changes in GDB 8.2
* The 'set disassembler-options' command now supports specifying options
+2018-09-13 Simon Marchi <simon.marchi@ericsson.com>
+2018-09-13 Tom Tromey <tom@tromey.com>
+
+ * python.texi (Inferiors In Python): Document
+ Inferior.progspace.
+ (Program Spaces In Python): Document that
+ gdb.current_progspace() is the same as
+ gdb.selected_inferior().progspace.
+
2018-09-13 Simon Marchi <simon.marchi@ericsson.com>
* python.texi (Basic Python): Mention the string representation
started by @value{GDBN} itself.
@end defvar
+@defvar Inferior.progspace
+The inferior's program space. @xref{Progspaces In Python}.
+@end defvar
+
A @code{gdb.Inferior} object has the following methods:
@defun Inferior.is_valid ()
@findex gdb.current_progspace
@defun gdb.current_progspace ()
This function returns the program space of the currently selected inferior.
-@xref{Inferiors and Programs}.
+@xref{Inferiors and Programs}. This is identical to
+@code{gdb.selected_inferior().progspace} (@pxref{Inferiors In Python}) and is
+included for historical compatibility.
@end defun
@findex gdb.progspaces
Py_RETURN_FALSE;
}
+/* Getter of gdb.Inferior.progspace. */
+
+static PyObject *
+infpy_get_progspace (PyObject *self, void *closure)
+{
+ inferior_object *inf = (inferior_object *) self;
+
+ INFPY_REQUIRE_VALID (inf);
+
+ program_space *pspace = inf->inferior->pspace;
+ gdb_assert (pspace != nullptr);
+
+ PyObject *py_pspace = pspace_to_pspace_object (pspace);
+ Py_XINCREF (py_pspace);
+ return py_pspace;
+}
+
static int
build_inferior_list (struct inferior *inf, void *arg)
{
NULL },
{ "was_attached", infpy_get_was_attached, NULL,
"True if the inferior was created using 'attach'.", NULL },
+ { "progspace", infpy_get_progspace, NULL, "Program space of this inferior" },
{ NULL }
};
+2018-09-13 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.python/py-inferior.exp: Add tests for Inferior.progspace
+ and a few other Inferior properties when the Inferior is no
+ longer valid.
+
2018-09-13 Tom Tromey <tom@tromey.com>
PR rust/23650:
gdb_test "python print ('result = %s' % i0.was_attached)" " = False" "test Inferior.was_attached"
gdb_test "python print (i0.threads ())" "\\(<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>,\\)" "test Inferior.threads"
+gdb_test "python print (i0.progspace)" "<gdb.Progspace object at $hex>"
+gdb_test "python print (i0.progspace == gdb.progspaces()\[0\])" "True"
+
# Test the number of inferior threads.
gdb_breakpoint check_threads
"RuntimeError: Inferior no longer exists.*"
gdb_test "python print (inf_list\[1\].was_attached)" \
"RuntimeError: Inferior no longer exists.*"
+ gdb_test "python print (inf_list\[1\].progspace)" \
+ "RuntimeError: Inferior no longer exists.*"
gdb_test "python print (inf_list\[1\].threads ())" \
"RuntimeError: Inferior no longer exists.*"
gdb_test "python print (inf_list\[1\].thread_from_thread_handle (1))" \