Search code examples
dllgdbcygwin

gdb can not `next` over an non system dll function call


The problem is with the debugging code that has a call to some dll function, this one and others from the same dll:

EdsGetCameraList(&l);

when I break on this line and then issue a next command, I get a

(gdb) n
0x1000e620 in ?? ()

0x1000e620 is address of EdsGetCameraList:

(gdb) disas find_cam,+20
Dump of assembler code from 0x401783 to 0x401797:
   0x00401783 <find_cam+0>:     push   ebp
   0x00401784 <find_cam+1>:     mov    ebp,esp
   0x00401786 <find_cam+3>:     sub    esp,0x48
=> 0x00401789 <find_cam+6>:     lea    eax,[ebp-0x14]
   0x0040178c <find_cam+9>:     mov    DWORD PTR [esp],eax
   0x0040178f <find_cam+12>:    mov    eax,ds:0x4092dc
   0x00401794 <find_cam+17>:    call   eax
   0x00401796 <find_cam+19>:    sub    esp,0x4
End of assembler dump.
(gdb) x 0x4092dc
0x4092dc <_imp__EdsGetCameraList@4>:    0x1000e620

No wonder if I type next again I get:

(gdb) n
Cannot find bounds of current function

What is going on?


Solution

  • next steps over source lines - you need the debug information for the dll you're debugging if you want to do source line stepping. In this case there is no debug info available and gdb doesn't know where source lines start/end -- next won't do anything.

    Instead you'll need to use the instruction-level step commands, nexti and stepi (ni, si) to single instruction step through these routines. You can also use finish to return to the caller function.

    When people debug with gdb at this level, they often have gdb display the next few instructions as they step -- do disp/3i $pc to have the next three instructions displayed.