------- Comment #5 from jan dot kratochvil at redhat dot com  2008-11-28 01:36 
-------
(In reply to comment #4)
> First, I think the DIE representing the defining declaration of A::elsewhere
> in class2.c should have a DW_AT_specification pointing back to the DIE
> representing the declaration or A::elsewhere in class.h.

Already present: non-defining declaration is <cf>, the defining declaration
is <ed>.  <ed> properly points by DW_AT_specification to its <cf>.


> Second, I think the DIE of the defining declaration of A::elsewhere in class2
> should have a DW_AT_const_value attribute whose value should be the constant
> "211".
> 
> This can be deduced from the dwarf2 spec, section [4.1 Data Object Entries],
> point 9, pdf page 35, spec page 33 that reads:
> 
> "9. An entry describing a variable whose value is constant and not represented
> by an object in the address space of the program, or an entry describing a
> named constant, does not have a location attribute.

DW_AT_const_value is more for Fortran constants which are an equivalent
of C #define.  In the sample code here `static const int' is in .rodata, it has
its address (DW_AT_location) and can be tracked by `rwatch' (read-watchpoint).

  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [15] .rodata           PROGBITS         0000000000400658  00000658
       0000000000000014  0000000000000000   A       0     0     8
Symbol table '.symtab' contains 73 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
    55: 0000000000400668     4 OBJECT  GLOBAL DEFAULT   15 _ZN1A9elsewhereE

It should be sufficient the type entry at <0xe1> (not shown in the sample dump
here) is already correctly DW_TAG_const_type.


> And third, as you pointed out, the DIE of the declaration of A::elsewhere
> should not appear twice in the class.c compilation unit. It should only appear
> once, in the scope of the A class.

Two vs. one DIE is not a mistake but more a minor optimization (such
optimization is already Bug debug/37941).

With single DIE it would look OK to me.  With two DIEs there are currently
these problems:

(1) DW_AT_name is now `elsewhere' while it should be either `A::elsewhere'
    or whole DW_TAG_variable should be enclosed by DW_TAG_class_type for `A'.
    It may be Bug c++/37590.
    (Non-standard DW_AT_MIPS_linkage_name should be removed in the future.)

(2) Defining declaration <86> should point by DW_AT_specification to its
    non-defining declaration <37>.  (The DWARF citation is here from Dodji.)

(But I do not see these two problems as real issues for debugging.)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37982

Reply via email to