From a40bf0c2e93daac4ae4ce7dd1c43ab6135e76720 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 13 Sep 2018 15:39:26 -0400 Subject: python: Add Inferior.progspace property This patch adds a progspace property to the gdb.Inferior type, which allows getting the gdb.Progspace object associated to that inferior. In conjunction with the following patch, this will allow scripts iterate on objfiles associated with a particular inferior. gdb/ChangeLog: * python/py-inferior.c (infpy_get_progspace): New function. (inferior_object_getset): Add progspace property. * NEWS: Mention the new property. gdb/doc/ChangeLog: * 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. gdb/testsuite/ChangeLog: * gdb.python/py-inferior.exp: Add tests for Inferior.progspace and a few other Inferior properties when the Inferior is no longer valid. --- gdb/testsuite/gdb.python/py-inferior.exp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gdb/testsuite/gdb.python/py-inferior.exp') diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp index 7ec8193..38f5257 100644 --- a/gdb/testsuite/gdb.python/py-inferior.exp +++ b/gdb/testsuite/gdb.python/py-inferior.exp @@ -55,6 +55,9 @@ gdb_test "python print ('result = %s' % i0.pid)" " = \[0-9\]+" "test Inferior.pi gdb_test "python print ('result = %s' % i0.was_attached)" " = False" "test Inferior.was_attached" gdb_test "python print (i0.threads ())" "\\(,\\)" "test Inferior.threads" +gdb_test "python print (i0.progspace)" "" +gdb_test "python print (i0.progspace == gdb.progspaces()\[0\])" "True" + # Test the number of inferior threads. gdb_breakpoint check_threads @@ -263,6 +266,8 @@ with_test_prefix "is_valid" { "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))" \ -- cgit v1.1