aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-objfile.exp
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2014-12-12 09:48:13 -0800
committerDoug Evans <dje@google.com>2014-12-12 09:48:13 -0800
commit6dddd6a5747532ef6e9703432c51680011df4e8d (patch)
tree35083e8dddfb1148d20dc1dc6808c05df7b8bb8a /gdb/testsuite/gdb.python/py-objfile.exp
parentf161c17134bdfa5f5e72d7afb7dfccf5599a67e1 (diff)
downloadgdb-6dddd6a5747532ef6e9703432c51680011df4e8d.zip
gdb-6dddd6a5747532ef6e9703432c51680011df4e8d.tar.gz
gdb-6dddd6a5747532ef6e9703432c51680011df4e8d.tar.bz2
New python function gdb.lookup_objfile.
gdb/ChangeLog: * NEWS: Mention gdb.lookup_objfile. * python/python.c (GdbMethods): Add lookup_objfile. * python/python-internal.h (gdbpy_lookup_objfile): Declare. * python/py-objfile.c: #include "symtab.h". (objfpy_build_id_ok, objfpy_build_id_matches): New functions. (objfpy_lookup_objfile_by_name): New function. (objfpy_lookup_objfile_by_build_id): New function. (gdbpy_lookup_objfile): New function. gdb/doc/ChangeLog: * python.texi (Objfiles In Python): Document gdb.lookup_objfile. gdb/testsuite/ChangeLog: * lib/gdb-python.exp (get_python_valueof): New function. * gdb.python/py-objfile.exp: Add tests for gdb.lookup_objfile.
Diffstat (limited to 'gdb/testsuite/gdb.python/py-objfile.exp')
-rw-r--r--gdb/testsuite/gdb.python/py-objfile.exp24
1 files changed, 23 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index f3a8a6c..5d3c084 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -32,23 +32,39 @@ if ![runto_main] then {
return 0
}
+set python_error_text "Error while executing Python code\\."
+
gdb_py_test_silent_cmd "python sym = gdb.lookup_symbol(\"some_var\")" \
"Find a symbol in objfile" 1
gdb_py_test_silent_cmd "python objfile = sym\[0\].symtab.objfile" \
"Get backing object file" 1
-gdb_test "python print (objfile.filename)" ".*py-objfile.*" \
+gdb_test "python print (objfile.filename)" "${testfile}" \
"Get objfile file name"
+gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
+ "${testfile}"
+gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
+ "Objfile not found\\.\r\n${python_error_text}"
+
set binfile_build_id [get_build_id $binfile]
if [string compare $binfile_build_id ""] {
verbose -log "binfile_build_id = $binfile_build_id"
gdb_test "python print (objfile.build_id)" "$binfile_build_id" \
"Get objfile build id"
+ gdb_test "python print (gdb.lookup_objfile (\"$binfile_build_id\", by_build_id=True).filename)" \
+ "${testfile}"
} else {
unsupported "build-id is not supported by the compiler"
}
+# Other lookup_objfile_by_build_id tests we can do, even if compiler doesn't
+# support them.
+gdb_test "python print (gdb.lookup_objfile (\"foo\", by_build_id=True))" \
+ "Not a valid build id\\.\r\n${python_error_text}"
+gdb_test "python print (gdb.lookup_objfile (\"1234abcdef\", by_build_id=True))" \
+ "Objfile not found\\.\r\n${python_error_text}"
+
gdb_test "python print (objfile.progspace)" "<gdb\.Progspace object at .*>" \
"Get objfile program space"
gdb_test "python print (objfile.is_valid())" "True" \
@@ -93,3 +109,9 @@ gdb_test "python print (sep_objfile.owner.filename)" "${testfile}2" \
gdb_test "p main" "= {int \\(\\)} $hex <main>" \
"print main with debug info"
+
+# Separate debug files are not findable.
+if { [get_python_valueof "sep_objfile.build_id" "None"] != "None" } {
+ gdb_test "python print (gdb.lookup_objfile (sep_objfile.build_id, by_build_id=True))" \
+ "Objfile not found\\.\r\n${python_error_text}"
+}