What make the directive run twice?

Eli Zaretskii eliz@gnu.org
Fri Jun 4 12:11:00 GMT 2004

> Date: Fri, 04 Jun 2004 10:30:32 +0800
> From: Jason Luo <jasonl@turbolinux.com.cn>
> > It wasn't run twice; it appears in the step output twice.  This is
> > common when debugging optimized code; part of the function call occurs
> > before the previous line and part after.
> I disassemble the call function init_device_map,and the function 
> check_device,I didn't find that you says.
> init_device_map call check_deivce,then the control jump to the function 
> check_device,then process continue.The process flow is correct  like the 
> c source file's.

That's not the right way to analyze this.

When you type "next" in GDB, GDB needs to know how machine
instructions to run to land at the next source line.  So what you need
to do is to use a tool such as objdump to see what is the
correspondence between program code addresses and source lines.  That
is the information used by GDB during stepping.

My experience is consistent with what Daniel says: stepping through
optimized code quite often jumps between source lines like you saw.

More information about the Gdb mailing list