GDB界面模式TUI

引自:https://blog.csdn.net/xu415/article/details/19021759

 

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:

 generalfloat,systemvector,allsave,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. 

 

 

---------------------------------------------------------------------------------------------------------

 

22.1 TUI Overview

In TUI mode, GDB can display several text windows:

 

command

This window is the GDB command window with the GDB prompt and the GDB output. The GDB input is still managed using readline.

 

source

The source window shows the source file of the program. The current line and active breakpoints are displayed in this window.

 

assembly

The assembly window shows the disassembly output of the program.

 

register

This window shows the processor registers. Registers are highlighted when their values change.

The source and assembly windows show the current program position by highlighting the current line and marking it with a `>' marker. Breakpoints are indicated with two markers. The first marker indicates the breakpoint type:

 

B

Breakpoint which was hit at least once.

 

b

Breakpoint which was never hit.

 

H

Hardware breakpoint which was hit at least once.

 

h

Hardware breakpoint which was never hit.

The second marker indicates whether the breakpoint is enabled or not:

 

+

Breakpoint is enabled.

 

-

Breakpoint is disabled.

The source, assembly and register windows are updated when the current thread changes, when the frame changes, or when the program counter changes.

These windows are not all visible at the same time. The command window is always visible. The others can be arranged in several layouts:

 

  • source only,

     

  • assembly only,

     

  • source and assembly,

     

  • source and registers, or

     

  • assembly and registers.

A status line above the command window shows the following information:

 

target

Indicates the current GDB target. (see section Specifying a Debugging Target).

 

process

Gives the current process or thread number. When no process is being debugged, this field is set to No process.

 

function

Gives the current function name for the selected frame. The name is demangled if demangling is turned on (see section 8.7 Print Settings). When there is no symbol corresponding to the current program counter, the string ?? is displayed.

 

line

Indicates the current line number for the selected frame. When the current line number is not known, the string ?? is displayed.

 

pc

Indicates the current program counter address.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

22.2 TUI Key Bindings

The TUI installs several key bindings in the readline keymaps (see section 27. Command Line Editing). The following key bindings are installed for both TUI mode and the GDB standard mode.

 

C-x C-a

C-x a

C-x A

Enter or leave the TUI mode. When leaving the TUI mode, the curses window management stops and GDB operates using its standard mode, writing on the terminal directly. When reentering the TUI mode, control is given back to the curses windows. The screen is then refreshed.

C-x 1

Use a 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 1 binding.

C-x 2

Use a TUI layout with at least two windows. When the current layout already has two windows, the next layout with two windows is used. When a new layout is chosen, one window will always be common to the previous layout and the new one.

Think of it as the Emacs C-x 2 binding.

C-x o

Change the active window. The TUI associates several key bindings (like scrolling and arrow keys) with the active window. This command gives the focus to the next TUI window.

Think of it as the Emacs C-x o binding.

C-x s

Switch in and out of the TUI SingleKey mode that binds single keys to GDB commands (see section 22.3 TUI Single Key Mode).

The following key bindings only work in the TUI mode:

 

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.

Because the arrow keys scroll the active window in the TUI mode, they are not available for their normal use by readline unless the command window has the focus. When another window is active, you must use other readline key bindings such as C-p, C-n, C-b and C-f to control the command window.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

22.3 TUI Single Key Mode

The TUI also provides a SingleKey mode, which binds several frequently used GDB commands to single keys. Type C-x s to switch into this mode, where the following key bindings are used:

 

c

continue

d

down

f

finish

n

next

q

exit the SingleKey mode.

r

run

s

step

u

up

v

info locals

w

where

Other keys temporarily switch to the GDB command prompt. The key that was pressed is inserted in the editing buffer so that it is possible to type 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 q or C-x s.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

22.4 TUI-specific Commands

The TUI has specific commands to control the text windows. These commands are always available, even when GDB is not in the TUI mode. When GDB is in the standard mode, most of these commands will automatically switch to the TUI mode.

 

info win

List and give the size of all displayed windows.

 

layout next

Display the next layout.

 

layout prev

Display the previous layout.

 

layout src

Display the source window only.

 

layout asm

Display the assembly window only.

 

layout split

Display the source and assembly window.

 

layout regs

Display the 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

Refresh the screen. This is similar to typing C-L.

 

tui reg float

Show the floating point registers in the register window.

 

tui reg general

Show the general registers in the register window.

 

tui reg next

Show the next register group. The list of register groups as well as their order is target specific. The predefined register groups are the following: generalfloatsystemvectorallsaverestore.

 

tui reg system

Show the system registers in the register window.

 

update

Update the source window and the current execution point.

 

winheight name +count

winheight name -count

Change the height of the window name by count lines. Positive counts increase the height, while negative counts decrease it.

 

tabset nchars

Set the width of tab stops to be nchars characters.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

22.5 TUI Configuration Variables

Several configuration variables control the appearance of TUI windows.

 

set tui border-kind kind

Select the border appearance for the source, assembly and register windows. The possible values are the following:

space

Use a space character to draw the border.

 

ascii

Use ASCII characters `+', `-' and `|' to draw the border.

 

acs

Use the Alternate Character Set to draw the border. The border is drawn using character line graphics if the terminal supports them.

 

set tui border-mode mode

set tui active-border-mode mode

Select the display attributes for the borders of the inactive windows or the active window. The mode can be one of the following:

normal

Use normal attributes to display the border.

 

standout

Use standout mode.

 

reverse

Use reverse video mode.

 

half

Use half bright mode.

 

half-standout

Use half bright and standout mode.

 

bold

Use extra bright or bold mode.

 

bold-standout

Use extra bright or bold and standout mode.

你可能感兴趣的:(GDB界面模式TUI)