mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
gobject.py: Don't install frame filters when GDB does not support them
Stock GDB (both versions 7.0 and 7.1) does not come with the new backtrace code and python API. To prevent an ugly python backtrace when auto-loading gobject.py, let's catch the exception and not register the FrameWrapper and the FrameFilter. https://bugzilla.gnome.org/show_bug.cgi?id=613732
This commit is contained in:
parent
4846fd923d
commit
91d4659bbf
@ -1,7 +1,15 @@
|
|||||||
|
import os.path
|
||||||
import gdb
|
import gdb
|
||||||
import glib
|
import glib
|
||||||
import gdb.backtrace
|
try:
|
||||||
import gdb.command.backtrace
|
import gdb.backtrace
|
||||||
|
import gdb.command.backtrace
|
||||||
|
except ImportError:
|
||||||
|
print(os.path.basename(__file__) + ": gdb was not built with "
|
||||||
|
"custom backtrace support, disabling.")
|
||||||
|
HAVE_GDB_BACKTRACE = 0
|
||||||
|
else:
|
||||||
|
HAVE_GDB_BACKTRACE = 1
|
||||||
|
|
||||||
# This is not quite right, as local vars may override symname
|
# This is not quite right, as local vars may override symname
|
||||||
def read_global_var (symname):
|
def read_global_var (symname):
|
||||||
@ -107,13 +115,14 @@ class GFrameWrapper:
|
|||||||
return getattr (self.frame, name)
|
return getattr (self.frame, name)
|
||||||
|
|
||||||
# Monkey patch FrameWrapper to avoid IA__ in symbol names
|
# Monkey patch FrameWrapper to avoid IA__ in symbol names
|
||||||
old__init__ = gdb.command.backtrace.FrameWrapper.__init__
|
if HAVE_GDB_BACKTRACE:
|
||||||
def monkey_patched_init(self, frame):
|
old__init__ = gdb.command.backtrace.FrameWrapper.__init__
|
||||||
name = frame.name()
|
def monkey_patched_init(self, frame):
|
||||||
if name and name.startswith("IA__"):
|
name = frame.name()
|
||||||
frame = GFrameWrapper(frame)
|
if name and name.startswith("IA__"):
|
||||||
old__init__(self,frame)
|
frame = GFrameWrapper(frame)
|
||||||
gdb.command.backtrace.FrameWrapper.__init__ = monkey_patched_init
|
old__init__(self,frame)
|
||||||
|
gdb.command.backtrace.FrameWrapper.__init__ = monkey_patched_init
|
||||||
|
|
||||||
class DummyFrame:
|
class DummyFrame:
|
||||||
def __init__ (self, frame):
|
def __init__ (self, frame):
|
||||||
@ -301,5 +310,6 @@ def register (obj):
|
|||||||
if obj == None:
|
if obj == None:
|
||||||
obj = gdb
|
obj = gdb
|
||||||
|
|
||||||
gdb.backtrace.push_frame_filter (GFrameFilter)
|
if HAVE_GDB_BACKTRACE:
|
||||||
|
gdb.backtrace.push_frame_filter (GFrameFilter)
|
||||||
obj.pretty_printers.append(pretty_printer_lookup)
|
obj.pretty_printers.append(pretty_printer_lookup)
|
||||||
|
Loading…
Reference in New Issue
Block a user