How do I debug a gst-launch-1.0 pipeline using gdb?

To debug gst-launch-1.0 using GDB, you can follow these steps:

  1. Install GDB if you haven’t already:
    sudo apt-get install gdb

  2. Launch GDB with gst-launch-1.0 as the executable:
    gdb gst-launch-1.0

  3. In GDB, set any necessary environment variables for GStreamer debugging. For example, you can set the GST_DEBUG variable to control the debug output verbosity level:
    (gdb) set environment GST_DEBUG=3
    Adjust the value of GST_DEBUG according to your debugging needs.

  4. Set any breakpoints or perform any other necessary GDB configurations. For example, to set a breakpoint at the gst-launch-1.0 main function, use:
    (gdb) break main

  5. Start the debugging session:
    (gdb) run <your_gstreamer_pipeline>
    Replace <your_gstreamer_pipeline> with the actual GStreamer pipeline you want to debug.

  6. GDB will now execute gst-launch-1.0, and you can interact with it through GDB. You can use GDB commands such as step, next, continue, and print to control the execution and inspect variables.

  7. If a breakpoint is hit, GDB will pause the execution, and you can examine the program state, stack frames, and variables.

  8. Continue stepping through the program or using other GDB commands until you have debugged the issue or collected the necessary information.

Remember that gst-launch-1.0 is a command-line tool that launches GStreamer pipelines. Debugging it with GDB allows you to inspect its execution but does not provide direct control over individual elements in the pipeline.

To get relevant functions to add as breakpoint you can run this code to parse your .so file.
nm -C --defined-only | grep ' T '

For example, for debugging the detection post process function.
Run this to get the post process available functions:
nm -C --defined-only $TAPPAS_WORKSPACE/apps/h8/gstreamer/libs/post_processes// | grep ' T '

The expected output is:
0000000000010200 T filter
000000000000fcd0 T yolov5
00000000000107b0 T yolov5m_vehicles
0000000000010ce0 T yolov5_no_persons
0000000000010290 T yolox
000000000000f600 T common::nms(std::vector<HailoDetection, std::allocator >&, float, bool)
0000000000008950 T common::iou_calc(HailoBBox const&, HailoBBox const&)

You can use the ‘yolov5’ to set a break point.

Note that debugging full CPP / Python applications running Gstreamer can be done using more sophisticated tools like VSCode.
If your symbols or code are not human readable make sure you compile it in debug mode.
To compile TAPPAS code in debug mode use:
$TAPPAS_WORKSPACE/scripts/gstreamer/ --build-mode debug