gdb: add 'gst-pipeline-tree' command
authorMichael Olbrich <m.olbrich@pengutronix.de>
Sat, 11 May 2019 19:02:37 +0000 (21:02 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 24 May 2019 10:37:50 +0000 (10:37 +0000)
It shows a simple tree of all elements in pipeline.
As with gst-dot, the toplevel bin is found from any element of the
pipeline:

(gdb) gst-pipeline-tree bsink
playbin
  inputselector1
  inputselector0
  uridecodebin0
    queue2-0
    decodebin0
      avdec_aac0
      aacparse0
      vaapidecodebin0
        vaapipostproc0
        capsfilter1
        vaapi-queue
        vaapidecode0
      capsfilter0
      h264parse0
      multiqueue0
      matroskademux0
      typefind
    typefindelement0
    source
  playsink
    abin
      aconv
        resample
        conv
        identity
      aqueue
      pulsesink0
    vbin
      vconv
        scale
        conv
        identity
      vqueue
      vaapisink0
    vdbin
      deinterlace
      vdconv
    audiotee
    streamsynchronizer0

libs/gst/helpers/gst_gdb.py

index 597e9bf..1159e97 100644 (file)
@@ -871,6 +871,12 @@ class GdbGstElement(GdbGstObject):
 
         _gdb_write(indent, "}")
 
+    @save_memory_access_print("<inaccessible memory>")
+    def print_tree(self, indent):
+        _gdb_write(indent, "%s" % self.name())
+        for child in self.children():
+            child.print_tree(indent+1)
+
     def _dot(self, indent=0):
         spc = "  " * indent
 
@@ -1049,8 +1055,31 @@ Usage gst-print <gstreamer-object>"""
         obj.print(0)
 
 
+class GstPipelineTree(gdb.Command):
+    """\
+Usage: gst-pipeline-tree <gst-object>"""
+    def __init__(self):
+        super(GstPipelineTree, self).__init__("gst-pipeline-tree",
+                                              gdb.COMPLETE_SYMBOL)
+
+    def invoke(self, arg, from_tty):
+        self.dont_repeat()
+        args = gdb.string_to_argv(arg)
+        if len(args) != 1:
+            raise Exception("Usage: gst-pipeline-tree <gst-object>")
+
+        value = gdb.parse_and_eval(args[0])
+        if not value:
+            raise Exception("'%s' is not a valid object" % args[0])
+
+        value = gst_object_from_value(value)
+        value = gst_object_pipeline(value)
+        GdbGstElement(value).print_tree(0)
+
+
 GstDot()
 GstPrint()
+GstPipelineTree()
 
 
 class GstPipeline(gdb.Function):