gdb:在没有 运行 程序的情况下重定向标准输出
gdb: Redirect stdout without running the program
在gdb中,我们通常使用r > log.txt
来重定向stdout。这也运行程序。
有没有办法在不实际启动程序的情况下重定向 stdout(仅,而不是 stdin)?
我的预期工作流程是:
redirect stdout to log.txt
call func1(a, b, c) # I want the stdout output going to log.txt, without any gdb info, just stdout
请注意,tty
命令在这种情况下不起作用(我只想重定向标准输出)。
My intended workflow is:
您的预期工作流程将无法工作:您不能 call func1(...)
没有 首先运行 程序.
看起来您想要的是(大致):
start
程序(运行到 main
)。
call func1(...)
其输出重定向到一个文件。
This answer 展示了如何在程序执行的任意点将输出重定向到您想要的任何位置。
在gdb中,我们通常使用r > log.txt
来重定向stdout。这也运行程序。
有没有办法在不实际启动程序的情况下重定向 stdout(仅,而不是 stdin)?
我的预期工作流程是:
redirect stdout to log.txt
call func1(a, b, c) # I want the stdout output going to log.txt, without any gdb info, just stdout
请注意,tty
命令在这种情况下不起作用(我只想重定向标准输出)。
My intended workflow is:
您的预期工作流程将无法工作:您不能 call func1(...)
没有 首先运行 程序.
看起来您想要的是(大致):
start
程序(运行到main
)。call func1(...)
其输出重定向到一个文件。
This answer 展示了如何在程序执行的任意点将输出重定向到您想要的任何位置。