我正在使用 GDB 调试 C 程序,并且在变量 uint8_t msg_bin_tst[64];
上设置了一个观察点。当观察点被触发时,GDB 输出如下内容:
Watchpoint 4: msg_bin_tst
Old value = "@\001\000\067\335\002\033a32c85ba9dda45823be416246cf8b433baa068d7\000\000\000\000\000\000\000\000\000\017\000\000\000(\000\000"
New value = "@\001\000\067\335\002\033a32c85ba9dda45823be416246cf6cf8b433baa068d7\000\000\000\000\000\000\017\000\000\000(\000\000"
这有点难以解释,有没有一种方法可以将输出格式设置为类似print/x
,即类似于:
msg_bin_tst = {0x40, 0x1, 0x0, 0x37, 0xdd, 0x2, 0x1b, 0x61, 0x33, 0x32, 0x63, 0x38, 0x35, 0x62, 0x61, 0x39, 0x64, 0x64, 0x61, 0x34, 0x35, 0x38, 0x32, 0x33, 0x62, 0x65, 0x34, 0x31, 0x36, 0x32, 0x34, 0x36, 0x63, 0x66, 0x38, 0x62, 0x34, 0x33, 0x33, 0x62, 0x61, 0x61, 0x30, 0x36, 0x38, 0x64, 0x37, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0}
最佳答案
使用commands
设置命中观察点时的命令,例如:
(gdb) commands 2
Type commands for breakpoint(s) 2, one per line.
End with a line saying just "end".
>print /x msg_bin_tst
>end
2
是观察点的数量。然后当命中观察点时,数组将自动转储。
可以引用gdb手册:https://sourceware.org/gdb/onlinedocs/gdb/Break-Commands.html .
关于c - 设置观察点以在 GDB 中输出十六进制列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24679883/