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.
This commit is contained in:
parent
fc46f98d5d
commit
219c04fc3b
2 changed files with 11 additions and 1 deletions
|
@ -513,7 +513,7 @@ objfpy_repr (PyObject *self_)
|
||||||
return PyString_FromString ("<gdb.Objfile (invalid)>");
|
return PyString_FromString ("<gdb.Objfile (invalid)>");
|
||||||
|
|
||||||
return PyString_FromFormat ("<gdb.Objfile filename=%s>",
|
return PyString_FromFormat ("<gdb.Objfile filename=%s>",
|
||||||
objfile_filename (obj));
|
objfile_name (obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Subroutine of gdbpy_lookup_objfile_by_build_id to simplify it.
|
/* Subroutine of gdbpy_lookup_objfile_by_build_id to simplify it.
|
||||||
|
|
|
@ -227,6 +227,16 @@ proc jit_reader_test {} {
|
||||||
"Attempt to assign to an unmodifiable value\." \
|
"Attempt to assign to an unmodifiable value\." \
|
||||||
"cannot assign to register"
|
"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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue