Add gdb.Objfile.username.

gdb/ChangeLog:

	* NEWS: Mention gdb.Objfile.username.
	* python/py-objfile.c (objfpy_get_username): New function.
	(objfile_getset): Add "username".

gdb/doc/ChangeLog:

	* python.texi (Objfiles In Python): Document Objfile.username.

gdb/testsuite/ChangeLog:

	* gdb.python/py-objfile.exp: Add tests for objfile.username.
	Add test for objfile.filename, objfile.username after objfile
	has been unloaded.
This commit is contained in:
Doug Evans
2015-01-27 10:13:52 -08:00
parent 1b5493961a
commit 3a8b707add
7 changed files with 68 additions and 0 deletions

View File

@ -42,6 +42,9 @@ gdb_py_test_silent_cmd "python objfile = sym\[0\].symtab.objfile" \
gdb_test "python print (objfile.filename)" "${testfile}" \
"Get objfile file name"
gdb_test "python print (objfile.username)" "${testfile}" \
"Get objfile user name"
gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
"${testfile}"
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
@ -78,6 +81,18 @@ gdb_py_test_silent_cmd "python objfile.random_attribute = 42" \
gdb_test "python print (objfile.random_attribute)" "42" \
"Verify set of random attribute in objfile"
# Verify invalid objfile handling.
if { [gdb_unload] < 0 } {
fail "unload all files"
return -1
}
gdb_test "python print objfile.filename" "None" \
"objfile.filename after objfile is unloaded"
gdb_test "python print objfile.username" "None" \
"objfile.username after objfile is unloaded"
# Now build another copy of the testcase, this time without debug info.
if { [prepare_for_testing ${testfile}.exp ${testfile}2 ${srcfile} {nodebug ldflags=-Wl,--strip-debug}] } {
@ -107,6 +122,9 @@ gdb_py_test_silent_cmd "python sep_objfile = gdb.objfiles()\[0\]" \
gdb_test "python print (sep_objfile.owner.filename)" "${testfile}2" \
"Test owner of separate debug file"
gdb_test "python print (sep_objfile.owner.username)" "${testfile}2" \
"Test user-name of owner of separate debug file"
gdb_test "p main" "= {int \\(\\)} $hex <main>" \
"print main with debug info"