Displaying each assembly instruction executed in gdb

后端 未结 3 897
别跟我提以往
别跟我提以往 2020-12-14 22:04

I currently have a tricky bug that occurs in a place where I don\'t have access to source or symbols, i.e. I can see the instruction and its address where the crash occurs,

3条回答
  •  独厮守ぢ
    2020-12-14 22:25

    The following should do what you asked for:

    # not strictly required, but you'll likely want the log anyway
    (gdb) set logging on
    
    # ask gdb to not stop every screen-full
    (gdb) set height 0
    
    (gdb) while 1
     > x/i $pc
     > stepi
     > end
    

    However, this approach to debugging will likely prove futile: there are simply too many instructions executed even in most trivial programs.

    A better approach might be to run the program until crash, attempt to understand what current function is doing and who calls it, and setting breakpoints appropriately.

    On x86, you can often deduce function boundaries even in fully stripped executable.

    Another thing you'll want to look at is strace/truss output, so you can see what system calls immediately precede the crash point.

提交回复
热议问题