GDB

2016/05/09

Categories: Linux Tags: debug

设置 intel 格式汇编

~/.gdbinit中:

set disassembly intel 

查看寄存器

(gdb) i r
rax            0x4005a5	4195749
rbx            0x0	0
rcx            0x0	0
rdx            0x7fffffffe628	140737488348712
rsi            0x7fffffffe618	140737488348696
rdi            0x1	1
rbp            0x7fffffffe530	0x7fffffffe530
rsp            0x7fffffffe530	0x7fffffffe530
r8             0x7ffff7dd4e80	140737351863936
r9             0x7ffff7dea560	140737351951712
r10            0x7fffffffe3c0	140737488348096
r11            0x7ffff7a36dd0	140737348070864
r12            0x400470	4195440
r13            0x7fffffffe610	140737488348688
r14            0x0	0
r15            0x0	0
rip            0x4005a9	0x4005a9 <main+4>
eflags         0x246	[ PF ZF IF ]
cs             0x33	51
ss             0x2b	43
ds             0x0	0
es             0x0	0
fs             0x0	0
gs             0x0	0
(gdb) i r rip
rip            0x4005a9	0x4005a9 <main+4>

查看内存

  1. command x, short for examine.

  2. 格式化字符

    o Display in octal.
    x Display in hexadecimal.
    u Display in unsigned, standard base-10 decimal.
    d Display in decimal
    t Display in binary.
    
    (gdb) x/2x $rip
    
  3. 数据长度字符

    b A single byte
    h A halfword, which is two bytes in size
    w A word, which is four bytes in size
    g A giant, which is eight bytes in size
        
    (gdb) x/4xb $rip
    
  4. 指令字符

    i, short for instruction, to display the memory as disassembled assembly language instructions.

    (gdb) x/3i $rip
    
  5. 其它格式化字符

    The c format letter can be used to automatically look up a byte on the ASCII table.

    The s format letter will display an entire string of character data.