GDB 的 s 单步命令 怎么改回不进入标准库函数。

jiaga 2014-09-13 11:11:38
debian 7.6 系统
今天用 apt-get install 安装了几个东东 电脑自己下载了很多东西。
然后 GDB 调试代码的时候用 s 命令遇到每个标准库函数都要进去
想这样:
11      #include <stdio.h>
12
13 int main(void)
14 {
15 printf("hello world!\n");
(gdb) l
16
17 return 0;
18 }
(gdb) b main
Breakpoint 1 at 0x400510: file test.c, line 15.
(gdb) r
Starting program: /home/jiaga/c/linked_list/void_list/test
s
Breakpoint 1, main () at test.c:15
15 printf("hello world!\n");
(gdb) s
_IO_puts (str=0x4005dc "hello world!") at ioputs.c:35
35 ioputs.c: 没有那个文件或目录.
(gdb) s
37 in ioputs.c
(gdb) s
__strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:26
26 ../sysdeps/x86_64/multiarch/../strlen.S: 没有那个文件或目录.
(gdb)


弄得我操作好不自在。
只要是标准库它就要源码,我木有啊。。。 而且我也不想调试标准库啊!!

以前 s 命令都是直接跳过了标准库函数的啊!!
像这样:
15              printf("hello world!\n");
(gdb) s
hello world!
17 return 0;
(gdb)


用 s 命令然后标准库函数就直接执行了啊, 都没有要进去,就直接跳自己的代码上了啊?

为什么呢??? 现在调试很麻烦了啊,刚看了几行代码又要碰到标准库函数进去 要么就要看准是标准库函数的时候用 n 命令跳过。之前习惯了一路 s 命令走下去的,现在很不习惯啊!!!
怎么改回来呢???
...全文
551 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Cody2k3 2014-09-14
  • 打赏
  • 举报
回复
猜测楼主可能最近无意下载了glibc的debug文件 到了debug file directory gdb 的step的实现只是简单的看当前地址是否有source line的信息 所以如果不想跳入glibc的function只需要保证gdb看不到glibc的debug info 闲话少叙, 直接上个例子 (gdb) b main Breakpoint 1 at 0x400520: file b.C, line 5. (gdb) r Starting program: b Breakpoint 1, main () at b.C:5 5 printf("hello world\n"); (gdb) step _IO_puts (str=0x4005e4 "hello world") at ioputs.c:35 35 ioputs.c: No such file or directory. (gdb) show debug-file-directory The directory where separate debug symbols are searched for is "/usr/lib/debug". (gdb) set debug-file-directory (gdb) show debug-file-directory The directory where separate debug symbols are searched for is "". (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: b Breakpoint 1, main () at b.C:5 5 printf("hello world\n"); (gdb) step hello world 7 return 0; (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: b Breakpoint 1, main () at b.C:5 5 printf("hello world\n"); (gdb) next hello world 7 return 0; 如果只是简单想跳过printf,除了改变debug file directory, 也可以直接用 next,如上所示 预知详情,可参考 https://blogs.oracle.com/dbx/entry/gnu_debuglink_or_debugging_system
jiaga 2014-09-14
  • 打赏
  • 举报
回复
弄好了 谢谢啊

23,217

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧