如何在 TUI 模式下在 GDB 的命令窗口中向后滚动?
假设
(gdb) print *this
产生 20 行输出。是的,会有 Type
,但我想在到达输出底部后滚动回顶部。
我不认为 http://sourceware.org/gdb/onlinedocs/gdb/ TUI-Keys.html 回答了我的问题。它指出
;
将活动窗口向上滚动一页。
但是当焦点位于命令窗口上时,PgUp 会倒回命令历史记录,而不是在命令窗口中向后滚动。难道只有我有这种行为吗?
我正在使用 PuTTY 来通过 SSH 连接到 Red Hat Linux(如果这有什么区别的话)。
Suppose that
(gdb) print *this
resulted in 20 lines of output. Yes, there would be Type <return> to continue, or q <return> to quit
, but I'd like to scroll back to the top after I got to the bottom of the output.
I don't think http://sourceware.org/gdb/onlinedocs/gdb/TUI-Keys.html answers my question. It states
<PgUp>
Scroll the active window one page up.
but when the focus is on the command window, PgUp rewinds the command history, instead of scrolling back in the command window. Is it only me who suffers from this behavior?
I'm using PuTTY in order to SSH to Red Hat Linux (if this makes any difference).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 TUI 模式下查看 GDB 输出历史记录的一种方法是启用日志记录:
然后在另一个 shell 中跟踪日志:
这具有将滚动与命令交互分开的优点,因此您可以在查看 GDB 输出的某些过去部分的同时键入命令。
滚动键在我的 CMD 窗口中不起作用,因此 GDB 有效地消耗并销毁了自己的输出。退出 TUI 模式允许我向上滚动,但在 TUI 模式下发生的输出不存在 - 非 TUI 窗口仅显示退出 TUI 模式后生成的新输出。到目前为止,log 和 tail 是我能找到的唯一解决方案。
编辑:如果您在切换到 TUI 模式之前激活 GDB 日志记录(通过
设置日志记录
),您可能会发现日志记录在进入 TUI 时停止(这是 GDB 中的一个错误)。您可以将其重新打开:One way to see the GDB output history in TUI mode is to enable logging:
and then tail the log in another shell:
This has the advantage of separating scrolling from command interaction, so you can type commands while viewing some past section of the GDB output.
None of the scrolling keys work in my CMD window, so GDB effectively consumes and destroys its own output. Switching out of TUI mode allows me to scroll up, but the output that occurred while in TUI mode is not there--the non-TUI window only shows new output generated after switching out of TUI mode. So far log and tail is the only solution I can find.
Edit: if you activate GDB logging (via
set logging on
) before switching to TUI mode, you may find that the logging stops upon entering TUI (this is a bug in GDB). You can toggle it back on:我在这里找到了答案:http://beej.us/guide/bggdb/
还有一个示例会话说明了这一点:
I found an answer here: http://beej.us/guide/bggdb/
There's also an example session illustrating this:
您可以尝试 Ctrl + P 执行上一个命令,Ctrl + N 执行下一个命令(当您使用Ctrl + P返回到上一个命令时:)
You can try Ctrl + P for the previous command and Ctrl + N for the next command (when you have used Ctrl + P to go back to the previous commands :)
使用
Cx o
(通常是Ctrl + X、O)。使用此功能,您可以更改活动窗口,然后使用正常的向上向下箭头查看以前的命令。Use
C-x o
(usually Ctrl + X, O). Using this you can change your active window and then use normal up down arrow to see previous commands.我认为这是最好的答案。
其他答案使用输出跟踪来查看单独文本输出文件中的输出,但使用它您可以通过滚动在 gdb 窗口中查看命令输出。
所有答案都假设您处于使用 curses 库的 TUI 模式(文本用户界面)。在此模式下,当您在命令窗口中使用向上或向下箭头时,它仅显示OP不想要的上一个或下一个命令。
确定的方法是:通过在命令窗口中输入“tuidisable”命令退出 TUI 模式。然后当命令输出很长时,您可以向上滚动查看命令输出。如果您想返回 TUI 模式,请执行“tui enable”
我在安装 gdb-dashboard 后进行了测试,通过它你可以看到所有信息,但是我认为你可以在没有 gdb-dashboard 的情况下使用它。
I think this is the best answer.
Other answers use output tracing to see the output in separte text output file, but using this you can see the command output in the gdb window by scrolling.
All the answers assumed you are in TUI mode (Text User Interface) using curses library. In this mode, when you use up or down arrow in command window, it only shows previous or next commands which the OP doesn't want.
The sure memthod is : you exit the TUI mode by giving 'tui disable' command in command window. Then when the command output is very long, you can scroll up to see the command output. If you want to come back to TUI mode, do 'tui enable'
I tested this after installing gdb-dashboard by which you can see all the information, but I think you can use it without gdb-dashboard.