Skip to content
Advertisement

gdb step not working as expected

I am debugging static multi-threaded x86-64 C++ application on Linux.

I can set breakpoints on functions and stop on them and I can walk step by step over function body. But when I try to step into another function, gdb not stops at it’s beginning and it seems that it just continues execution. When I interrupt program execution, gdb goes to broken state and becomes unusable:

(gdb) bt
Target is executing.
(gdb) c
Continuing.
Cannot execute this command while the selected thread is running.
(gdb) 

As a workaround I can use stepi several times instead of step, stepi works as expected. What could be the reason of this behavior? Is there any workarounds besides using stepi? I am using gdb 7.6 and gcc 4.7.1.

Advertisement

Answer

What could be the reason of this behavior?

It’s a bug in GDB. It sets a temporary breakpoint and expects it to be hit. But the breakpoint doesn’t get hit (possibly because it was set in the wrong place), and GDB’s internal state machine gets all confused.

Is there any workarounds besides using stepi?

You can try upgrading to top-of-trunk GDB version from CVS, and if GDB is still broken, report the bug in GDB bugzilla.

Advertisement