如何将整个GDB会话转储到文件,包括我输入的命令及其输出? [英] How to dump the entire GDB session to a file, including commands I type and their output?

查看:120
本文介绍了如何将整个GDB会话转储到文件,包括我输入的命令及其输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在bash中,我可以使用脚本命令,该命令将shell中显示的所有内容转储到文件中,包括:




  • 命令输入

  • PS1行

  • 命令的stdout和stderr


gdb中的等价物是什么?



我试图运行 shell脚本来自GDB内部,但是在我返回后,我在shell中,失去了shell提示符,无法再运行命令。此外,我无法使用ctrl + c或ctrl + \退出。我需要强制杀死 / bin / login tty2 才能退出。

解决方案

<如果你想记录GDB的输出,你可以使用 GDB日志记录输出命令,例如。

  set logging file mylog.txt 
set logging on

如果您想将程序的输出重定向到文件,可以使用重定向,例如。

 运行myprog> mylog.txt 

请参阅 /onlinedocs/gdb/Input_002fOutput.html#Input_002fOutputrel =noreferrer>

In bash, I can use the script command, which dumps everything that shows on the shell to a file, including:

  • commands typed
  • PS1 line
  • stdout and stderr of commands

What is the equivalent in gdb?

I tried to run shell script from inside GDB, but after I hit return, I was in the shell and lost the shell prompt and could not run command any more. Moreover I could not use ctrl+c or ctrl+\ to exit. I needed to force kill the /bin/login tty2 to exit.

解决方案

If you want to log GDB's output, you can use the GDB logging output commands, eg.

set logging file mylog.txt
set logging on

If you want to redirect your program's output to a file, you can use a redirect, eg.

run myprog > mylog.txt

see the chapter on program IO in the GDB manual for more information

这篇关于如何将整个GDB会话转储到文件,包括我输入的命令及其输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆