gdb脚本例子

# gdb -q  --command ./__run_exit_handlers__info_locals.gdb_script --args ./app.elf

break exit_callback_f1
commands 1
bt
frame 1
info locals
end

run
continue
quit


#以下是输出:
# Reading symbols from ./app.elf...done.
# Breakpoint 1 at 0x40067b: file app.c, line 6.
# warning: Error disabling address space randomization: Operation not permitted

# Breakpoint 1, exit_callback_f1 () at app.c:6
# 6	    printf("I'm exit callback function 01\n");
# 0  exit_callback_f1 () at app.c:6
# 1  0x00007f1292c36050 in __run_exit_handlers (status=0, listp=0x7f1292fa26f8 <__exit_funcs>, run_list_atexit=true, run_dtors=true) at exit.c:108
# 2  0x00007f1292c36193 in __GI_exit (status=0) at exit.c:139
# 3  0x00007f1292c21514 in __libc_start_main (main=0x40068a <main>, argc=1, argv=0x7fffcba1c028, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
    stack_end=0x7fffcba1c018) at ../csu/libc-start.c:342
# 4  0x00000000004005ba in _start ()
# 1  0x00007f1292c36050 in __run_exit_handlers (status=0, listp=0x7f1292fa26f8 <__exit_funcs>, run_list_atexit=true, run_dtors=true) at exit.c:108
# 108		      cxafct (f->func.cxa.arg, status);
# atfct = 0x14
# onfct = 0x4006e3 <__libc_csu_init>
# cxafct = 0x400677 <exit_callback_f1>
# f = 0x7f1292fa3d90 <initial+48>
# new_exitfn_called = 2
# cur = 0x7f1292fa3d60 <initial>
# 函数 __run_exit_handlers 的局部变量 正常显示,说明 编译 exit.c 时候的 -O0 禁用优化 确实生效了
# I'm exit callback function 01
# [Inferior 1 (process 579656) exited normally]

-

更多gdb脚本例子

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

ziix

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

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

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

打赏作者

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

抵扣说明:

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

余额充值