mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 19:21:06 +00:00
bc621cc335
This adds gdb pretty printer for some GStreamer types. For GstObject pointers the type and name is added, e.g. "0x5555557e4110 [GstDecodeBin|decodebin0]". For GstMiniObject pointers the object type is added, e.g. "0x7fffe001fc50 [GstBuffer]". For GstClockTime and GstClockTimeDiff the time is also printed in human readable form, e.g. "150116219955 [+0:02:30.116219955]". Fixes #320
70 lines
1.8 KiB
Python
70 lines
1.8 KiB
Python
##
|
|
## imported from glib: glib/glib_gdb.py
|
|
##
|
|
import gdb
|
|
import sys
|
|
|
|
if sys.version_info[0] >= 3:
|
|
long = int
|
|
|
|
# This is not quite right, as local vars may override symname
|
|
def read_global_var (symname):
|
|
return gdb.selected_frame().read_var(symname)
|
|
|
|
def g_quark_to_string (quark):
|
|
if quark is None:
|
|
return None
|
|
quark = long(quark)
|
|
if quark == 0:
|
|
return None
|
|
try:
|
|
val = read_global_var ("quarks")
|
|
max_q = long(read_global_var ("quark_seq_id"))
|
|
except:
|
|
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()
|
|
return None
|
|
|
|
##
|
|
## imported from glib: gobject/gobject_gdb.py
|
|
##
|
|
|
|
def g_type_to_typenode (gtype):
|
|
def lookup_fundamental_type (typenode):
|
|
if typenode == 0:
|
|
return None
|
|
val = read_global_var ("static_fundamental_type_nodes")
|
|
if val is None:
|
|
return None
|
|
return val[typenode >> 2].address
|
|
|
|
gtype = long(gtype)
|
|
typenode = gtype - gtype % 4
|
|
if typenode > (255 << 2):
|
|
typenode = gdb.Value(typenode).cast (gdb.lookup_type("TypeNode").pointer())
|
|
else:
|
|
typenode = lookup_fundamental_type (typenode)
|
|
return typenode
|
|
|
|
def g_type_to_name (gtype):
|
|
typenode = g_type_to_typenode(gtype)
|
|
if typenode != None:
|
|
return g_quark_to_string (typenode["qname"])
|
|
return None
|
|
|
|
def g_type_name_from_instance (instance):
|
|
if long(instance) != 0:
|
|
try:
|
|
inst = instance.cast (gdb.lookup_type("GTypeInstance").pointer())
|
|
klass = inst["g_class"]
|
|
gtype = klass["g_type"]
|
|
name = g_type_to_name (gtype)
|
|
return name
|
|
except RuntimeError:
|
|
pass
|
|
return None
|