0%

gdb-disassemble

堆栈信息

(cskygdb) bt
#0  0x003cfd6a in GxAVWaitEvents (dev=5, module=8, event_mask=1, timeout_us=500000, event=0x2f3325c8) at av/avapi.c:146
#1  0x002bb7d2 in GxBus_SiFilterQuery ()
#2  0x002b9c82 in GxSiServiceConsole ()
#3  0x002b883c in sched_console_thread ()
#4  0x003c88e0 in default_thread_function (arg=0x63b640) at os/linux/osapi.c:428
#5  0x003d8ca0 in ?? ()

(cskygdb) bt full

(cskygdb) info f 0
Stack frame at 0x2f3325c8:
 pc = 0x3cfd6a in GxAVWaitEvents (av/avapi.c:146); saved pc 0x2bb7d2
 called by frame at 0x2f3325f8
 source language c.
 Arglist at 0x2f3325a8, args: dev=5, module=8, event_mask=1, timeout_us=500000, event=0x2f3325c8
 Locals at 0x2f3325a8, Previous frame's sp is 0x2f3325c8

函数

断点 b *GxAVWaitEvents,reg如下:

i r
r0             0x2f3325c8    0x2f3325c8
r1             0x58    88
r2             0x5    5                   //param 0
r3             0x8    8                   //param 1
r4             0x1    1                   //param 2
r5             0x7a120    500000          //param 3
r6             0x2f3325c8    791881160   //param 4
r7             0x6257f0    6445040
r8             0x0    0
r9             0x60da00    6347264
r10            0x0    0
r11            0x621928    6428968
r12            0x0    0
r13            0x0    0
r14            0x2f332608    791881224
r15            0x2bb7d2    2865106         //last frame pc
pc             0x3cfd6a    0x3cfd6a <GxAVWaitEvents+2>
epc            0x0    0
psr            0x1064141    17187137
epsr           0x0    0
(cskygdb) disassemble GxAVWaitEvents
Dump of assembler code for function GxAVWaitEvents:
                                            //r0 0x2f3325c8
=> 0x003cfd68 <+0>:    subi    r0, r0, 32      //r0 0x2f3325a8
   0x003cfd6a <+2>:    st    r15, (r0, 24)       //last frame pc push
End of assembler dump.

(cskygdb) help disassemble
Disassemble a specified section of memory.
Default is the function surrounding the pc of the selected frame.
With a /m modifier, source lines are included (if available).
With a /r modifier, raw instructions in hex are included.
With a single argument, the function surrounding that address is dumped.
Two arguments (separated by a comma) are taken as a range of memory to dump,
  in the form of "start,end", or "start,+length".

(cskygdb) disassemble /m GxAVWaitEvents

常用反汇编调试命令

  • b *func 断点在 func 入栈之前
  • ni/si 汇编指令级单步执行
  • disassemble func 反汇编 func
  • disassemble /m func 反汇编 func,带有源代码信息
  • disassemble $pc-20,$pc+20 反汇编执行区间代码
  • watch *(int *)0x8049aa4 内存读写断点
  • rwatch *(int *)0x8049aa4 内存读断点
  • awatch *(int *)0x8049aa4 内存读写断点
  • display /i $pc 显示当前汇编指令
  • info r 查看寄存器
  • i r rx 查看rx寄存器