bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gdb and assignment statements


From: Kevin Buettner
Subject: Re: Gdb and assignment statements
Date: Wed, 13 Dec 2000 23:45:28 -0700

On Dec 14, 11:34am, Ranga Rao Ravuri wrote:

>    Please let me give the complete code it self and explain what
> happened.
> The following code was compiled with command
> gcc -g3 -O0 x.c 
> >x.c>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>      1 #include <netinet/in.h>
>       2 main()
>       3 {
>       4    int port = 5060;
>       5 
>       6    port=htons(port);
>       7    printf("Port %d\n", port);
>       8 }
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> Here is gdb out put after setting up the break point on line 6 
> 
> (gdb) b 6
> Breakpoint 1 at 0x10a64: file x.c, line 6.
> (gdb) info break
> Num Type           Disp Enb Address    What
> 1   breakpoint     keep y   0x00010a64 in main at x.c:6
> (gdb) r
> Starting program: /export/home0/rangarao/examples/c/a.out 
> 
> Breakpoint 1, main () at x.c:7
> 7          printf("Port %d\n", port);
> (gdb) info break
> Num Type           Disp Enb Address    What
> 1   breakpoint     keep y   0x00010a64 in main at x.c:6
>         breakpoint already hit 1 time
> (gdb) info line 6
> Line 6 of "x.c" is at address 0x10a64 <main+16> but contains no code.
> 
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> Even after disabling the complete omptimization the no code generated
> for line 6
> If the 'port' is declared as STATIC gdb could break on that line and
> showing properly
> The earlier said behavior is observed even in case when 'port' is
> 'volatile'
> Or Is this has any thing with gcc ?
> Any suggestions please ..

I'm having trouble understanding why you wish to set a breakpoint on a
line that the compiler has optimized out as being a nop.  If line 6
(after macro expansion) is really ``port = port;'', what are you going
to learn by stopping on line 6 that you can't learn by stopping on
line 7?

In any event, gdb's mapping of program addresses to line numbers (and
vice versa) is determined by debugging information supplied by the
compiler.  gdb is not choosing to ignore this line; rather the
compiler produced no executable code associated for the line in
question and simply is not capable of supplying a mapping for that
line.

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]