+def gst_object_from_value(value):
+ if value.type.code != gdb.TYPE_CODE_PTR:
+ value = value.address
+
+ if not is_gst_type(value, "GstObject"):
+ raise Exception("'%s' is not a GstObject" % args[0])
+
+ return value.cast(gdb.lookup_type("GstObject").pointer())
+
+
+def gst_object_pipeline(obj):
+ try:
+ while obj["parent"] != 0:
+ tmp = obj["parent"]
+ # sanity checks to handle memory corruption
+ if g_inherits_type(obj, "GstElement") and \
+ GdbGstElement(obj) not in GdbGstElement(tmp).children():
+ break
+ if g_inherits_type(obj, "GstPad") and \
+ GdbGstPad(obj) not in GdbGstElement(tmp).pads():
+ break
+ obj = tmp
+ except gdb.MemoryError:
+ pass
+
+ if not g_inherits_type(obj, "GstElement"):
+ raise Exception("Toplevel parent is not a GstElement")
+ return obj.cast(gdb.lookup_type("GstElement").pointer())
+
+