gstreamer调试手段

代码调试手段

添加打印


#define GST_ERROR(...)	GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_ERROR,   NULL, __VA_ARGS__)
#define GST_WARNING(...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_WARNING, NULL, __VA_ARGS__)
#define GST_INFO(...)	GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_INFO,    NULL, __VA_ARGS__)
#define GST_DEBUG(...)	GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   NULL, __VA_ARGS__)
#define GST_LOG(...)	GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_LOG,     NULL, __VA_ARGS__)
#define GST_FIXME(...)	GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_FIXME,   NULL, __VA_ARGS__)
#define GST_TRACE(...)	GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_TRACE,   NULL, __VA_ARGS__)

gdb

确保core文件大小限制解除


fuqiang@fuqiang-VivoBook:/usr/lib/x86_64-linux-gnu$ ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) 0
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
...

fuqiang@fuqiang-VivoBook:/usr/lib/x86_64-linux-gnu$ ulimit -c unlimited

fuqiang@fuqiang-VivoBook:/usr/lib/x86_64-linux-gnu$ ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) unlimited
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
...

确认core文件的位置


sudo service apport stop

cat /proc/sys/kernel/core_pattern

echo core > /proc/sys/kernel/core_pattern

制造崩溃


static void
gst_mydecoder_init (Gstmydecoder * filter)
{
  GST_ERROR("gst_mydecoder_init");
  char *str = NULL;
	str[0] = 0;

  filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");

执行


fuqiang@fuqiang-VivoBook:~/workspace/gstreamer$ gst-launch-1.0 --gst-debug=3 videotestsrc ! mydecoder ! autovideosink

(gst-launch-1.0:911980): GStreamer-CRITICAL **: 18:18:11.516: gst_debug_log_valist: assertion 'category != NULL' failed
0:00:00.016936571 911980 0x558ab0cca100 ERROR              mydecoder gstmydecoder.c:123:gst_mydecoder_class_init: gst_mydecoder_class_init
0:00:00.016957593 911980 0x558ab0cca100 ERROR              mydecoder gstmydecoder.c:158:gst_mydecoder_init: gst_mydecoder_init
Caught SIGSEGV
Spinning.  Please run 'gdb gst-launch-1.0 911980' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core

执行CTRL-\后生成core dump文件


fuqiang@fuqiang-VivoBook:~/workspace/gstreamer$ ls -al
总用量 4380
drwxrwxr-x 13 fuqiang fuqiang    4096  7月 20 18:18 .
drwxrwxr-x  6 fuqiang fuqiang    4096  7月 19 14:58 ..
drwxrwxr-x  8 fuqiang fuqiang    4096  7月 18 08:57 ci
-rw-------  1 fuqiang fuqiang 4599808  7月 20 18:18 core.911980
drwxrwxr-x  5 fuqiang fuqiang    4096  7月 16 20:51 data
-rw-rw-r--  1 fuqiang fuqiang     131  7月 18 08:57 .editorconfig
drwxrwxr-x  8 fuqiang fuqiang    4096  7月 20 16:44 .git
-rw-rw-r--  1 fuqiang fuqiang    1064  7月 16 20:51 .gitignore
drwxrwxr-x  3 fuqiang fuqiang    4096  7月 16 20:51 .gitlab
...

gdb调试


fuqiang@fuqiang-VivoBook:~/workspace/gstreamer$ gdb gst-launch-1.0 core.911980 
GNU gdb (Ubuntu 12.0.90-0ubuntu1) 12.0.90
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gst-launch-1.0...
[New LWP 911980]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `gst-launch-1.0 --gst-debug=3 videotestsrc ! mydecoder ! autovideosink'.
Program terminated with signal SIGQUIT, Quit.
#0  0x00007fdda845b7fa in __GI___clock_nanosleep (clock_id=clock_id@entry=0, flags=flags@entry=0, req=0x7ffeed177940, rem=0x7ffeed177930)
    at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78
78	../sysdeps/unix/sysv/linux/clock_nanosleep.c: 没有那个文件或目录.
(gdb) 

bt调出堆栈后可以查看问题所在


gst_mydecoder_init (filter=<optimized out>) at ../subprojects/gst-plugins-bad/gst/mydecoder/gstmydecoder.c:160
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代码论斤卖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值