From 6258ee56d207b6f95c406362212314777e66f06c Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Thu, 31 Aug 2023 18:43:46 -0400 Subject: [PATCH] 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 : 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: --- .../libs/gst/helpers/glib_gobject_helper.py | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/subprojects/gstreamer/libs/gst/helpers/glib_gobject_helper.py b/subprojects/gstreamer/libs/gst/helpers/glib_gobject_helper.py index 5b08c386ba..85df3d1d0f 100644 --- a/subprojects/gstreamer/libs/gst/helpers/glib_gobject_helper.py +++ b/subprojects/gstreamer/libs/gst/helpers/glib_gobject_helper.py @@ -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 ##