I am using GDB Machine interface to debug binary file which read from stdin and write to sdtout. I would like redirect both stdin and stdout to files. With plain GDB i can use run command like this:
run < input.txt > output.txt
Is there any way to maybe use GDB/MI command -exec-run similarly to this?
Here is similar question GDB/MI detecting target waiting for input but it seems so complex compared to plain gdb solution.
I also have not found anything in docs: 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. So if i need to forward stdin and stdout to file i can do it like this:
-file-exec-and-symbols <filename>
//readfile to debug -break-insert main
//set breakpoint at main function (or anywhere esle) run < input.txt > output.txt
//forward stdin and stdout to files -exec-run
//start debugging After this you can run commands like step or -exec-step or anything else like you normally do.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.