Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* about PR gdb/10002 (extern optimized out symbols print: Address of  symbol is unknown)
@ 2009-03-25 22:26 Joel Brobecker
  2009-03-25 23:00 ` Paul Pluzhnikov
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2009-03-25 22:26 UTC (permalink / raw)
  To: gdb

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: about PR gdb/10002 (extern optimized out symbols print: Address   of symbol is unknown)
  2009-03-25 22:26 about PR gdb/10002 (extern optimized out symbols print: Address of symbol is unknown) Joel Brobecker
@ 2009-03-25 23:00 ` Paul Pluzhnikov
  2009-03-26 14:15   ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Pluzhnikov @ 2009-03-25 23:00 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb

On Wed, Mar 25, 2009 at 3:26 PM, Joel Brobecker <brobecker@adacore.com> wrote:

> This seems correct to me.  However, the testcase itself is a little
> borderline in my opinion.

The test case depends on compiler's ability to optimize out reference to
"missing". If the compiler couldn't do that, you'd get an unresolved symbol
at link time.

> The variable was not "optimized out", but was never linked in.

Well, the reference to the variable was optimized out.

> It's as if it really does not exist.

I think it's not "as if"; it *really* doesn't.

> So I don't know if GDB is really all that incorrect, here. Thoughts?

I don't see anything wrong about GDB's output.

-- 
Paul Pluzhnikov


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: about PR gdb/10002 (extern optimized out symbols print:  Address   of symbol is unknown)
  2009-03-25 23:00 ` Paul Pluzhnikov
@ 2009-03-26 14:15   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2009-03-26 14:15 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: Joel Brobecker, gdb

On Thu, 26 Mar 2009 00:00:24 +0100, Paul Pluzhnikov wrote:
> depends on compiler's ability to optimize out reference to "missing". If the
> compiler couldn't do that, you'd get an unresolved symbol at link time.

The target of that code was to produce:
 <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

The real test case
  http://sourceware.org/ml/gdb-patches/2009-03/msg00545.html
uses .S for DWARF.  This C code was just an easy easy how to
arch-independently create a reproducer of the GDB problem for the reader.


> > The variable was not "optimized out", but was never linked in.
> 
> Well, the reference to the variable was optimized out.

I see now in DWARF3 4.1 point 4:
# In a variable entry representing the definition of a variable (that is, with
# no DW_AT_declaration attribute) if no location attribute is present [...],
# the variable is assumed to exist in the source code but not in the executable
# program [...]

As there is present DW_AT_declaration the variable is not considered as
<optimized out> by DWARF.  I overlooked this condition of DWARF so far.

Going to close this PR gdb/10002 as invalid I also find now GDB is correct
now.


Still it is questionable how to reprosent by ELF/DWARF if the other
compilation unit would have the variable "missing" optimized out if GCC LTO
would find no reference to it.  But this is not an actual problem to solve.


Thanks,
Jan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-03-26 14:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-25 22:26 about PR gdb/10002 (extern optimized out symbols print: Address of symbol is unknown) Joel Brobecker
2009-03-25 23:00 ` Paul Pluzhnikov
2009-03-26 14:15   ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox