gdb: add gst_element_pad() function
authorMichael Olbrich <m.olbrich@pengutronix.de>
Sun, 12 May 2019 05:45:31 +0000 (07:45 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 24 May 2019 10:37:50 +0000 (10:37 +0000)
Another helper to navigate a pipeline. It makes it possible to easily
access the pads of an element:

(gdb) print $gst_element_pad(basesink, "sink")
$1 = 0x7fffe80770f0 [GstPad|sink]

libs/gst/helpers/gst_gdb.py

index 114d2e7..e475c9f 100644 (file)
@@ -1157,8 +1157,35 @@ Find a child element with the given name"""
         return child
 
 
+class GstElementPad(gdb.Function):
+    """\
+Get the pad with the given name"""
+
+    def __init__(self):
+        super(GstElementPad, self).__init__("gst_element_pad")
+
+    def invoke(self, element, arg):
+        value = gst_object_from_value(element)
+        if not g_inherits_type(value, "GstElement"):
+            raise Exception("'%s' is not a GstElement" %
+                            str(value.address))
+
+        try:
+            name = arg.string()
+        except gdb.error:
+            raise Exception("Usage: $gst_element_pad(<gst-object>, \"<pad-name>\")")
+
+        obj = GdbGstElement(value)
+        for pad in obj.pads():
+            if pad.name() == name:
+                return pad.val
+
+        raise Exception("No pad named '%s' found." % name)
+
+
 GstPipeline()
 GstBinGet()
+GstElementPad()
 
 
 def register(obj):