TUI(TextUser Interface)为GDB调试的文本用户界面,可以方便地显示源代码、汇编和寄存器文本窗口,TUI使用效果如下图所示。
Tui界面可以通过运行gdbtui或gdb-tui命令进入(其它变种gdb也一样,如arm-none-eabi-gdb-tui),当然也可以进入gdb界面后使用TUI快捷键打开,如C-xC-a快捷键,详见TUI快捷键绑定章节。
1 TUI Overview
在TUI模式中,可以显示以下几个窗口:
命令窗口
用于GDB调试时的命令输入和命令结果输出显示,与普通GDB窗口无异。
源代码窗口
用于显示程序源代码,包括当前运行行、中断以中断标识等。
汇编窗口
显示当前程序的汇编代码。
寄存器窗口
显示处理器的寄存器内容,当寄存器内容发生改变时会高亮显示。
源代码窗口和汇编窗口会高亮显示程序运行位置并以'>'符号标记。有两个特殊标记用于标识断点,第一个标记用于标识断点类型:
B
程序至少有一次运行到了该断点
b
程序没有运行到过该断点
H
程序至少有一次运行到了该硬件断点
h
程序没有运行到过该硬件断点
第二个标记用于标识断点使能与否:
+
断点使能Breakpointis enabled.
-
断点被禁用Breakpointis disabled.
当调试程序时,源代码窗口、汇编窗口和寄存器窗口的内容会自动更新。
TUI运行时,命令窗口是一直可见不可隐藏的,而源代码窗口、汇编窗口和寄存器窗口则不能同时显示,只能显示一个或两个窗口,但不能只显示寄存器窗口。
在命令窗口上方有一行状态栏,显示效果如下图所示,主要显示内容有:
目标
Indicatesthe current GDB target. (see section Specifyinga Debugging Target).
进程
Givesthe current process or thread number. When no process is beingdebugged, this field is set to No process.
函数
Givesthe current function name for the selected frame. The name isdemangled if demangling is turned on (see section 8.7Print Settings). When there is no symbol corresponding to thecurrent program counter, the string ??is displayed.
行号
Indicatesthe current line number for the selected frame. When the currentline number is not known, the string ??is displayed.
pc指针
Indicatesthe current program counter address.
2 TUI快捷键TUIKey Bindings
TheTUI installs several key bindings in the readline keymaps (seesection 27.Command Line Editing). The following key bindings are installedfor both TUI mode and the GDB standard mode.
C-x C-a
C-x a
C-x A (按住Ctrl+x后松开再按a,以下快捷键操作方式相同)
进入或退出TUI模式。
C-x 1
使TUI只显示一个窗口。Usea TUI layout with only one window. The layout will either be`source' or `assembly'.When the TUI mode is not active, it will switch to the TUI mode.Think of this key binding as the Emacs C-x 1binding.
C-x 2
使TUI显示两个窗口,连接使用此快捷键可在三种窗口组合(只能同时显示两个,共3种组合)中不断切换。
Usea TUI layout with at least two windows. When the current layoutalready has two windows, the next layout with two windows is used.When a new layout is chosen, one window will always be common to theprevious layout and the new one. Think of it as the Emacs C-x2 binding.
C-x o
更换激活窗口
Changethe active window. The TUI associates several key bindings (likescrolling and arrow keys) with the active window. This command givesthe focus to the next TUI window. Think of it as the Emacs C-xo binding.
C-x s
在TUI模式和TUISingleKey模式之间切换
Switchin and out of the TUI SingleKey mode that binds single keys to GDBcommands (see section 22.3TUI Single Key Mode).
下列快捷键只在TUI模式才能有效:
PgUp
激活窗口的内容向上滚动一页Scroll the active window one page up.
PgDn
激活窗口的内容向下滚动一页Scroll the active window one page down.
Up
激活窗口的内容向上滚动一行Scroll the active window one line up.
Down
激动窗口的内容向下滚动一行Scroll the active window one line down.
Left
激活窗口的内容向左移动一列Scroll the active window one column left.
Right
激活窗口的内容向右移动一列Scroll the active window one column right.
C-L
更新屏幕Refresh the screen.
当源代码和汇编窗口同时显示时,以上快捷键会同步更新两个窗口的内容。
Becausethe arrow keys scroll the active window in the TUI mode, they are notavailable for their normal use by readline unless the command windowhas the focus. When another window is active, you must use otherreadline key bindings such as C-p, C-n,C-b and C-f tocontrol the command window.
3 TUI Single Key Mode
TheTUI also provides a SingleKey mode, which bindsseveral frequently used GDB commands to single keys. Type C-xs to switch into this mode, where the following key bindingsare used:
c
continue
d
down
f
finish运行到当前函数返回
n
next
q
exitthe SingleKey mode. 退出SingleKey模式
r
run
s
step
u
up
v
infolocals
w
where
Otherkeys temporarily switch to the GDB command prompt. The key that waspressed is inserted in the editing buffer so that it is possible totype most GDB commands without interaction with the TUI SingleKey mode. Once the command is entered the TUI SingleKey mode is restored.The only way to permanently leave this mode is by typing qor C-x s.
4 TUI-specific Commands
TheTUI has specific commands to control the text windows. These commandsare always available, even when GDB is not in the TUI mode. When GDBis in the standard mode, most of these commands will automaticallyswitch to the TUI mode. 当处理GDB标准模式时,下列的大多数命令会自动切换到TUI模式。
info win:显示正在显示的窗口大小信息
Listand give the size of all displayed windows.
layout next:显示下一个窗口
Displaythe next layout.
layout prev:显示上一个窗口
Displaythe previous layout.
layout src:显示源代码窗口
Displaythe source window only.
layout asm:显示汇编窗口
Displaythe assembly window only.
layout split:显示源代码和汇编窗口
Displaythe source and assembly window.
layout regs:显示寄存器窗口
Displaythe register window together with the source or assembly window.
focus next:将一个窗口置为激活状态
Make the next window active for scrolling.
focus prev:将上一个窗口置为激活状态
Make the previous window active for scrolling.
focus src:将源代码窗口置为激活状态
Make the source window active for scrolling.
focus asm:将汇编窗口置为激活状态
Make the assembly window active for scrolling.
focus regs:将寄存器窗口置为激活状态
Make the register window active for scrolling.
focus cmd:将命令行窗口置为激活状态
Make the command window active for scrolling.
refresh:更新窗口,与C-L快捷键同
Refresh the screen. This is similar to typing C-L.
tuireg float:寄存器窗口显示内容为浮点寄存器
Showthe floating point registers in the register window.
tuireg general:寄存器窗口显示内容为普通寄存器
Show the general registers in the register window.
tuireg next:显示下一组寄存器
Show the next register group. The list of register groups as well astheir order is target specific. The predefined register groups are the following:
general, float,system, vector,all, save,restore.
tuireg system :显示上一组寄存器
Show the system registers in the register window.
update :更新源代码窗口到当前运行点
Update the source window and the current execution point.
winheight winname +count:增加指定窗口的高度
winheight winname -count:减小指定窗口的高度
Changethe height of the window name by count lines.Positive counts increase the height, while negative counts decreaseit.
tabset nchars
Set the width of tab stops to be nchars characters
————————————————
版权声明:本文为CSDN博主「慢慢学着走」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xu415/article/details/19021759
来源:CSDN
作者:dataowner
链接:https://blog.csdn.net/dataowner/article/details/103991197