[英]GDB/MI redirect stdin and stdout to files
I am using GDB Machine interface to debug binary file which read from stdin and write to sdtout. 我正在使用GDB机器接口调试从stdin读取并写入sdtout的二进制文件。 I would like redirect both stdin and stdout to files. 我想将stdin和stdout都重定向到文件。 With plain GDB i can use run command like this: 使用普通的GDB,我可以使用如下运行命令:
run < input.txt > output.txt
Is there any way to maybe use GDB/MI command -exec-run similarly to this? 有什么办法可以类似地使用GDB / MI命令-exec-run吗?
Here is similar question GDB/MI detecting target waiting for input but it seems so complex compared to plain gdb solution. 这是GDB / MI检测目标等待输入的类似问题,但与普通的gdb解决方案相比,它看起来是如此复杂。
I also have not found anything in docs: ftp://ftp.gnu.org/old-gnu/Manuals/gdb/html_chapter/gdb_22.html#SEC216 我也没有在文档中找到任何内容: ftp : //ftp.gnu.org/old-gnu/Manuals/gdb/html_chapter/gdb_22.html#SEC216
您应该能够将mi命令-inferior-tty-set与mkfifo实用程序一起使用。
I found the solution. 我找到了解决方案。 Its is possible to use MI GDB commands together with GDB commands. 可以将MI GDB命令与GDB命令一起使用。 So if i need to forward stdin and stdout to file i can do it like this: 因此,如果我需要将stdin和stdout转发到文件,我可以这样做:
-file-exec-and-symbols <filename>
//readfile to debug -file-exec-and-symbols <filename>
//要调试的读取-file-exec-and-symbols <filename>
-break-insert main
//set breakpoint at main function (or anywhere esle) -break-insert main
//在主函数(或esle的任何地方)上设置断点 run < input.txt > output.txt
//forward stdin and stdout to files run < input.txt > output.txt
//将stdin和stdout转发到文件 -exec-run
//start debugging -exec-run
//开始调试 After this you can run commands like step or -exec-step or anything else like you normally do. 之后,您可以运行诸如step或-exec-step之类的命令,或者像平时一样执行其他操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.