GDB调试技巧实战--commands(断点回调)

commands的介绍

直接看gdb的help:commands会在关联的断点断住时被执行。

(gdb) help commands
Set commands to be executed when a breakpoint is hit.
Give breakpoint number as argument after "commands".
With no argument, the targeted breakpoint is the last one set.
The commands themselves follow starting on the next line.
Type a line containing "end" to indicate the end of them.
Give "silent" as the first line to make the breakpoint silent;
then no output is printed when it is hit, except what the commands print.

我随便写了一个commands,让读者快速瞥一眼它的大体样子。

(gdb) b main
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>printf("hello main\n");
>where
>end

例子

要真正看其作用,咱必须得先有一个c/c++程序,我们就用

你可能感兴趣的:(GDB技巧,linux,gdb)