diff mbox

DWARF support for AIX v3

Message ID CAGWvnynQevxr0ey85G7940zuHkbZrhNj25U8ZTLO0S9LkgGm_A@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn Sept. 21, 2015, 3:41 p.m. UTC
Appended is a patch to support DWARF on AIX and works with GDB and AIX
assembler.  The AIX assembler prepends the CU length to the section
and does not want the compiler to provide it, so I need to disable
those parts of dwarf2out.c.  I know it's ugly, but, on the upside,
this eventually allows GCC to deprecate Stabs, which I think is worth
the pain.

I discovered that -g3 emits the debug_macros section, which AIX also
does not like, so I disable that section as well.  As I mentioned in
v2, I moved the calculation of aranges_length to its one use in the
output function instead of calculating it early to avoid an unused
function argument.

I also switched to XCOFF_DEBUGGING_INFO as the macro to test in
dwarf2out.c.  I think a target hook or testing that DWARF section
names have not been overridden to NULL is overkill. Suggestions
welcome, but any solution that disables arbitrary portions of
dwarf2out.c is going to be ugly. I doubt that any other system,
especially ones based on ELF file format, would ever do this.

With a few tweaks to the testsuite, this passes GCC dwarf2 tests.

Thanks, David

        * dwarf2out.c (size_of_pubnames): Don't define on AIX.
        (size_of_aranges): Don't define on AIX.
        (output_compilation_unit_header): Don't output length on AIX.
        (output_pubnames): Don't output length on AIX.
        (output_aranges): Delete argument. Compute length locally. Don't
        output length on AIX.
        (output_line_info): Don't output length on AIX.
        (dwarf2out_finish): Don't output location lists on AIX.
        Don't compute aranges_length. Don't output macros section.
        * config/rs6000/rs6000.c (rs6000_xcoff_debug_unwind_info):
        New.
        (rs6000_xcoff_asm_named_section): Emit .dwsect pseudo-op
        for SECTION_DEBUG.
        (rs6000_xcoff_declare_function_name): Emit different
        .function pseudo-op when DWARF2_DEBUG.
        * config/rs6000/xcoff.h (TARGET_DEBUG_UNWIND_INFO):
        Redefine.
        * config/rs6000/aix71.h (DWARF2_DEBUGGING_INFO): Define.
        (PREFERRED_DEBUGGING_TYPE): Define.
        (DEBUG_INFO_SECTION): Define.
        (DEBUG_ABBREV_SECTION): Define.
        (DEBUG_ARANGES_SECTION): Define.
        (DEBUG_LINE_SECTION): Define.
        (DEBUG_PUBNAMES_SECTION): Define.
        (DEBUG_PUBTYPES_SECTION): Define.
        (DEBUG_STR_SECTION): Define.
        (DEBUG_RANGES_SECTION): Define.

Index: config/rs6000/aix71.h
===================================================================
+/* AIX 7.1 supports DWARF debugging, but XCOFF remains the default.  */
+#define DWARF2_DEBUGGING_INFO 1
+#define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
+#define DEBUG_INFO_SECTION      "0x10000"
+#define DEBUG_ABBREV_SECTION    "0x60000"
+#define DEBUG_ARANGES_SECTION   "0x50000"
+#define DEBUG_LINE_SECTION      "0x20000"
+#define DEBUG_PUBNAMES_SECTION  "0x30000"
+#define DEBUG_PUBTYPES_SECTION  "0x40000"
+#define DEBUG_STR_SECTION       "0x70000"
+#define DEBUG_RANGES_SECTION    "0x80000"

Comments

Richard Biener Sept. 22, 2015, 8:12 a.m. UTC | #1
On Mon, Sep 21, 2015 at 5:41 PM, David Edelsohn <dje.gcc@gmail.com> wrote:
> Appended is a patch to support DWARF on AIX and works with GDB and AIX
> assembler.  The AIX assembler prepends the CU length to the section
> and does not want the compiler to provide it, so I need to disable
> those parts of dwarf2out.c.  I know it's ugly, but, on the upside,
> this eventually allows GCC to deprecate Stabs, which I think is worth
> the pain.
>
> I discovered that -g3 emits the debug_macros section, which AIX also
> does not like, so I disable that section as well.  As I mentioned in
> v2, I moved the calculation of aranges_length to its one use in the
> output function instead of calculating it early to avoid an unused
> function argument.
>
> I also switched to XCOFF_DEBUGGING_INFO as the macro to test in
> dwarf2out.c.  I think a target hook or testing that DWARF section
> names have not been overridden to NULL is overkill. Suggestions
> welcome, but any solution that disables arbitrary portions of
> dwarf2out.c is going to be ugly. I doubt that any other system,
> especially ones based on ELF file format, would ever do this.

Using an existing macro works for me - but as we are working towards
eliminating conditional compilation can you try using

  if (!XCOFF_DEBUGGING_INFO)

?  If the macro is not always defined devise a new one defined from
XCOFF_DEBUGGING_INFO.

Richard.

> With a few tweaks to the testsuite, this passes GCC dwarf2 tests.
>
> Thanks, David
>
>         * dwarf2out.c (size_of_pubnames): Don't define on AIX.
>         (size_of_aranges): Don't define on AIX.
>         (output_compilation_unit_header): Don't output length on AIX.
>         (output_pubnames): Don't output length on AIX.
>         (output_aranges): Delete argument. Compute length locally. Don't
>         output length on AIX.
>         (output_line_info): Don't output length on AIX.
>         (dwarf2out_finish): Don't output location lists on AIX.
>         Don't compute aranges_length. Don't output macros section.
>         * config/rs6000/rs6000.c (rs6000_xcoff_debug_unwind_info):
>         New.
>         (rs6000_xcoff_asm_named_section): Emit .dwsect pseudo-op
>         for SECTION_DEBUG.
>         (rs6000_xcoff_declare_function_name): Emit different
>         .function pseudo-op when DWARF2_DEBUG.
>         * config/rs6000/xcoff.h (TARGET_DEBUG_UNWIND_INFO):
>         Redefine.
>         * config/rs6000/aix71.h (DWARF2_DEBUGGING_INFO): Define.
>         (PREFERRED_DEBUGGING_TYPE): Define.
>         (DEBUG_INFO_SECTION): Define.
>         (DEBUG_ABBREV_SECTION): Define.
>         (DEBUG_ARANGES_SECTION): Define.
>         (DEBUG_LINE_SECTION): Define.
>         (DEBUG_PUBNAMES_SECTION): Define.
>         (DEBUG_PUBTYPES_SECTION): Define.
>         (DEBUG_STR_SECTION): Define.
>         (DEBUG_RANGES_SECTION): Define.
>
> Index: dwarf2out.c
> ===================================================================
> --- dwarf2out.c (revision 227959)
> +++ dwarf2out.c (working copy)
> @@ -3185,8 +3185,10 @@ static void calc_base_type_die_sizes (void);
>  static void mark_dies (dw_die_ref);
>  static void unmark_dies (dw_die_ref);
>  static void unmark_all_dies (dw_die_ref);
> +#ifndef XCOFF_DEBUGGING_INFO
>  static unsigned long size_of_pubnames (vec<pubname_entry, va_gc> *);
>  static unsigned long size_of_aranges (void);
> +#endif
>  static enum dwarf_form value_format (dw_attr_node *);
>  static void output_value_format (dw_attr_node *);
>  static void output_abbrev_section (void);
> @@ -3202,7 +3204,7 @@ static void add_enumerator_pubname (const char *,
>  static void add_pubname_string (const char *, dw_die_ref);
>  static void add_pubtype (tree, dw_die_ref);
>  static void output_pubnames (vec<pubname_entry, va_gc> *);
> -static void output_aranges (unsigned long);
> +static void output_aranges (void);
>  static unsigned int add_ranges_num (int);
>  static unsigned int add_ranges (const_tree);
>  static void add_ranges_by_labels (dw_die_ref, const char *, const char *,
> @@ -8387,6 +8389,7 @@ include_pubname_in_output (vec<pubname_entry, va_g
>            || !flag_eliminate_unused_debug_types);
>  }
>
> +#ifndef XCOFF_DEBUGGING_INFO
>  /* Return the size of the .debug_pubnames or .debug_pubtypes table
>     generated for the compilation unit.  */
>
> @@ -8441,6 +8444,7 @@ size_of_aranges (void)
>    size += 2 * DWARF2_ADDR_SIZE;
>    return size;
>  }
> +#endif
>  ^L
>  /* Select the encoding of an attribute value.  */
>
> @@ -9198,12 +9202,14 @@ output_compilation_unit_header (void)
>       DWARFv5 draft DIE tags in DWARFv4 format.  */
>    int ver = dwarf_version < 5 ? dwarf_version : 4;
>
> +#ifndef XCOFF_DEBUGGING_INFO
>    if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
>      dw2_asm_output_data (4, 0xffffffff,
>        "Initial length escape value indicating 64-bit DWARF extension");
>    dw2_asm_output_data (DWARF_OFFSET_SIZE,
>                        next_die_offset - DWARF_INITIAL_LENGTH_SIZE,
>                        "Length of Compilation Unit Info");
> +#endif
>    dw2_asm_output_data (2, ver, "DWARF version number");
>    dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label,
>                          debug_abbrev_section,
> @@ -9630,13 +9636,16 @@ static void
>  output_pubnames (vec<pubname_entry, va_gc> *names)
>  {
>    unsigned i;
> -  unsigned long pubnames_length = size_of_pubnames (names);
>    pubname_entry *pub;
>
> +#ifndef XCOFF_DEBUGGING_INFO
> +  unsigned long pubnames_length = size_of_pubnames (names);
> +
>    if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
>      dw2_asm_output_data (4, 0xffffffff,
>        "Initial length escape value indicating 64-bit DWARF extension");
>    dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length, "Pub Info Length");
> +#endif
>
>    /* Version number for pubnames/pubtypes is independent of dwarf version.  */
>    dw2_asm_output_data (2, 2, "DWARF Version");
> @@ -9706,15 +9715,19 @@ output_pubtables (void)
>     text section generated for this compilation unit.  */
>
>  static void
> -output_aranges (unsigned long aranges_length)
> +output_aranges (void)
>  {
>    unsigned i;
>
> -  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
> +#ifndef XCOFF_DEBUGGING_INFO
> +  unsigned long aranges_length = size_of_aranges ();
> +
> +if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
>      dw2_asm_output_data (4, 0xffffffff,
>        "Initial length escape value indicating 64-bit DWARF extension");
>    dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
>                        "Length of Address Ranges Info");
> +#endif
>    /* Version number for aranges is still 2, even up to DWARF5.  */
>    dw2_asm_output_data (2, 2, "DWARF Version");
>    if (dwarf_split_debug_info)
> @@ -10398,11 +10411,13 @@ output_line_info (bool prologue_only)
>    ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, 0);
>    ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, 0);
>
> +#ifndef XCOFF_DEBUGGING_INFO
>    if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
>      dw2_asm_output_data (4, 0xffffffff,
>        "Initial length escape value indicating 64-bit DWARF extension");
>    dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
>                         "Length of Source Line Info");
> +#endif
>    ASM_OUTPUT_LABEL (asm_out_file, l1);
>
>    dw2_asm_output_data (2, ver, "DWARF Version");
> @@ -25486,6 +25501,7 @@ dwarf2out_finish (const char *filename)
>        output_abbrev_section ();
>      }
>
> +#ifndef XCOFF_DEBUGGING_INFO
>    /* Output location list section if necessary.  */
>    if (have_location_lists)
>      {
> @@ -25494,6 +25510,7 @@ dwarf2out_finish (const char *filename)
>        ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
>        output_location_lists (comp_unit_die ());
>      }
> +#endif
>
>    output_pubtables ();
>
> @@ -25504,10 +25521,8 @@ dwarf2out_finish (const char *filename)
>       generate a table that would have contained data.  */
>    if (info_section_emitted)
>      {
> -      unsigned long aranges_length = size_of_aranges ();
> -
>        switch_to_section (debug_aranges_section);
> -      output_aranges (aranges_length);
> +      output_aranges ();
>      }
>
>    /* Output ranges section if necessary.  */
> @@ -25518,6 +25533,7 @@ dwarf2out_finish (const char *filename)
>        output_ranges ();
>      }
>
> +#ifndef XCOFF_DEBUGGING_INFO
>    /* Have to end the macro section.  */
>    if (have_macinfo)
>      {
> @@ -25526,6 +25542,7 @@ dwarf2out_finish (const char *filename)
>        output_macinfo ();
>        dw2_asm_output_data (1, 0, "End compilation unit");
>      }
> +#endif
>
>    /* Output the source line correspondence table.  We must do this
>       even if there is no line information.  Otherwise, on an empty
> Index: config/rs6000/rs6000.c
> ===================================================================
> --- config/rs6000/rs6000.c      (revision 227937)
> +++ config/rs6000/rs6000.c      (working copy)
> @@ -30684,6 +30684,12 @@
>  #endif
>
>  #if TARGET_XCOFF
> +static enum unwind_info_type
> +rs6000_xcoff_debug_unwind_info (void)
> +{
> +  return UI_NONE;
> +}
> +
>  static void
>  rs6000_xcoff_asm_output_anchor (rtx symbol)
>  {
> @@ -30805,6 +30811,11 @@
>    int smclass;
>    static const char * const suffix[4] = { "PR", "RO", "RW", "TL" };
>
> +  if (flags & SECTION_DEBUG)
> +    {
> +      fprintf (asm_out_file, "\t.dwsect %s\n", name);
> +      return;
> +    }
>    if (flags & SECTION_CODE)
>      smclass = 0;
>    else if (flags & SECTION_TLS)
> @@ -31140,8 +31151,16 @@
>    fputs (":\n", file);
>    data.function_descriptor = true;
>    symtab_node::get (decl)->call_for_symbol_and_aliases (rs6000_declare_alias, &
> data, true);
> -  if (write_symbols != NO_DEBUG && !DECL_IGNORED_P (decl))
> -    xcoffout_declare_function (file, decl, buffer);
> +  if (!DECL_IGNORED_P (decl))
> +    {
> +      if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
> +       xcoffout_declare_function (file, decl, buffer);
> +      else if (write_symbols == DWARF2_DEBUG)
> +       {
> +         name = (*targetm.strip_name_encoding) (name);
> +         fprintf (file, "\t.function .%s,.%s,2,0\n", name, name);
> +       }
> +    }
>    return;
>  }
>
> Index: config/rs6000/xcoff.h
> ===================================================================
> --- config/rs6000/xcoff.h       (revision 227937)
> +++ config/rs6000/xcoff.h       (working copy)
> @@ -86,6 +86,8 @@
>                || (SCALAR_FLOAT_MODE_P (GET_MODE (X))                   \
>                    && ! TARGET_NO_FP_IN_TOC)))))
>
> +#undef TARGET_DEBUG_UNWIND_INFO
> +#define TARGET_DEBUG_UNWIND_INFO  rs6000_xcoff_debug_unwind_info
>  #define TARGET_ASM_OUTPUT_ANCHOR  rs6000_xcoff_asm_output_anchor
>  #define TARGET_ASM_GLOBALIZE_LABEL  rs6000_xcoff_asm_globalize_label
>  #define TARGET_ASM_INIT_SECTIONS  rs6000_xcoff_asm_init_sections
> Index: config/rs6000/aix71.h
> ===================================================================
> +/* AIX 7.1 supports DWARF debugging, but XCOFF remains the default.  */
> +#define DWARF2_DEBUGGING_INFO 1
> +#define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
> +#define DEBUG_INFO_SECTION      "0x10000"
> +#define DEBUG_ABBREV_SECTION    "0x60000"
> +#define DEBUG_ARANGES_SECTION   "0x50000"
> +#define DEBUG_LINE_SECTION      "0x20000"
> +#define DEBUG_PUBNAMES_SECTION  "0x30000"
> +#define DEBUG_PUBTYPES_SECTION  "0x40000"
> +#define DEBUG_STR_SECTION       "0x70000"
> +#define DEBUG_RANGES_SECTION    "0x80000"
David Edelsohn Sept. 22, 2015, 12:38 p.m. UTC | #2
On Tue, Sep 22, 2015 at 4:12 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Mon, Sep 21, 2015 at 5:41 PM, David Edelsohn <dje.gcc@gmail.com> wrote:
>> Appended is a patch to support DWARF on AIX and works with GDB and AIX
>> assembler.  The AIX assembler prepends the CU length to the section
>> and does not want the compiler to provide it, so I need to disable
>> those parts of dwarf2out.c.  I know it's ugly, but, on the upside,
>> this eventually allows GCC to deprecate Stabs, which I think is worth
>> the pain.
>>
>> I discovered that -g3 emits the debug_macros section, which AIX also
>> does not like, so I disable that section as well.  As I mentioned in
>> v2, I moved the calculation of aranges_length to its one use in the
>> output function instead of calculating it early to avoid an unused
>> function argument.
>>
>> I also switched to XCOFF_DEBUGGING_INFO as the macro to test in
>> dwarf2out.c.  I think a target hook or testing that DWARF section
>> names have not been overridden to NULL is overkill. Suggestions
>> welcome, but any solution that disables arbitrary portions of
>> dwarf2out.c is going to be ugly. I doubt that any other system,
>> especially ones based on ELF file format, would ever do this.
>
> Using an existing macro works for me - but as we are working towards
> eliminating conditional compilation can you try using
>
>   if (!XCOFF_DEBUGGING_INFO)
>
> ?  If the macro is not always defined devise a new one defined from
> XCOFF_DEBUGGING_INFO.

You prefer that I define a new macro in defaults.h instead of

#ifndef XCOFF_DEBUGGING_INFO
#define XCOFF_DEBUGGING_INFO 0
#endif

in dwarf2out.c?

- David
Richard Biener Sept. 22, 2015, 1:16 p.m. UTC | #3
On September 22, 2015 2:38:34 PM GMT+02:00, David Edelsohn <dje.gcc@gmail.com> wrote:
>On Tue, Sep 22, 2015 at 4:12 AM, Richard Biener
><richard.guenther@gmail.com> wrote:
>> On Mon, Sep 21, 2015 at 5:41 PM, David Edelsohn <dje.gcc@gmail.com>
>wrote:
>>> Appended is a patch to support DWARF on AIX and works with GDB and
>AIX
>>> assembler.  The AIX assembler prepends the CU length to the section
>>> and does not want the compiler to provide it, so I need to disable
>>> those parts of dwarf2out.c.  I know it's ugly, but, on the upside,
>>> this eventually allows GCC to deprecate Stabs, which I think is
>worth
>>> the pain.
>>>
>>> I discovered that -g3 emits the debug_macros section, which AIX also
>>> does not like, so I disable that section as well.  As I mentioned in
>>> v2, I moved the calculation of aranges_length to its one use in the
>>> output function instead of calculating it early to avoid an unused
>>> function argument.
>>>
>>> I also switched to XCOFF_DEBUGGING_INFO as the macro to test in
>>> dwarf2out.c.  I think a target hook or testing that DWARF section
>>> names have not been overridden to NULL is overkill. Suggestions
>>> welcome, but any solution that disables arbitrary portions of
>>> dwarf2out.c is going to be ugly. I doubt that any other system,
>>> especially ones based on ELF file format, would ever do this.
>>
>> Using an existing macro works for me - but as we are working towards
>> eliminating conditional compilation can you try using
>>
>>   if (!XCOFF_DEBUGGING_INFO)
>>
>> ?  If the macro is not always defined devise a new one defined from
>> XCOFF_DEBUGGING_INFO.
>
>You prefer that I define a new macro in defaults.h instead of
>
>#ifndef XCOFF_DEBUGGING_INFO
>#define XCOFF_DEBUGGING_INFO 0
>#endif
>
>in dwarf2out.c?

Or, if that works, add a default for XCOFF_DEBUGGING_INFO.

I thought of a dwarf2out.c local define.

Richard.

>
>- David
Trevor Saunders Sept. 22, 2015, 1:54 p.m. UTC | #4
On Tue, Sep 22, 2015 at 03:16:28PM +0200, Richard Biener wrote:
> On September 22, 2015 2:38:34 PM GMT+02:00, David Edelsohn <dje.gcc@gmail.com> wrote:
> >On Tue, Sep 22, 2015 at 4:12 AM, Richard Biener
> ><richard.guenther@gmail.com> wrote:
> >> On Mon, Sep 21, 2015 at 5:41 PM, David Edelsohn <dje.gcc@gmail.com>
> >wrote:
> >>> Appended is a patch to support DWARF on AIX and works with GDB and
> >AIX
> >>> assembler.  The AIX assembler prepends the CU length to the section
> >>> and does not want the compiler to provide it, so I need to disable
> >>> those parts of dwarf2out.c.  I know it's ugly, but, on the upside,
> >>> this eventually allows GCC to deprecate Stabs, which I think is
> >worth
> >>> the pain.
> >>>
> >>> I discovered that -g3 emits the debug_macros section, which AIX also
> >>> does not like, so I disable that section as well.  As I mentioned in
> >>> v2, I moved the calculation of aranges_length to its one use in the
> >>> output function instead of calculating it early to avoid an unused
> >>> function argument.
> >>>
> >>> I also switched to XCOFF_DEBUGGING_INFO as the macro to test in
> >>> dwarf2out.c.  I think a target hook or testing that DWARF section
> >>> names have not been overridden to NULL is overkill. Suggestions
> >>> welcome, but any solution that disables arbitrary portions of
> >>> dwarf2out.c is going to be ugly. I doubt that any other system,
> >>> especially ones based on ELF file format, would ever do this.
> >>
> >> Using an existing macro works for me - but as we are working towards
> >> eliminating conditional compilation can you try using
> >>
> >>   if (!XCOFF_DEBUGGING_INFO)
> >>
> >> ?  If the macro is not always defined devise a new one defined from
> >> XCOFF_DEBUGGING_INFO.
> >
> >You prefer that I define a new macro in defaults.h instead of
> >
> >#ifndef XCOFF_DEBUGGING_INFO
> >#define XCOFF_DEBUGGING_INFO 0
> >#endif
> >
> >in dwarf2out.c?
> 
> Or, if that works, add a default for XCOFF_DEBUGGING_INFO.
> 
> I thought of a dwarf2out.c local define.

I wouldn't worry about this too much, I have local patches turning the
X_DEBUGGING_INFO macros into 0/1 instead of undef / def, so which I
expect to commit in the next week or so.

Trev

> 
> Richard.
> 
> >
> >- David
> 
>
David Edelsohn Sept. 22, 2015, 2:09 p.m. UTC | #5
On Tue, Sep 22, 2015 at 9:54 AM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
> On Tue, Sep 22, 2015 at 03:16:28PM +0200, Richard Biener wrote:
>> On September 22, 2015 2:38:34 PM GMT+02:00, David Edelsohn <dje.gcc@gmail.com> wrote:
>> >On Tue, Sep 22, 2015 at 4:12 AM, Richard Biener
>> ><richard.guenther@gmail.com> wrote:
>> >> On Mon, Sep 21, 2015 at 5:41 PM, David Edelsohn <dje.gcc@gmail.com>
>> >wrote:
>> >>> Appended is a patch to support DWARF on AIX and works with GDB and
>> >AIX
>> >>> assembler.  The AIX assembler prepends the CU length to the section
>> >>> and does not want the compiler to provide it, so I need to disable
>> >>> those parts of dwarf2out.c.  I know it's ugly, but, on the upside,
>> >>> this eventually allows GCC to deprecate Stabs, which I think is
>> >worth
>> >>> the pain.
>> >>>
>> >>> I discovered that -g3 emits the debug_macros section, which AIX also
>> >>> does not like, so I disable that section as well.  As I mentioned in
>> >>> v2, I moved the calculation of aranges_length to its one use in the
>> >>> output function instead of calculating it early to avoid an unused
>> >>> function argument.
>> >>>
>> >>> I also switched to XCOFF_DEBUGGING_INFO as the macro to test in
>> >>> dwarf2out.c.  I think a target hook or testing that DWARF section
>> >>> names have not been overridden to NULL is overkill. Suggestions
>> >>> welcome, but any solution that disables arbitrary portions of
>> >>> dwarf2out.c is going to be ugly. I doubt that any other system,
>> >>> especially ones based on ELF file format, would ever do this.
>> >>
>> >> Using an existing macro works for me - but as we are working towards
>> >> eliminating conditional compilation can you try using
>> >>
>> >>   if (!XCOFF_DEBUGGING_INFO)
>> >>
>> >> ?  If the macro is not always defined devise a new one defined from
>> >> XCOFF_DEBUGGING_INFO.
>> >
>> >You prefer that I define a new macro in defaults.h instead of
>> >
>> >#ifndef XCOFF_DEBUGGING_INFO
>> >#define XCOFF_DEBUGGING_INFO 0
>> >#endif
>> >
>> >in dwarf2out.c?
>>
>> Or, if that works, add a default for XCOFF_DEBUGGING_INFO.
>>
>> I thought of a dwarf2out.c local define.
>
> I wouldn't worry about this too much, I have local patches turning the
> X_DEBUGGING_INFO macros into 0/1 instead of undef / def, so which I
> expect to commit in the next week or so.

XCOFF_DEBUGGING_INFO currently conditionally includes header files and
conditionally compiles code that depends on macros only defined for
AIX.  You addressed all of those dependencies?

Thanks, David
David Edelsohn Sept. 22, 2015, 2:12 p.m. UTC | #6
On Tue, Sep 22, 2015 at 9:16 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On September 22, 2015 2:38:34 PM GMT+02:00, David Edelsohn <dje.gcc@gmail.com> wrote:
>>On Tue, Sep 22, 2015 at 4:12 AM, Richard Biener
>><richard.guenther@gmail.com> wrote:
>>> On Mon, Sep 21, 2015 at 5:41 PM, David Edelsohn <dje.gcc@gmail.com>
>>wrote:
>>>> Appended is a patch to support DWARF on AIX and works with GDB and
>>AIX
>>>> assembler.  The AIX assembler prepends the CU length to the section
>>>> and does not want the compiler to provide it, so I need to disable
>>>> those parts of dwarf2out.c.  I know it's ugly, but, on the upside,
>>>> this eventually allows GCC to deprecate Stabs, which I think is
>>worth
>>>> the pain.
>>>>
>>>> I discovered that -g3 emits the debug_macros section, which AIX also
>>>> does not like, so I disable that section as well.  As I mentioned in
>>>> v2, I moved the calculation of aranges_length to its one use in the
>>>> output function instead of calculating it early to avoid an unused
>>>> function argument.
>>>>
>>>> I also switched to XCOFF_DEBUGGING_INFO as the macro to test in
>>>> dwarf2out.c.  I think a target hook or testing that DWARF section
>>>> names have not been overridden to NULL is overkill. Suggestions
>>>> welcome, but any solution that disables arbitrary portions of
>>>> dwarf2out.c is going to be ugly. I doubt that any other system,
>>>> especially ones based on ELF file format, would ever do this.
>>>
>>> Using an existing macro works for me - but as we are working towards
>>> eliminating conditional compilation can you try using
>>>
>>>   if (!XCOFF_DEBUGGING_INFO)
>>>
>>> ?  If the macro is not always defined devise a new one defined from
>>> XCOFF_DEBUGGING_INFO.
>>
>>You prefer that I define a new macro in defaults.h instead of
>>
>>#ifndef XCOFF_DEBUGGING_INFO
>>#define XCOFF_DEBUGGING_INFO 0
>>#endif
>>
>>in dwarf2out.c?
>
> Or, if that works, add a default for XCOFF_DEBUGGING_INFO.
>
> I thought of a dwarf2out.c local define.

That's what I'm testing now.

I also need a small change in dwarf2asm.c because it explicitly emits
the ELF ".ascii" directive for commented assembly.  It cannot use
ASM_OUTPUT_ASCII because that would prematurely emit a "\n".

Thanks, David
Trevor Saunders Sept. 22, 2015, 2:19 p.m. UTC | #7
On Tue, Sep 22, 2015 at 10:09:51AM -0400, David Edelsohn wrote:
> On Tue, Sep 22, 2015 at 9:54 AM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
> > On Tue, Sep 22, 2015 at 03:16:28PM +0200, Richard Biener wrote:
> >> On September 22, 2015 2:38:34 PM GMT+02:00, David Edelsohn <dje.gcc@gmail.com> wrote:
> >> >On Tue, Sep 22, 2015 at 4:12 AM, Richard Biener
> >> ><richard.guenther@gmail.com> wrote:
> >> >> On Mon, Sep 21, 2015 at 5:41 PM, David Edelsohn <dje.gcc@gmail.com>
> >> >wrote:
> >> >>> Appended is a patch to support DWARF on AIX and works with GDB and
> >> >AIX
> >> >>> assembler.  The AIX assembler prepends the CU length to the section
> >> >>> and does not want the compiler to provide it, so I need to disable
> >> >>> those parts of dwarf2out.c.  I know it's ugly, but, on the upside,
> >> >>> this eventually allows GCC to deprecate Stabs, which I think is
> >> >worth
> >> >>> the pain.
> >> >>>
> >> >>> I discovered that -g3 emits the debug_macros section, which AIX also
> >> >>> does not like, so I disable that section as well.  As I mentioned in
> >> >>> v2, I moved the calculation of aranges_length to its one use in the
> >> >>> output function instead of calculating it early to avoid an unused
> >> >>> function argument.
> >> >>>
> >> >>> I also switched to XCOFF_DEBUGGING_INFO as the macro to test in
> >> >>> dwarf2out.c.  I think a target hook or testing that DWARF section
> >> >>> names have not been overridden to NULL is overkill. Suggestions
> >> >>> welcome, but any solution that disables arbitrary portions of
> >> >>> dwarf2out.c is going to be ugly. I doubt that any other system,
> >> >>> especially ones based on ELF file format, would ever do this.
> >> >>
> >> >> Using an existing macro works for me - but as we are working towards
> >> >> eliminating conditional compilation can you try using
> >> >>
> >> >>   if (!XCOFF_DEBUGGING_INFO)
> >> >>
> >> >> ?  If the macro is not always defined devise a new one defined from
> >> >> XCOFF_DEBUGGING_INFO.
> >> >
> >> >You prefer that I define a new macro in defaults.h instead of
> >> >
> >> >#ifndef XCOFF_DEBUGGING_INFO
> >> >#define XCOFF_DEBUGGING_INFO 0
> >> >#endif
> >> >
> >> >in dwarf2out.c?
> >>
> >> Or, if that works, add a default for XCOFF_DEBUGGING_INFO.
> >>
> >> I thought of a dwarf2out.c local define.
> >
> > I wouldn't worry about this too much, I have local patches turning the
> > X_DEBUGGING_INFO macros into 0/1 instead of undef / def, so which I
> > expect to commit in the next week or so.
> 
> XCOFF_DEBUGGING_INFO currently conditionally includes header files and
> conditionally compiles code that depends on macros only defined for
> AIX.  You addressed all of those dependencies?

no, the headers are still conditionally included, only now with #if
XCOFF_DEBUGGING_INFO instead of #ifdef.

Trev

> 
> Thanks, David
Richard Henderson Sept. 22, 2015, 3:29 p.m. UTC | #8
On 09/21/2015 08:41 AM, David Edelsohn wrote:
> +#ifndef XCOFF_DEBUGGING_INFO
>    if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
>      dw2_asm_output_data (4, 0xffffffff,
>        "Initial length escape value indicating 64-bit DWARF extension");
>    dw2_asm_output_data (DWARF_OFFSET_SIZE,
>                        next_die_offset - DWARF_INITIAL_LENGTH_SIZE,
>                        "Length of Compilation Unit Info");
> +#endif

This should have a comment akin to the note in the introduction to your
message.  Otherwise someone's going to look at this in a few years and scratch
their head.


> @@ -10398,11 +10411,13 @@ output_line_info (bool prologue_only)
>    ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, 0);
>    ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, 0);
> 
> +#ifndef XCOFF_DEBUGGING_INFO
>    if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
>      dw2_asm_output_data (4, 0xffffffff,
>        "Initial length escape value indicating 64-bit DWARF extension");
>    dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
>                         "Length of Source Line Info");
> +#endif

... or perhaps since we keep repeating the pattern, pull this out to a
subroutine like output_initial_size, or something.  We probably should have
done that before, when we added dwarf4 support.


> +#ifndef XCOFF_DEBUGGING_INFO
>    /* Output location list section if necessary.  */
>    if (have_location_lists)
>      {
> @@ -25494,6 +25510,7 @@ dwarf2out_finish (const char *filename)
>        ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
>        output_location_lists (comp_unit_die ());
>      }
> +#endif

I'd think you need to disable add_AT_loc_list instead.  Otherwise it would
appear as if we would still add the the location_description attribute to the
DIE, but then not fill in the referent.

Frankly I think there is going to be a *lot* that breaks, or is unusable,
without support for location lists.


> +#ifndef XCOFF_DEBUGGING_INFO
>    /* Have to end the macro section.  */
>    if (have_macinfo)
>      {
> @@ -25526,6 +25542,7 @@ dwarf2out_finish (const char *filename)
>        output_macinfo ();
>        dw2_asm_output_data (1, 0, "End compilation unit");
>      }
> +#endif

Similarly.

For this, the easy way to remove the macinfo is to force debug_info_level <
DINFO_LEVEL_VERBOSE, since the addition of the macinfo table is the only change
for -g3.


r~
David Edelsohn Sept. 22, 2015, 5:25 p.m. UTC | #9
On Tue, Sep 22, 2015 at 11:29 AM, Richard Henderson <rth@redhat.com> wrote:

>> @@ -10398,11 +10411,13 @@ output_line_info (bool prologue_only)
>>    ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, 0);
>>    ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, 0);
>>
>> +#ifndef XCOFF_DEBUGGING_INFO
>>    if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
>>      dw2_asm_output_data (4, 0xffffffff,
>>        "Initial length escape value indicating 64-bit DWARF extension");
>>    dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
>>                         "Length of Source Line Info");
>> +#endif
>
> ... or perhaps since we keep repeating the pattern, pull this out to a
> subroutine like output_initial_size, or something.  We probably should have
> done that before, when we added dwarf4 support.

I agree that encapsulating it would be nice, but not all of the DWARF
sections compute the length as a single value, e.g., the delta
computation using labels above.  If I change this, I need to direct
the dw2 output of different length computations into a string, or
duplicate the logic for the various forms of computation.  That starts
to make the cure worse than the disease.

>
>
>> +#ifndef XCOFF_DEBUGGING_INFO
>>    /* Output location list section if necessary.  */
>>    if (have_location_lists)
>>      {
>> @@ -25494,6 +25510,7 @@ dwarf2out_finish (const char *filename)
>>        ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
>>        output_location_lists (comp_unit_die ());
>>      }
>> +#endif
>
> I'd think you need to disable add_AT_loc_list instead.  Otherwise it would
> appear as if we would still add the the location_description attribute to the
> DIE, but then not fill in the referent.
>
> Frankly I think there is going to be a *lot* that breaks, or is unusable,
> without support for location lists.

Yep.  Shrug.  I'm just the messenger.

I'm re-working the parts of the patch based on your suggestion.

Thanks, David
diff mbox

Patch

Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 227959)
+++ dwarf2out.c (working copy)
@@ -3185,8 +3185,10 @@  static void calc_base_type_die_sizes (void);
 static void mark_dies (dw_die_ref);
 static void unmark_dies (dw_die_ref);
 static void unmark_all_dies (dw_die_ref);
+#ifndef XCOFF_DEBUGGING_INFO
 static unsigned long size_of_pubnames (vec<pubname_entry, va_gc> *);
 static unsigned long size_of_aranges (void);
+#endif
 static enum dwarf_form value_format (dw_attr_node *);
 static void output_value_format (dw_attr_node *);
 static void output_abbrev_section (void);
@@ -3202,7 +3204,7 @@  static void add_enumerator_pubname (const char *,
 static void add_pubname_string (const char *, dw_die_ref);
 static void add_pubtype (tree, dw_die_ref);
 static void output_pubnames (vec<pubname_entry, va_gc> *);
-static void output_aranges (unsigned long);
+static void output_aranges (void);
 static unsigned int add_ranges_num (int);
 static unsigned int add_ranges (const_tree);
 static void add_ranges_by_labels (dw_die_ref, const char *, const char *,
@@ -8387,6 +8389,7 @@  include_pubname_in_output (vec<pubname_entry, va_g
           || !flag_eliminate_unused_debug_types);
 }

+#ifndef XCOFF_DEBUGGING_INFO
 /* Return the size of the .debug_pubnames or .debug_pubtypes table
    generated for the compilation unit.  */

@@ -8441,6 +8444,7 @@  size_of_aranges (void)
   size += 2 * DWARF2_ADDR_SIZE;
   return size;
 }
+#endif
 ^L
 /* Select the encoding of an attribute value.  */

@@ -9198,12 +9202,14 @@  output_compilation_unit_header (void)
      DWARFv5 draft DIE tags in DWARFv4 format.  */
   int ver = dwarf_version < 5 ? dwarf_version : 4;

+#ifndef XCOFF_DEBUGGING_INFO
   if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
     dw2_asm_output_data (4, 0xffffffff,
       "Initial length escape value indicating 64-bit DWARF extension");
   dw2_asm_output_data (DWARF_OFFSET_SIZE,
                       next_die_offset - DWARF_INITIAL_LENGTH_SIZE,
                       "Length of Compilation Unit Info");
+#endif
   dw2_asm_output_data (2, ver, "DWARF version number");
   dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label,
                         debug_abbrev_section,
@@ -9630,13 +9636,16 @@  static void
 output_pubnames (vec<pubname_entry, va_gc> *names)
 {
   unsigned i;
-  unsigned long pubnames_length = size_of_pubnames (names);
   pubname_entry *pub;

+#ifndef XCOFF_DEBUGGING_INFO
+  unsigned long pubnames_length = size_of_pubnames (names);
+
   if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
     dw2_asm_output_data (4, 0xffffffff,
       "Initial length escape value indicating 64-bit DWARF extension");
   dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length, "Pub Info Length");
+#endif

   /* Version number for pubnames/pubtypes is independent of dwarf version.  */
   dw2_asm_output_data (2, 2, "DWARF Version");
@@ -9706,15 +9715,19 @@  output_pubtables (void)
    text section generated for this compilation unit.  */

 static void
-output_aranges (unsigned long aranges_length)
+output_aranges (void)
 {
   unsigned i;

-  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+#ifndef XCOFF_DEBUGGING_INFO
+  unsigned long aranges_length = size_of_aranges ();
+
+if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
     dw2_asm_output_data (4, 0xffffffff,
       "Initial length escape value indicating 64-bit DWARF extension");
   dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
                       "Length of Address Ranges Info");
+#endif
   /* Version number for aranges is still 2, even up to DWARF5.  */
   dw2_asm_output_data (2, 2, "DWARF Version");
   if (dwarf_split_debug_info)
@@ -10398,11 +10411,13 @@  output_line_info (bool prologue_only)
   ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, 0);

+#ifndef XCOFF_DEBUGGING_INFO
   if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
     dw2_asm_output_data (4, 0xffffffff,
       "Initial length escape value indicating 64-bit DWARF extension");
   dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
                        "Length of Source Line Info");
+#endif
   ASM_OUTPUT_LABEL (asm_out_file, l1);

   dw2_asm_output_data (2, ver, "DWARF Version");
@@ -25486,6 +25501,7 @@  dwarf2out_finish (const char *filename)
       output_abbrev_section ();
     }

+#ifndef XCOFF_DEBUGGING_INFO
   /* Output location list section if necessary.  */
   if (have_location_lists)
     {
@@ -25494,6 +25510,7 @@  dwarf2out_finish (const char *filename)
       ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
       output_location_lists (comp_unit_die ());
     }
+#endif

   output_pubtables ();

@@ -25504,10 +25521,8 @@  dwarf2out_finish (const char *filename)
      generate a table that would have contained data.  */
   if (info_section_emitted)
     {
-      unsigned long aranges_length = size_of_aranges ();
-
       switch_to_section (debug_aranges_section);
-      output_aranges (aranges_length);
+      output_aranges ();
     }

   /* Output ranges section if necessary.  */
@@ -25518,6 +25533,7 @@  dwarf2out_finish (const char *filename)
       output_ranges ();
     }

+#ifndef XCOFF_DEBUGGING_INFO
   /* Have to end the macro section.  */
   if (have_macinfo)
     {
@@ -25526,6 +25542,7 @@  dwarf2out_finish (const char *filename)
       output_macinfo ();
       dw2_asm_output_data (1, 0, "End compilation unit");
     }
+#endif

   /* Output the source line correspondence table.  We must do this
      even if there is no line information.  Otherwise, on an empty
Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c      (revision 227937)
+++ config/rs6000/rs6000.c      (working copy)
@@ -30684,6 +30684,12 @@ 
 #endif

 #if TARGET_XCOFF
+static enum unwind_info_type
+rs6000_xcoff_debug_unwind_info (void)
+{
+  return UI_NONE;
+}
+
 static void
 rs6000_xcoff_asm_output_anchor (rtx symbol)
 {
@@ -30805,6 +30811,11 @@ 
   int smclass;
   static const char * const suffix[4] = { "PR", "RO", "RW", "TL" };

+  if (flags & SECTION_DEBUG)
+    {
+      fprintf (asm_out_file, "\t.dwsect %s\n", name);
+      return;
+    }
   if (flags & SECTION_CODE)
     smclass = 0;
   else if (flags & SECTION_TLS)
@@ -31140,8 +31151,16 @@ 
   fputs (":\n", file);
   data.function_descriptor = true;
   symtab_node::get (decl)->call_for_symbol_and_aliases (rs6000_declare_alias, &
data, true);
-  if (write_symbols != NO_DEBUG && !DECL_IGNORED_P (decl))
-    xcoffout_declare_function (file, decl, buffer);
+  if (!DECL_IGNORED_P (decl))
+    {
+      if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
+       xcoffout_declare_function (file, decl, buffer);
+      else if (write_symbols == DWARF2_DEBUG)
+       {
+         name = (*targetm.strip_name_encoding) (name);
+         fprintf (file, "\t.function .%s,.%s,2,0\n", name, name);
+       }
+    }
   return;
 }

Index: config/rs6000/xcoff.h
===================================================================
--- config/rs6000/xcoff.h       (revision 227937)
+++ config/rs6000/xcoff.h       (working copy)
@@ -86,6 +86,8 @@ 
               || (SCALAR_FLOAT_MODE_P (GET_MODE (X))                   \
                   && ! TARGET_NO_FP_IN_TOC)))))

+#undef TARGET_DEBUG_UNWIND_INFO
+#define TARGET_DEBUG_UNWIND_INFO  rs6000_xcoff_debug_unwind_info
 #define TARGET_ASM_OUTPUT_ANCHOR  rs6000_xcoff_asm_output_anchor
 #define TARGET_ASM_GLOBALIZE_LABEL  rs6000_xcoff_asm_globalize_label
 #define TARGET_ASM_INIT_SECTIONS  rs6000_xcoff_asm_init_sections