gdb: Workaround optimized out quark_seq_id

On fedora 38 (and it was the case in previous releases), the
quark_seq_id is optimized out so getting quarks from the
global variable always failed. This patch works around that by assuming
it is a valid quark whenever the quark_seq_id is not accessible.

This issue often manifested as Python Exception <class 'TypeError'>:
can only concatenate str (not "NoneType") to str when debugging as
other parts of the code assume that getting the quark for a GType name
will work.

Same as https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3559

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5986>
This commit is contained in:
Thibault Saunier 2023-08-31 18:43:46 -04:00 committed by GStreamer Marge Bot
parent 3855646f1d
commit 6258ee56d2

View file

@ -1,5 +1,5 @@
##
## imported from glib: glib/glib_gdb.py
# imported from glib: glib/glib_gdb.py
##
import gdb
import sys
@ -11,23 +11,35 @@ if sys.version_info[0] >= 3:
def read_global_var (symname):
return gdb.selected_frame().read_var(symname)
def g_quark_to_string (quark):
def g_quark_to_string(quark):
if quark is None:
return None
quark = long(quark)
if quark == 0:
return None
max_q = None
try:
val = read_global_var ("quarks")
max_q = long(read_global_var ("quark_seq_id"))
except:
val = read_global_var("quarks")
try:
val = read_global_var ("g_quarks")
max_q = long(read_global_var ("g_quark_seq_id"))
except:
return None;
if quark < max_q:
return val[quark].string()
max_q = long(read_global_var("quark_seq_id"))
# quark_seq_id gets optimized out in some builds so work around it
except gdb.error:
pass
except Exception:
try:
val = read_global_var("g_quarks")
try:
max_q = long(read_global_var("g_quark_seq_id"))
except gdb.error:
pass
except Exception:
return None
if max_q is None or quark < max_q:
try:
return val[quark].string()
except gdb.MemoryError:
print("Invalid quark %d" % quark)
return None
##