about PR gdb/10002 (extern optimized out symbols print: Address of symbol is unknown)

Joel Brobecker
2009-03-25T22:26:15Z

Here is the testcase that Jan provided:

extern int missing;

int
main (void)
{
return 0 && missing;
}

This file is to be built using the following command:

% gcc -o kfail kfail.c -Wall -g

The debugger currently says that variable "missing" is unknown:

% gdb kfail
GNU gdb (GDB) 6.8.50.20090324-cvs
(gdb) p missing
Address of symbol "missing" is unknown.

The debugging information inside kfail.c says:

<1><55>: Abbrev Number: 4 (DW_TAG_variable)
<56> DW_AT_name : (indirect string, offset: 0x66): missing
<5c> DW_AT_type : <0x4e>
<60> DW_AT_external : 1
<61> DW_AT_declaration : 1

This seems correct to me. However, the testcase itself is a little
borderline in my opinion. The variable was not "optimized out", but
was never linked in. It's as if it really does not exist.

So I don't know if GDB is really all that incorrect, here. Thoughts?
Maybe there is a testcase a little more involved that shows the same
sort of issue?

--
Joel