Add ability to add attributes to gdb.Objfile and gdb.Progspace objects.

gdb/ChangeLog:

	* NEWS: Mention ability add attributes to gdb.Objfile and
	gdb.Progspace objects.
	* python/py-objfile.c (objfile_object): New member dict.
	(objfpy_dealloc): Py_XDECREF dict.
	(objfpy_initialize): Initialize dict.
	(objfile_getset): Add __dict__.
	(objfile_object_type): Set tp_dictoffset member.
	* python/py-progspace.c (progspace_object): New member dict.
	(pspy_dealloc): Py_XDECREF dict.
	(pspy_initialize): Initialize dict.
	(pspace_getset): Add __dict__.
	(pspace_object_type): Set tp_dictoffset member.

gdb/doc/ChangeLog:

	* python.texi (Progspaces In Python): Document ability to add
	random attributes to gdb.Progspace objects.
	(Objfiles In Python): Document ability to add random attributes to
	gdb.objfile objects.

gdb/testsuite/ChangeLog:

	* gdb.python/py-objfile.exp: Add tests for setting random attributes
	in objfiles.
	* gdb.python/py-progspace.exp: Add tests for setting random attributes
	in progspaces.
This commit is contained in:
Doug Evans 2014-10-30 17:05:17 -07:00
parent c21c8bde37
commit 02be9a7100
9 changed files with 130 additions and 3 deletions

View file

@ -46,3 +46,8 @@ gdb_test "python print (objfile.is_valid())" "True" \
gdb_unload
gdb_test "python print (objfile.is_valid())" "False" \
"Get objfile validity after unload"
gdb_py_test_silent_cmd "python objfile.random_attribute = 42" \
"Set random attribute in objfile" 1
gdb_test "python print (objfile.random_attribute)" "42" \
"Verify set of random attribute in objfile"

View file

@ -16,6 +16,8 @@
# This file is part of the GDB testsuite. It tests the program space
# support in Python.
load_lib gdb-python.exp
standard_testfile
if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
@ -37,5 +39,13 @@ gdb_test "python print (gdb.progspaces())" "\\\[<gdb.Progspace object at $hex>\\
gdb_load ${binfile}
gdb_test "python print (gdb.current_progspace().filename)" "py-progspace" \
gdb_py_test_silent_cmd "python progspace = gdb.current_progspace()" \
"Get current progspace" 1
gdb_test "python print (progspace.filename)" "py-progspace" \
"current progspace filename (py-progspace)"
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"