gdb advanced function commands usage

The commands command of gdb allows the program to automatically execute a set of commands every time it reaches a breakpoint, so as to help programmers better observe the program running process and locate program running problems.

The specific usage is as follows, here is an example of viewing the breakpoint call stack in gdb:

(gdb)b xxx
(gdb)commands
>bt
>c
>end
(gdb)c

After the above settings are executed, every time the program runs to the xxx position, the commands command will be triggered to automatically execute the three commands bt, c, and end, and then the program will automatically go down without affecting its operation.

The effect is as follows:

 

Any gdb command can be added to commands to help programmers obtain more program running information, and flexible use of this function can improve the efficiency of problem location.

Guess you like

Origin blog.csdn.net/hhhlizhao/article/details/130954741