# 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脚本例子
于 2024-04-03 14:30:05 首次发布
本文详细展示了如何使用GDB调试器对C程序的exit_callback_f1函数进行调试,包括设置断点、查看局部变量,以及讨论了地址空间随机化的警告。
摘要由CSDN通过智能技术生成