Using gdb to single-step assembly code outside specified executable causes error "cannot find bounds of current function" Using gdb to single-step assembly code outside specified executable causes error "cannot find bounds of current function" linux linux

Using gdb to single-step assembly code outside specified executable causes error "cannot find bounds of current function"


Instead of gdb, run gdbtui. Or run gdb with the -tui switch. Or press C-x C-a after entering gdb. Now you're in GDB's TUI mode.

Enter layout asm to make the upper window display assembly -- this will automatically follow your instruction pointer, although you can also change frames or scroll around while debugging. Press C-x s to enter SingleKey mode, where run continue up down finish etc. are abbreviated to a single key, allowing you to walk through your program very quickly.

   +---------------------------------------------------------------------------+B+>|0x402670 <main>         push   %r15                                        |   |0x402672 <main+2>       mov    %edi,%r15d                                  |   |0x402675 <main+5>       push   %r14                                        |   |0x402677 <main+7>       push   %r13                                        |   |0x402679 <main+9>       mov    %rsi,%r13                                   |   |0x40267c <main+12>      push   %r12                                        |   |0x40267e <main+14>      push   %rbp                                        |   |0x40267f <main+15>      push   %rbx                                        |   |0x402680 <main+16>      sub    $0x438,%rsp                                 |   |0x402687 <main+23>      mov    (%rsi),%rdi                                 |   |0x40268a <main+26>      movq   $0x402a10,0x400(%rsp)                       |   |0x402696 <main+38>      movq   $0x0,0x408(%rsp)                            |   |0x4026a2 <main+50>      movq   $0x402510,0x410(%rsp)                       |   +---------------------------------------------------------------------------+child process 21518 In: main                            Line: ??   PC: 0x402670(gdb) file /opt/j64-602/bin/jconsoleReading symbols from /opt/j64-602/bin/jconsole...done.(no debugging symbols found)...done.(gdb) layout asm(gdb) start(gdb)


You can use stepi or nexti (which can be abbreviated to si or ni) to step through your machine code.


The most useful thing you can do here is display/i $pc, before using stepi as already suggested in R Samuel Klatchko's answer. This tells gdb to disassemble the current instruction just before printing the prompt each time; then you can just keep hitting Enter to repeat the stepi command.

(See my answer to another question for more detail - the context of that question was different, but the principle is the same.)