Re: Fwd: some questions about kernel debugging

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

 



loody <miloody@xxxxxxxxx> writes:

> 2010/7/14 Ian Lance Taylor <iant@xxxxxxxxxx>:
>> loody <miloody@xxxxxxxxx> writes:
>>
>>> I write a sample program and compile it with -O1 optimized.
>>> (such as gcc -g -O1 -o test test.c)
>>> And I can see the local variable.
>>> I attach my test program, kernel config and compile flags for your reference.
>>> appreciate your help,
>>
>> Thanks, but it seems like you are showing us a case which works.  Are
>> you asking why this works and the kernel doesn't work?  Can you show us
>> a case which doesn't work?
> I paste the content of my gdb as below:
> ( I stop at line 1242 and I try to print i but gdb refused)
>
> Program received signal 0, Signal 0.
> dummy_timer (_dum=<value optimized out>) at drivers/usb/gadget/dummy_hcd.c:1242
> (gdb) p i
> $13 = <value optimized out>
> (gdb) list
> 1237            }
> 1238
> 1239            for (i = 0; i < DUMMY_ENDPOINTS; i++) {
> 1240                    if (!ep_name [i])
> 1241                            break;
> 1242                    dum->ep [i].already_seen = 0;
> 1243            }
> 1244
> 1245    restart:
> 1246            list_for_each_entry_safe (urbp, tmp, &dum->urbp_list,
> urbp_list) {
> (gdb) p i
> $14 = <value optimized out>
> (gdb)

This means that the compiler did not emit any debugging information
which would permit gdb to print the variable.

In this case the variable 'i' is most likely entirely gone, and replaced
by code which simply walks two pointers.  It's also possible that the
loop was simply unrolled.  In other words, if you look at the generated
code, there may simply not be any value which corresponds to the
variable 'i' in the source code.

This is a normal scenario, and is what gdb is attempting to convey by
saying "value optimized out".

Ian



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux