On Wed, Sep 09, 2020 at 09:57:54PM +0200, Mark Wielaard wrote:
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -9057,13 +9057,14 @@ possible.
>  @opindex gdwarf
>  Produce debugging information in DWARF format (if that is supported).
>  The value of @var{version} may be either 2, 3, 4 or 5; the default version
> -for most targets is 4.  DWARF Version 5 is only experimental.
> +for most targets is 5 (with the exception of vxworks and darwin which
> +default to version 2).

I think in documentation we should spell these VxWorks and Darwin/Mac OS X

> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -29395,6 +29395,13 @@ prune_unused_types_walk (dw_die_ref die)
>         if (die->die_perennial_p)
>           break;
>  
> +       /* For static data members, the declaration in the class is supposed
> +          to have DW_TAG_member tag in DWARF{3,4} but DW_TAG_variable in
> +          DWARF5.  DW_TAG_member will be marked, so mark even such
> +          DW_TAG_variables in DWARF5.  */
> +       if (dwarf_version >= 5 && class_scope_p (die->die_parent))
> +         break;

I think to this Jason objected, so we need to figure out something else.

> --- a/gcc/gcc.c
> +++ b/gcc/gcc.c
> @@ -1882,6 +1882,11 @@ init_spec (void)
>    }
>  #endif
>  
> +  static const char dv[] = "%{g*:%{%:debug-level-gt(0):--gdwarf-5}} ";
> +  obstack_grow (&obstack, dv, sizeof (dv) - 1);
> +  obstack_grow0 (&obstack, asm_spec, strlen (asm_spec));
> +  asm_spec = XOBFINISH (&obstack, const char *);
> +
>  #if defined LINK_EH_SPEC || defined LINK_BUILDID_SPEC || \
>      defined LINKER_HASH_STYLE
>  # ifdef LINK_BUILDID_SPEC

and the above should be done in a different spot.

In particular:
 static const char *asm_options =
 "%{-target-help:%:print-asm-header()} "
 #if HAVE_GNU_AS
 /* If GNU AS is used, then convert -w (no warnings), -I, and -v
    to the assembler equivalents.  */
 "%{v} %{w:-W} %{I*} "
+ASM_DEBUG_OPTION_SPEC
 #endif
 ASM_COMPRESS_DEBUG_SPEC
 "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}";
and define ASM_DEBUG_OPTIONS_SPEC similarly to ASM_DEBUG_SPEC, except
that it would add something only for dwarf and only add --gdwarf-{2,3,4,5}
using dwarf-version-gt (ASM_DEBUG_SPEC would go first and only when
compiling *.s/*.S files).  Or maybe for HAVE_AS_GDWARF_5_DEBUG_FLAG
ASM_DEBUG_SPEC would never add --gdwarf2 and defer that to
ASM_DEBUG_OPTION_SPEC.

As for the test assembly, I'd say we should take
#define F void foo (void) {}
F
compile it with
gcc -S -O2 -g1 -dA -gno-as-loc-support -fno-merge-debug-strings
remove .cfi_* directives, remove the ret instruction, change @function
and @progbits to %function and %progbits, change .uleb128 to just .byte,
I think all the values should be small enough, maybe change .value to
.2byte and .long to .4byte (whatever is most portable across different
arches and gas versions), simplify (shorten) strings and adjust
sizes, and do something with the .quad directives, that is dependent on
the address size, perhaps just take those attributes out and adjust
.debug_abbrev?  Finally, remove all comments (emit them in the first case
just to better understand the debug info).

        Jakub

Reply via email to