diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2018-09-13 15:40:41 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2018-09-13 15:42:12 -0400 |
commit | 0ae1a3211adcb8e7518b0b656b2309ebbc45e9ae (patch) | |
tree | 96c5436eeaac8f151adfd96c5fc17117b8f3b4ba /gdb/testsuite/gdb.python/py-progspace.exp | |
parent | a40bf0c2e93daac4ae4ce7dd1c43ab6135e76720 (diff) | |
download | binutils-0ae1a3211adcb8e7518b0b656b2309ebbc45e9ae.zip binutils-0ae1a3211adcb8e7518b0b656b2309ebbc45e9ae.tar.gz binutils-0ae1a3211adcb8e7518b0b656b2309ebbc45e9ae.tar.bz2 |
python: Add Progspace.objfiles method
This patch adds an objfiles method to the Progspace object, which
returns a sequence of the objfiles associated to that program space. I
chose a method rather than a property for symmetry with gdb.objfiles().
gdb/ChangeLog:
* python/py-progspace.c (PSPY_REQUIRE_VALID): New macro.
(pspy_get_objfiles): New function.
(progspace_object_methods): New.
(pspace_object_type): Add tp_methods callback.
* python/python-internal.h (build_objfiles_list): New
declaration.
* python/python.c (build_objfiles_list): New function.
(gdbpy_objfiles): Implement using build_objfiles_list.
* NEWS: Mention the Progspace.objfiles method.
gdb/doc/ChangeLog:
* python.texi (Program Spaces In Python): Document the
Progspace.objfiles method.
(Objfiles In Python): Mention that gdb.objfiles() is identical
to gdb.selected_inferior().progspace.objfiles().
gdb/testsuite/ChangeLog:
* gdb.python/py-progspace.exp: Test the Progspace.objfiles
method.
Diffstat (limited to 'gdb/testsuite/gdb.python/py-progspace.exp')
-rw-r--r-- | gdb/testsuite/gdb.python/py-progspace.exp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp index f0cafa8..fa1ffd9 100644 --- a/gdb/testsuite/gdb.python/py-progspace.exp +++ b/gdb/testsuite/gdb.python/py-progspace.exp @@ -51,3 +51,34 @@ gdb_py_test_silent_cmd "python progspace.random_attribute = 42" \ "Set random attribute in progspace" 1 gdb_test "python print (progspace.random_attribute)" "42" \ "Verify set of random attribute in progspace" + +if {![runto_main]} { + fail "can't run to main" + return +} + +# With a single inferior, progspace.objfiles () and gdb.objfiles () should +# be identical. +gdb_test "python print (progspace.objfiles () == gdb.objfiles ())" "True" + +gdb_test "add-inferior" +gdb_test "inferior 2" + +gdb_load ${binfile} + +# With a second (non-started) inferior, we should have a single objfile - the +# main one. +gdb_test "python print (len (gdb.objfiles ())) == 1" + +# And the gdb.objfiles() list should now be different from the objfiles of the +# prog space of inferior 1. +gdb_test "python print (progspace.objfiles () != gdb.objfiles ())" "True" + +# Delete inferior 2 (and therefore the second progspace), check that the Python +# object reacts sensibly. +gdb_py_test_silent_cmd "python progspace2 = gdb.current_progspace()" \ + "save progspace 2" 1 +gdb_test "inferior 1" "Switching to inferior 1.*" +gdb_test_no_output "remove-inferiors 2" +gdb_test "python print (progspace2.objfiles ())" \ + "RuntimeError: Program space no longer exists.*" |