Ranga Rao Ravuri <[EMAIL PROTECTED]> writes:
> Hi
> Here is little problem gdb never does
>
> I have a line in 'c' code like
>
> 10 int port;
> 11 .
> 12 .
> 13 .
> >>>> 14 x = htons(x);
> 15 .
> 16 .
> 17
> If I run this part of code on sun sparc with SunOs 5.7
> the htons is defined like
>
> #define htons(x) (x)
>
> How do I break on line 14 and see what is happening ? It never breaks on
> 14, rather it does on 15.
> All statements (x) = (x) are ignored by gdb.For each such a case the
> break point was set on next source statement.
> Is that gcc which optimizes the expressions like 'x=x' by removing from
> the code.
If you give gcc the -g flag, and not the -O flag, it is supposed to
generate code that behaves the way one would expect from the source
code. If you have compiled your program this way, and GDB doesn't let
you set a breakpoint on line 14, that is a bug. However, it's most
likely a GCC bug, not a GDB bug.
File: gcc.info, Node: Optimize Options, Next: Preprocessor Options, Prev: Debugging
Options, Up: Invoking GCC
Options That Control Optimization
=================================
These options control various sorts of optimizations:
`-O'
`-O1'
Optimize. Optimizing compilation takes somewhat more time, and a
lot more memory for a large function.
Without `-O', the compiler's goal is to reduce the cost of
compilation and to make debugging produce the expected results.
Statements are independent: if you stop the program with a
breakpoint between statements, you can then assign a new value to
any variable or change the program counter to any other statement
in the function and get exactly the results you would expect from
the source code.
Without `-O', the compiler only allocates variables declared
`register' in registers. The resulting compiled code is a little
worse than produced by PCC without `-O'.
_______________________________________________
Bug-gdb mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gdb