gdb 重定向标准输出 -- 调试ncurse比较有用

在调试使用ncurses的程序时,gdb和DDD提供了重定向标准输出到另一个终端窗口的功能。在gdb中,可以通过`tty /dev/pts/10`命令指定执行窗口,并用`sleep 10000`确保输入被程序接收。在DDD中,只需点击`View | Execution Window`即可自动创建执行窗口。调试完成后,注意可能需要在执行窗口使用`reset`命令恢复终端设置。

默认情况下,程序的标准输出在gdb窗口。 有时候这样调试会比较麻烦。

gdb提供了重定向的方法。


4.1 GDB
Start up GDB as usual in some text window. Then choose another window in which your curses application
will run, and determine the device name for that latter window (which we will call the “execution
window”). To do this, run the Unix tty command in that window. Let’s suppose for example that the output
of the command is “/dev/pts/10”. Then within GDB issue the command


(gdb) tty /dev/pts/10


We must then do one more thing before issuing the run command to GDB. Go to the execution window,
and type


sleep 10000


Unix’s sleep command has the shell go inactive for the given amount of time, in this example 10,000
seconds. This is needed so that any input we type in that window will be sure to go to our pro

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值