自动化gdb:在每次调用函数puts时显示回溯 [英] Automate gdb: show backtrace at every call to function puts

查看:88
本文介绍了自动化gdb:在每次调用函数puts时显示回溯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调试一些程序。我需要从某些功能的所有呼叫回溯,例如现在我使用这样的gdb 脚本

 设置宽度0 
设置高度0
设置详细关闭
break puts
命令1
backtrace
继续
end

但是以

开头

  gdb --batch --command = script --args ./some_program arguments 

给出错误:

 功能puts未定义。 
在将来的共享库加载时使断点处于待处理状态? (y或[n])[回答N;输入不是来自终端]
/ root / script:5:源文件中的错误:
没有断点编号1.

如何在库函数的脚本中设置断点?

解决方案



 设定宽度0 
设定高度0
设定详细关闭
开始#运行至主要,所以共享库在到达main之后加载
#,GDB应该有libc符号,其中包含puts
break puts
命令1
backtrace
continue
end

如果这不起作用,请说明操作系统版本。



编辑:正如osgx正确指出的,另一种选择是添加

  set在



break break


I want to debug some program. I need backtraces from all calls to some function, e.g. puts.

Now I use such gdb script:

set width 0
set height 0
set verbose off
break puts
commands 1
backtrace
continue
end

But starting it with

gdb --batch --command=script --args ./some_program arguments

Gives a error:

Function "puts" not defined.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
/root/script:5: Error in sourced command file:
No breakpoint number 1.

How can I set breakpoint in script for library call?

解决方案

Try this instead:

set width 0
set height 0
set verbose off
start  # runs to main, so shared libraries are loaded
       # after you reach main, GDB should have libc symbols, "puts" among them
break puts
commands 1
backtrace
continue
end

If this doesn't work, please state operating system version.

EDIT: as osgx correctly points out, the other alternative is to add

set breakpoint pending on

before break puts

这篇关于自动化gdb:在每次调用函数puts时显示回溯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆