diff mbox

DWARF support for AIX v2

Message ID CAGWvnymETR3HFjP2DQtjnHDjm-uy8fvTgV37Vqv1nmE5yiDD0A@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn Sept. 20, 2015, 9:39 p.m. UTC
The cause of the DWARF section length compatibility problem is the AIX
assembler implicitly prepends the section length to the beginning of
the appropriate DWARF sections and does not expect the compiler to
provide it.  How helpful!  Ugh.  This means that GCC should not emit
the section length on AIX, which makes dwarf2out.c a little more ugly.
But, hey, this eventually will allow GCC to get rid of Stabs, which
seems like a good trade off.

To localize the changes a little, I moved the single computation of
aranges_length into output_aranges.

If people prefer a different macro test, let me know.
XCOFF_DEBUGGING_INFO because the issue is DWARF embedded in XCOFF file
format?  I don't know if we want XCOFF_DEBUGGING_INFO to mean any
debugging format embedded in XCOFF or AIX Stabs specifically.

Second version of patch below.

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.
        * 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"
diff mbox

Patch

Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 227937)
+++ 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 TARGET_AIX_VERSION
 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);
        (DEBUG_PUBNAMES_SECTION): Define.
        (DEBUG_PUBTYPES_SECTION): Define.
        (DEBUG_STR_SECTION): Define.
        (DEBUG_RANGES_SECTION): Define.

Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 227937)
+++ 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 TARGET_AIX_VERSION
 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);
 /* 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 TARGET_AIX_VERSION
   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 TARGET_AIX_VERSION
+  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 TARGET_AIX_VERSION
+  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 TARGET_AIX_VERSION
   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 TARGET_AIX_VERSION
   /* 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.  */
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