GDB的auto display的用法

在gdb当中,display的功能很不错的

下面是gdb手册上的定义:

display expr
Add the expression expr to the list of expressions to display each time your program stops. See Expressions.

display does not repeat if you press <RET> again after using it.

display/fmt expr
For fmt specifying only a display format and not a size or count, add the expression expr to the auto-display list but arrange to display it each time in the specified format fmt. See Output Formats.
display/fmt addr
For fmt `i' or `s', or including a unit-size or a number of units, add the expression addr as a memory address to be examined each time your program stops. Examining means in effect doing `x/fmt addr'. See Examining Memory.

这里讲一下显示数组:

假设定义了一个数组

char array[4];

那么在gdb当中就可以用如下的方式:

display /x *array@4

gdb就会吧array数组以十六进制显示了!~

 

原文地址:https://www.cnblogs.com/CodeWorkerLiMing/p/12007754.html