aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Vrany <jan.vrany@labware.com>2022-02-01 14:49:30 +0000
committerJan Vrany <jan.vrany@labware.com>2022-02-01 14:49:30 +0000
commit219c04fc3b3f7e7e19fc5f8d47e5036c7a80377f (patch)
tree4f273d75ba24cd29d8f912d2c507504187dbd853
parentfc46f98d5db8229cbb81db9012c514982fa1c979 (diff)
downloadbinutils-219c04fc3b3f7e7e19fc5f8d47e5036c7a80377f.zip
binutils-219c04fc3b3f7e7e19fc5f8d47e5036c7a80377f.tar.gz
binutils-219c04fc3b3f7e7e19fc5f8d47e5036c7a80377f.tar.bz2
gdb/python: fix gdb.Objfile.__repr__ () for dynamically compiled code
While experimenting with JIT reader API I realized that calling repr () on objfile created by JIT reader crashes GDB. The problem was that objfpy_repr () called objfile_filename () which returned NULL, causing PyString_FromFormat () to crash. This commit fixes this problem by using objfile_name () instead of objfile_filename (). This also makes consistent with the value of gdb.Objfile.filename variable.
-rw-r--r--gdb/python/py-objfile.c2
-rw-r--r--gdb/testsuite/gdb.base/jit-reader.exp10
2 files changed, 11 insertions, 1 deletions
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 6055a42..48d2eb3 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -513,7 +513,7 @@ objfpy_repr (PyObject *self_)
return PyString_FromString ("<gdb.Objfile (invalid)>");
return PyString_FromFormat ("<gdb.Objfile filename=%s>",
- objfile_filename (obj));
+ objfile_name (obj));
}
/* Subroutine of gdbpy_lookup_objfile_by_build_id to simplify it.
diff --git a/gdb/testsuite/gdb.base/jit-reader.exp b/gdb/testsuite/gdb.base/jit-reader.exp
index 7ee16d6..bcc8564 100644
--- a/gdb/testsuite/gdb.base/jit-reader.exp
+++ b/gdb/testsuite/gdb.base/jit-reader.exp
@@ -227,6 +227,16 @@ proc jit_reader_test {} {
"Attempt to assign to an unmodifiable value\." \
"cannot assign to register"
}
+
+ if { ![skip_python_tests] } {
+ gdb_test "python print(gdb.objfiles())" \
+ "$any<gdb.Objfile filename=<< JIT compiled code >>>$any" \
+ "python gdb.Objfile.__repr__ ()"
+
+ gdb_test "python print(list(map(lambda objf : objf.filename, gdb.objfiles())))" \
+ "$any'<< JIT compiled code >>'$any" \
+ "python gdb.Objfile.filename"
+ }
}
}