gdb command "next" wrongly working as command "step"

Pedro Alves palves@redhat.com
Fri Aug 23 21:54:00 GMT 2019


On 8/23/19 10:33 PM, William Tambe wrote:
> On Sun, Aug 18, 2019 at 4:06 AM Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
>> On Sun, 18 Aug 2019 10:31:54 +0200, William Tambe wrote:
>>> Can I have suggestions of locations within the gdb code where I could
>>> put breakpoints to trace where the issue I am having is occurring ?
>> Check what "set debug infrun 1" says and grep the sources for the displayed
>> messages.
>>
> Using "set debug infrun 1", I can see that GDB stops only after
> printing the following message:
> infrun: stepped to a different line.
> When the above event happens, GDB has stepped inside the function,
> which is obviously going to be on a different line; however, I am
> expecting GDB to step over the function.

Do a backtrace at this point.  GDB should see the caller in frame #1.
Sounds like it doesn't.

Or to be more accurate, use "stepi" to step to the first instruction
of the called function, and run "bt" there.

As Jan said, for "next" to work properly, backtrace/unwinding must work
properly.  When "next" behaves like "step", the most frequent reason
is that unwinding is broken.  "next" does a "backtrace" to detect whether
you've stepped into called function, and if you did, then it continues
execution to the address where the called function returns.

Thanks,
Pedro Alves



More information about the Gdb mailing list