Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个大而长的字符串,我想将它捕获到一个文件中。我可以使用日志记录来获得大部分的方式:
设置登录 设置日志文件 gdb.log
…但是如果我使用porx/s来打印字符串,引号和垃圾都会被转义。如何按原样获取字符串?
p
x/s
对于非常大的字符串,您还可以使用:
(gdb) set variable $s = MY_STRING (gdb) dump binary memory FILE $s $s + (size_t)strlen($s)
它可以很容易地适应处理带有空字节的缓冲区。此外 FILE 的内容永远不会包含字符串以外的任何内容。
啊,我完全忘记了printf:
printf
printf "%s\n", some_string