我想要使用类似于在gdb下使用命令的函数。
$ cat arg.txt | xargs ./binary
有没有什么方法可以实现它?
(gdb) run $( cat arg.txt )
将命令的输出作为参数传递也是可能的。
(gdb) run $( ruby -e 'print( "text as arguments" )' )
xargs
调用 gdb 时,默认情况下其标准输入被重定向到 /dev/null
。显然,gdb 需要标准输入来读取和执行用户输入,但由于标准输入是 /dev/null
,因此它无法执行此操作。xargs
和 --arg-file
。xargs --arg-file arg.txt gdb --args ./binary
-a file, --arg-file=file
Read items from file instead of standard input. If you use
this option, stdin remains unchanged when commands are run.
Otherwise, stdin is redirected from /dev/null.
(gdb) run $(cat change_me_bytes.hex)
对于将字节注入到argv[1]
中非常有效。谢谢! - rustyMagnet