驱动中回溯函数的调用关系
1.只需要在想要回溯的函数中调用dump_stack()即可。
dump_stack()在~/kernel/ lib/Dump_stack.c中定义,使用时可能需要包含头文件#include <asm/ptrace.h>
例如:
1 int max9211_s_stream(struct v4l2_subdev *sd, int enable) 2 { 3 int ret = 0; 4 struct max9211_priv *priv = container_of(sd, struct max9211_priv, subdev); 5 u8 con = !!enable; 6 7 switch(con){ 8 case 0: 9 dump_stack(); 10 break; 11 case 1: 12 ret = max9211_init(priv->client, priv); 13 dump_stack(); 14 break; 15 } 16 17 return ret; 18 }
在max9211_s_stream()中加入dump_stack()打印出的调用关系
[ 47.489191] [<ffff000008087c00>] dump_backtrace+0x0/0x1a8
[ 47.494584] [<ffff000008087dbc>] show_stack+0x14/0x20
[ 47.499633] [<ffff00000834867c>] dump_stack+0x94/0xb8
[ 47.504682] [<ffff000008382830>] max9211_s_stream+0x1a8/0x1d8
[ 47.510428] [<ffff00000852c950>] __rvin_start_streaming+0x118/0x168
[ 47.516690] [<ffff00000852dbd4>] rvin_start_streaming+0x24/0x118
[ 47.522692] [<ffff000008517c8c>] vb2_start_streaming+0x64/0x150
[ 47.528606] [<ffff000008519bdc>] vb2_core_streamon+0x16c/0x1a0
[ 47.534432] [<ffff00000851c3f4>] vb2_streamon+0x3c/0x60
[ 47.539650] [<ffff00000851c460>] vb2_ioctl_streamon+0x48/0x58
[ 47.545391] [<ffff000008502298>] v4l_streamon+0x20/0x28
[ 47.550610] [<ffff00000850614c>] __video_do_ioctl+0x25c/0x2c8
[ 47.556349] [<ffff000008505c88>] video_usercopy+0x230/0x478
[ 47.561914] [<ffff000008505ee4>] video_ioctl2+0x14/0x20
[ 47.567132] [<ffff000008500ef8>] v4l2_ioctl+0xe8/0x118
[ 47.572267] [<ffff0000081d1ddc>] do_vfs_ioctl+0xa4/0x740
[ 47.577572] [<ffff0000081d2504>] SyS_ioctl+0x8c/0xa0
[ 47.582531] [<ffff00000808274c>] __sys_trace_return+0x0/0x4
__rvin_start_streaming中可以看出根本就没有检测它的返回值!!!它的第二个参数传入的是1
使用ctrl+c结束时打印:
[ 71.141528] [<ffff000008087c00>] dump_backtrace+0x0/0x1a8
[ 71.146923] [<ffff000008087dbc>] show_stack+0x14/0x20
[ 71.151972] [<ffff00000834867c>] dump_stack+0x94/0xb8
[ 71.157021] [<ffff0000083828a0>] max9211_s_stream+0x190/0x1e0
[ 71.162766] [<ffff00000852d048>] __rvin_stop_streaming+0x100/0x138
[ 71.168939] [<ffff00000852d2c4>] rvin_stop_streaming+0x10c/0x130
[ 71.174941] [<ffff000008518420>] __vb2_queue_cancel+0x30/0x160
[ 71.180767] [<ffff0000085187a0>] vb2_core_streamoff+0x48/0xb0
[ 71.186507] [<ffff00000851c53c>] vb2_streamoff+0x3c/0x60
[ 71.191811] [<ffff00000851c5a8>] vb2_ioctl_streamoff+0x48/0x58
[ 71.197639] [<ffff000008502350>] v4l_streamoff+0x20/0x28
[ 71.202944] [<ffff0000085061dc>] __video_do_ioctl+0x25c/0x2c8
[ 71.208683] [<ffff000008505d18>] video_usercopy+0x230/0x478
[ 71.214248] [<ffff000008505f74>] video_ioctl2+0x14/0x20
[ 71.219465] [<ffff000008500f88>] v4l2_ioctl+0xe8/0x118
[ 71.224600] [<ffff0000081d1ddc>] do_vfs_ioctl+0xa4/0x740
[ 71.229905] [<ffff0000081d2504>] SyS_ioctl+0x8c/0xa0
[ 71.234863] [<ffff00000808274c>] __sys_trace_return+0x0/0x4
__rvin_stop_streaming中可以看出根本就没有检测它的返回值!!!它的第二个参数传入的是0
参考:http://blog.csdn.net/jasonchen_gbd/article/details/45585133
posted on 2017-12-01 18:40 Hello-World3 阅读(336) 评论(0) 编辑 收藏 举报