[rfc] -gdwarf-3 and DW_OP_call_frame_cfa

Joseph S. Myers joseph@codesourcery.com
Tue Jun 9 11:42:00 GMT 2009


On Tue, 9 Jun 2009, Richard Henderson wrote:

> I don't necessarily take it as given that we want a switch to
> select DWARF 3 vs DWARF 2, given that we're already generating
> some DWARF 3 extensions unconditionally.  We might simply want
> to do all of DWARF3 unconditionally and hope consumers can cope.

If you do generate DWARF3 labelled as version 3, however, whether 
unconditionally or conditionally, you need to ensure that where the same 
data has different interpretations as DWARF2 and DWARF3 the correct 
version is output for the version selected.  For example, bfd/dwarf2.c has

    case DW_FORM_ref_addr:
      /* DW_FORM_ref_addr is an address in DWARF2, and an offset in
         DWARF3.  */
      if (unit->version == 3)
        {
          if (unit->offset_size == 4)
            attr->u.val = read_4_bytes (unit->abfd, info_ptr);
          else
            attr->u.val = read_8_bytes (unit->abfd, info_ptr);
          info_ptr += unit->offset_size;
          break;
        }
      /* FALLTHROUGH */

which may need corresponding conditionals in DWARF[23] generation, and I 
have not checked for other such cases in the DWARF[23] specifications 
(whether or not correctly handled by BFD or GDB at present).

This of course does not apply to simple extensions which do not appear in 
the DWARF2 specification at all, just to things that appear in both but 
with different meanings.

> There is one quirk.  Previously we'd accept options like -gdwarf-23
> and take that to mean dwarf2 debugging, verbosity level 3.  Now
> you *must* write this as -gdwarf-2 -g3.  Which, frankly, is what I
> thought we had to do beforehand and was surprised at the error
> message I got while testing the handling of -gdwarf-4.

When DWARF1 was supported there were errors

cc1: use -gdwarf -g2 for DWARF v1, level 2
cc1: use -gdwarf-2   for DWARF v2

if you used -gdwarf2; reinstating something like that seems reasonable to 
me.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list