在GDB中打印字符数组到文件

我有一个包含大约100k个条目的字符数组.似乎在功能我的时候
打印*缓冲区过早切断.有没有什么可以做的,可以延长gdb将打印到控制台的字符数量?如果没有,我可以将此变量打印到文件?我试图使用转储命令,但似乎没有想出正确的事情.

解决方法

(gdb) help x
examine memory: x/FMT ADDRESS.
ADDRESS is an expression for the memory address to examine.
FMT is a repeat count followed by a format letter and a size letter.
Format letters are o(octal),x(hex),d(decimal),u(unsigned decimal),t(binary),f(float),a(address),i(instruction),c(char) and s(string).
Size letters are b(byte),h(halfword),w(word),g(giant,8 bytes).
The specified number of objects of the specified size are printed
according to the format.

Defaults for format and size letters are those prevIoUsly used.
Default count is 1.  Default address is following last thing printed
with this command or "print".
(gdb) x/8b array
0xbffd7670:     0       0       0       0       0       0       0       0
(gdb) x/16b array
0xbffd7670:     0       0       0       0       0       0       0       0
0xbffd7678:     0       0       0       0       0       0       0       0
(gdb) x/128b array
0xbffd7670:     0       0       0       0       0       0       0       0
0xbffd7678:     0       0       0       0       0       0       0       0
0xbffd7680:     0       0       0       0       0       0       0       0
0xbffd7688:     0       0       0       0       0       0       0       0
0xbffd7690:     0       0       0       0       0       0       0       0
0xbffd7698:     0       0       0       0       0       0       0       0
0xbffd76a0:     0       0       0       0       0       0       0       0
0xbffd76a8:     0       0       0       0       0       0       0       0
0xbffd76b0:     0       0       0       0       0       0       0       0
0xbffd76b8:     0       0       0       0       0       0       0       0
0xbffd76c0:     0       0       0       0       0       0       0       0
0xbffd76c8:     0       0       0       0       0       0       0       0
0xbffd76d0:     0       0       0       0       0       0       0       0
0xbffd76d8:     0       0       0       0       0       0       0       0
0xbffd76e0:     0       0       0       0       0       0       0       0
0xbffd76e8:     0       0       0       0       0       0       0       0
(gdb)

如果您想要打印ASCII字符符号,请使用x /< size> c.

(gdb) set logging file ~/gdb_dump.txt
(gdb) set logging on
copying output to /home/mminich/gdb_dump.txt.
(gdb) x/26c array
0xbfff4b20:     97 'a'  98 'b'  99 'c'  100 'd' 101 'e' 102 'f' 103 'g' 104 'h'
0xbfff4b28:     105 'i' 106 'j' 107 'k' 108 'l' 109 'm' 110 'n' 111 'o' 112 'p'
0xbfff4b30:     113 'q' 114 'r' 115 's' 116 't' 117 'u' 118 'v' 119 'w' 120 'x'
0xbfff4b38:     121 'y' 122 'z'
(gdb) set logging off
Done logging to /home/mminich/gdb_dump.txt.
(gdb)

BTW,我完全同意William Pursell在你的问题上的评论:“我发现在执行数据转储的代码中定义函数更容易,只需从gdb调用它们(在#ifdef DEBUG中包含定义)”

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...