Jump to content

GStreamer Debugging: Difference between revisions

m
no edit summary
mNo edit summary
mNo edit summary
 
Line 15: Line 15:
To see what debug can be enabled, add <tt>--gst-debug-help</tt> to your GStreamer application arguments, such as:
To see what debug can be enabled, add <tt>--gst-debug-help</tt> to your GStreamer application arguments, such as:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
gst-launch --gst-debug-help
gst-launch --gst-debug-help
</syntaxhighlight>
</syntaxhighlight>
Line 21: Line 21:
Then you can see which debug you are interested in, such as reference counting and buffer movement, and enable all debug output (level output 5).
Then you can see which debug you are interested in, such as reference counting and buffer movement, and enable all debug output (level output 5).


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
gst-launch videotestsrc num-buffers=3 ! fakesink --gst-debug=GST_REFCOUNTING:5,GST_BUFFER:5 --gst-debug-no-color=1  2>&1 | grep "\->0" > log.txt
gst-launch videotestsrc num-buffers=3 ! fakesink --gst-debug=GST_REFCOUNTING:5,GST_BUFFER:5 --gst-debug-no-color=1  2>&1 | grep "\->0" > log.txt
</syntaxhighlight>
</syntaxhighlight>
Line 29: Line 29:
Another way you can generate the same output is set the <tt>GST_DEBUG</tt> shell variable:
Another way you can generate the same output is set the <tt>GST_DEBUG</tt> shell variable:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
GST_DEBUG=GST_REFCOUNTING:5 gst-launch videotestsrc num-buffers=3 ! fakesink
GST_DEBUG=GST_REFCOUNTING:5 gst-launch videotestsrc num-buffers=3 ! fakesink
</syntaxhighlight>
</syntaxhighlight>
Line 35: Line 35:
Here is a simple way to count the number of frames in a (h264/quicktime) video file:
Here is a simple way to count the number of frames in a (h264/quicktime) video file:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
MOVIE=slomo_1425510055_2.mov
MOVIE=slomo_1425510055_2.mov
gst-launch -v filesrc location=$MOVIE ! qtdemux ! ffdec_h264 ! fakesink | fgrep chain | wc -l
gst-launch -v filesrc location=$MOVIE ! qtdemux ! ffdec_h264 ! fakesink | fgrep chain | wc -l
Line 77: Line 77:
1) Install "dot" tool on your host machine...to do so simply install graphviz:
1) Install "dot" tool on your host machine...to do so simply install graphviz:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
sudo apt-get install graphviz
sudo apt-get install graphviz
</syntaxhighlight>
</syntaxhighlight>
Line 83: Line 83:
2) On your target board, set the environment dot dump variable:
2) On your target board, set the environment dot dump variable:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
export GST_DEBUG_DUMP_DOT_DIR=/root
export GST_DEBUG_DUMP_DOT_DIR=/root
mkdir -p $GST_DEBUG_DUMP_DOT_DIR
mkdir -p $GST_DEBUG_DUMP_DOT_DIR
Line 92: Line 92:
4) Convert the dot files to PNG image files or SVG graphics files
4) Convert the dot files to PNG image files or SVG graphics files


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
dot -Tpng input.dot > output.png
dot -Tpng input.dot > output.png


Line 112: Line 112:
Example usage:
Example usage:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
export GSTTL_HIDE="caps;chk;topo"
export GSTTL_HIDE="caps;chk;topo"
export GSTTL_LOG_SIZE=1048576
export GSTTL_LOG_SIZE=1048576
Line 130: Line 130:
Run the telnet daemon on the target - likely:
Run the telnet daemon on the target - likely:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
/etc/init.d/inetd start
/etc/init.d/inetd start


Line 140: Line 140:
telnet into the target hardware and watch the interrupt count
telnet into the target hardware and watch the interrupt count


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
while sleep 1 ; do cat /proc/interrupts ; done
while sleep 1 ; do cat /proc/interrupts ; done
</syntaxhighlight>
</syntaxhighlight>
Line 150: Line 150:
If your GStreamer application is crashing with a segfault or similar condition, enable saving a core dump before running the application.
If your GStreamer application is crashing with a segfault or similar condition, enable saving a core dump before running the application.


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
ulimit -c 100000
ulimit -c 100000
mkdir -m 777 /root/dumps
mkdir -m 777 /root/dumps
Line 158: Line 158:
Once you have a <tt>/root/dumps/*.core</tt> file, copy it to your workstation and and inspect it with
Once you have a <tt>/root/dumps/*.core</tt> file, copy it to your workstation and and inspect it with


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
ddd  -debugger arm-linux-gnueabi-gdb $GSTREAMER_APPLICATION
ddd  -debugger arm-linux-gnueabi-gdb $GSTREAMER_APPLICATION
</syntaxhighlight>
</syntaxhighlight>
Line 164: Line 164:
Then in gdb,
Then in gdb,


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
target core <core file>
target core <core file>
bt
bt
Line 181: Line 181:
For TI DMAI plugin and other gstreamer components in the RidgeRun SDK, the can be done via:
For TI DMAI plugin and other gstreamer components in the RidgeRun SDK, the can be done via:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
cd $DEVDIR/proprietary/gst-dmai-plugins
cd $DEVDIR/proprietary/gst-dmai-plugins
make clean
make clean
Line 195: Line 195:
Attach to your running GStreamer application using gdbserver
Attach to your running GStreamer application using gdbserver


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
ps
ps
PID=4512 # set the right value based on your application's PID
PID=4512 # set the right value based on your application's PID
Line 203: Line 203:
Then start the cross-compile version of the GNU debugger, like
Then start the cross-compile version of the GNU debugger, like


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
arm-linux-gnueabi-gdb -tui $GSTREAMER_APP
arm-linux-gnueabi-gdb -tui $GSTREAMER_APP
</syntaxhighlight>
</syntaxhighlight>
Line 209: Line 209:
and get the gdb debugger connected to gdb server on the target
and get the gdb debugger connected to gdb server on the target


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
set solib-absolute-prefix <path to devdir>/fs/fs
set solib-absolute-prefix <path to devdir>/fs/fs
file <path to file>
file <path to file>
Line 217: Line 217:
List the threads and do a backtrace on each one
List the threads and do a backtrace on each one


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
info threads
info threads
bt
bt
Line 230: Line 230:
On the target (assuming your program's name is <tt>gstd</tt>), first list the PIDs for all the threads in your application:
On the target (assuming your program's name is <tt>gstd</tt>), first list the PIDs for all the threads in your application:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
PROG=gstd
PROG=gstd
ls /proc/`pidof $PROG`/task
ls /proc/`pidof $PROG`/task
Line 237: Line 237:
Then start gdbserver in multi-process mode:
Then start gdbserver in multi-process mode:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
gdbserver --multi :2345
gdbserver --multi :2345
</syntaxhighlight>
</syntaxhighlight>
Line 243: Line 243:
Then on the host start the cross-compile version of the GNU debugger, like
Then on the host start the cross-compile version of the GNU debugger, like


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
arm-linux-gnueabi-gdb -tui $GSTREAMER_APP
arm-linux-gnueabi-gdb -tui $GSTREAMER_APP
</syntaxhighlight>
</syntaxhighlight>
Line 249: Line 249:
and get the gdb debugger connected to gdb server on the target
and get the gdb debugger connected to gdb server on the target


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
set solib-absolute-prefix <path to devdir>/fs/fs
set solib-absolute-prefix <path to devdir>/fs/fs
file <path to file>
file <path to file>
Line 257: Line 257:
Now you can attach to a specific PID, do a backtrack, snoop around, and detach from that PID.  Once detached, you can do the same thing again using a different PID from the output of the <tt>ls</tt> command above.
Now you can attach to a specific PID, do a backtrack, snoop around, and detach from that PID.  Once detached, you can do the same thing again using a different PID from the output of the <tt>ls</tt> command above.


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
attach <pid>
attach <pid>
bt
bt
Line 300: Line 300:
If you are using the TI DMAI GStreamer plug-in for the TI Davinci and OMAP SoCs, then you can enable DMAI debug to get more information if a hardware-accelerated encoder or decoder is throwing an error.
If you are using the TI DMAI GStreamer plug-in for the TI Davinci and OMAP SoCs, then you can enable DMAI debug to get more information if a hardware-accelerated encoder or decoder is throwing an error.


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
DMAI_DEBUG=2 gst-launch -e alsasrc num-buffers=50 ! 'audio/x-raw-int,rate=(int)44100,channels=(int)2' ! queue ! dmaienc_aac bitrate=128000 ! qtmux ! filesink location=gstaudio_aac_2ch_128k.mp4
DMAI_DEBUG=2 gst-launch -e alsasrc num-buffers=50 ! 'audio/x-raw-int,rate=(int)44100,channels=(int)2' ! queue ! dmaienc_aac bitrate=128000 ! qtmux ! filesink location=gstaudio_aac_2ch_128k.mp4
</syntaxhighlight>
</syntaxhighlight>
Line 308: Line 308:
If you are using the TI DMAI GStreamer plug-in for the TI Davinci and OMAP SoCs, then you can enable CE debug to get more information if a hardware-accelerated encoder or decoder is throwing an error.  Note that the stack is GStreamer DMAI plug-in which uses DMAI which uses CE which uses codecs that take advantage of the hardware accelerators.
If you are using the TI DMAI GStreamer plug-in for the TI Davinci and OMAP SoCs, then you can enable CE debug to get more information if a hardware-accelerated encoder or decoder is throwing an error.  Note that the stack is GStreamer DMAI plug-in which uses DMAI which uses CE which uses codecs that take advantage of the hardware accelerators.


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
CE_DEBUG=3 gst-launch -e alsasrc num-buffers=50 ! 'audio/x-raw-int,rate=(int)44100,channels=(int)2' ! queue ! dmaienc_aac bitrate=128000 ! qtmux ! filesink location=gstaudio_aac_2ch_128k.mp4
CE_DEBUG=3 gst-launch -e alsasrc num-buffers=50 ! 'audio/x-raw-int,rate=(int)44100,channels=(int)2' ! queue ! dmaienc_aac bitrate=128000 ! qtmux ! filesink location=gstaudio_aac_2ch_128k.mp4
</syntaxhighlight>
</syntaxhighlight>
Line 314: Line 314:
And you can combine DMAI and CE debug
And you can combine DMAI and CE debug


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
CE_DEBUG=3 DMAI_DEBUG=2 gst-launch -e alsasrc num-buffers=50 ! 'audio/x-raw-int,rate=(int)44100,channels=(int)2' ! queue ! dmaienc_aac bitrate=128000 ! qtmux ! filesink location=gstaudio_aac_2ch_128k.mp4
CE_DEBUG=3 DMAI_DEBUG=2 gst-launch -e alsasrc num-buffers=50 ! 'audio/x-raw-int,rate=(int)44100,channels=(int)2' ! queue ! dmaienc_aac bitrate=128000 ! qtmux ! filesink location=gstaudio_aac_2ch_128k.mp4
</syntaxhighlight>
</syntaxhighlight>
Line 320: Line 320:
To write the debug to a file on tmpfs, which should reduce the performance impact of enabling debug, add  
To write the debug to a file on tmpfs, which should reduce the performance impact of enabling debug, add  


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
2>&1 | cat - > /tmp/gst-debug.txt
2>&1 | cat - > /tmp/gst-debug.txt
</syntaxhighlight>
</syntaxhighlight>
Line 330: Line 330:
If you are creating files on a network-connected embedded device, you can use NFS mount (which is different than NFS root mount) so that once you generate a file, it is easy to get it on your desktop machine.  For any real-time debugging, don't use NFS root mount as the network activity will affect the timing of your pipelines.  See [[Setting Up A NFS Service]] for instructions on configuring your desktop machine.
If you are creating files on a network-connected embedded device, you can use NFS mount (which is different than NFS root mount) so that once you generate a file, it is easy to get it on your desktop machine.  For any real-time debugging, don't use NFS root mount as the network activity will affect the timing of your pipelines.  See [[Setting Up A NFS Service]] for instructions on configuring your desktop machine.


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
HOST_IP=10.0.1.1
HOST_IP=10.0.1.1
HOST_NFS_SHARE_DIR=/local/home/tfischer/work/sdk/fs/fs
HOST_NFS_SHARE_DIR=/local/home/tfischer/work/sdk/fs/fs
Line 360: Line 360:
Add the following to your application's command line parameters:
Add the following to your application's command line parameters:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
--gst-debug=GST_REFCOUNTING:5
--gst-debug=GST_REFCOUNTING:5
</syntaxhighlight>
</syntaxhighlight>
Line 366: Line 366:
Another option is to set the GStreamer debugging shell variable, then run your program:
Another option is to set the GStreamer debugging shell variable, then run your program:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
export GST_DEBUG=GST_REFCOUNTING:5
export GST_DEBUG=GST_REFCOUNTING:5
</syntaxhighlight>
</syntaxhighlight>
Line 376: Line 376:
You can see which objects disappear, meaning their reference count reaches zero:
You can see which objects disappear, meaning their reference count reaches zero:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
gst-launch --gst-debug=GST_REFCOUNTING:5 videotestsrc num-buffers=3 ! fakesink 2>&1 | grep "\->0" | cut -d' ' -f 19
gst-launch --gst-debug=GST_REFCOUNTING:5 videotestsrc num-buffers=3 ! fakesink 2>&1 | grep "\->0" | cut -d' ' -f 19
</syntaxhighlight>
</syntaxhighlight>
Line 388: Line 388:
If your application generates output, you can redirect it to Syslog as follows:
If your application generates output, you can redirect it to Syslog as follows:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
MY_APP=gst-render
MY_APP=gst-render


Line 405: Line 405:


With MP4Box you can use the -info in order to get more info from a generated mp4 file:
With MP4Box you can use the -info in order to get more info from a generated mp4 file:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
MP4Box -info test.mp4
MP4Box -info test.mp4
</syntaxhighlight>
</syntaxhighlight>
Line 413: Line 413:
If you are creating an element you plan to use in an embedded device, you might find it helpful to build and test the element on your development machine first.
If you are creating an element you plan to use in an embedded device, you might find it helpful to build and test the element on your development machine first.


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
./autogen.sh
./autogen.sh
CFLAGS=-ggdb ./configure
CFLAGS=-ggdb ./configure
Line 422: Line 422:
Use GST_PLUGIN_PATH to enable GStreamer to find your element library:
Use GST_PLUGIN_PATH to enable GStreamer to find your element library:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
export GST_PLUGIN_PATH=$HOME/projects/gst-emboverlay/src/.libs  
export GST_PLUGIN_PATH=$HOME/projects/gst-emboverlay/src/.libs  
gst-inspect emboverlay
gst-inspect emboverlay
Line 429: Line 429:
Test out your element.  Better to use GStreamer daemon than gst-launch.
Test out your element.  Better to use GStreamer daemon than gst-launch.


<syntaxhighlight lang='bash'>
<syntaxhighlight lang="bash">
TEXT_OVERLAY="text=Hello\ There text-offseth=50 text-offsetv=100 text-font-height=50 text-color=0x800040 text-enable=true"
TEXT_OVERLAY="text=Hello\ There text-offseth=50 text-offsetv=100 text-font-height=50 text-color=0x800040 text-enable=true"
TEXT2_OVERLAY="text2=World text2-offseth=50 text2-offsetv=150 text2-font-height=50 text2-color=0x800040 text2-enable"
TEXT2_OVERLAY="text2=World text2-offseth=50 text2-offsetv=150 text2-font-height=50 text2-color=0x800040 text2-enable"
Line 463: Line 463:
* [[GStreamer_Debugging_Using_GDB |'''GStreamer Debugging Using GDB''']]
* [[GStreamer_Debugging_Using_GDB |'''GStreamer Debugging Using GDB''']]


==Contact Us==
{{ContactUs}}
{{ContactUs}}


[[Category:GStreamer]][[Category:Debug]][[Category:HowTo]][[Category:Whitepaper]][[Category:Jetson]]
[[Category:GStreamer]][[Category:Debug]][[Category:HowTo]][[Category:Whitepaper]][[Category:Jetson]]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.