gdb -tui & CGDB

来源:互联网 发布:李白的文学地位知乎 编辑:程序博客网 时间:2024/06/10 13:13


help layout

   src   : Displays source and command windows.
   asm : Displays disassembly and command windows.
   split : Displays source, disassembly and command windows.
   regs : Displays register window. If existing layout
             is source/command or assembly/command, the
             register window is displayed. If the
             source/assembly/command (split) is displayed,
             the register window is displayed with
             the window that has current logical focus.

help winheight

Usage: winheight <win_name> [+ | -] <#lines>
Window names are:
src   : the source window
cmd : the command window
asm : the disassembly window
regs : the register display

focus is like the winheight above


#1. TUI模式下有4个窗口,
  • (cmd)command 命令窗口. 可以键入调试命令
  • (src)source 源代码窗口. 显示当前行,断点等信息
  • (asm)assembly 汇编代码窗口
  • (reg)register 寄存器窗口
最常用的也就是默认使用的方式,也可以通过layout命令来进行选择自己需要的窗口,可参见help layout.

#2. gdbtui相关的命令
  1. layout
    用以修改窗口布局
    help layout
    layout src
    layoutasm
    layout split
  2. winheight
    调整各个窗口的高度。
    help winheight
    winheight src+5
    winheight src-4
  3. space
    当前窗口放大或者缩小以后,gdbtui窗口不会发生变化,我们可以通过space 键强行刷新gdbtui窗口。
  4. focus next / prev
    在默认设置下,方向键和PageUp PageDn 都是用来控制gdbtui的src窗口的,所以,我们常用的上下键用来显示前一条命令和后一条命令的功能就没有了, 不过这个时候我们可以通过ctrl + n / ctrl +p 来获取这个功能。

    我们可以通过focus命令来调整焦点位置,默认情况下是在src窗口,通过focus next命令, 焦点就移到cmd窗口了,这时候就可以像以前一样,通过方向键来切换到上一条命令和下一条命令。


     help focus
     focus cmd
     focus src

    焦点不在src窗口以后,我们就不能通过方向键来浏览源码了。


CGDB
https://leeyiw.gitbooks.io/cgdb-manual-in-chinese/content/3.1.html
ESC:切换焦点到源码模式,在该界面中可以使用vi的常用命令
i:切换焦点到gdb模式
o:打开文件对话框,选择要显示的代码文件,按ESC取消
空格:在当前行设置一个断点
k:向上移动,
j:向下移动;
/:查找;
-:将代码窗口缩小一行
=:将代码窗口增大一行
_:将代码窗口缩小25%(当TTY窗口显示的时候,将TTY窗口缩小一行)
+:将代码窗口增大25%

cgdb 好是好,以后写代码都用这个了可以,但这次拆炸弹不行。它只能分行输出汇编,不能在窗口显示。
display/i $pc shows disassembly always for the current instruction, in the console window.
To show disassembly for more instructions, prefix i with the number of instructions.
For example,
display/5i $pc
shows disassembly always for the next 5 instructions.
我Google到了说不能在窗口显示,为此第一次在shack overflow上答题Y(^_^)Y,顺便在csdn上写了下。