From patchwork Sun Sep 20 21:39:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edelsohn X-Patchwork-Id: 520059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0A77B14027C for ; Mon, 21 Sep 2015 07:39:13 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ygWb2fv7; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=TOPuKIK7cyInpiBPKUphg1AFO+I6MXsnSldWBw9vnfBYRB jOtOAYtY5iV6qLxrtuszRKPZTWFF+D/tuxAheunPwxqYkF5/pLlpM2HNeLY7CLaQ 4CGYa36/gst+WEyGA8kCdqAtb+eAC95J5bh/VuFrsSeh+DvhA/t43n32zB/w0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=iClTcmPCkWBppQnVlVY+uYpPguM=; b=ygWb2fv7FFGK4X43BIXY xzVF96sofURpwL18DZ3Sdwu1/CZRRLwQWDnqLTkIyhrihspzyBDGEj6cAOAZFGfL uXxZorp+5/gMhDTW3a+KaLn6Hrdr/7qJ9EVXf2LqV1idRr5+o+LjOzQBE5VlCI1I TY7vf2oV2Zb8PyZw3rtBxtk= Received: (qmail 119697 invoked by alias); 20 Sep 2015 21:39:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 119686 invoked by uid 89); 20 Sep 2015 21:39:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL, BAYES_95, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ig0-f171.google.com Received: from mail-ig0-f171.google.com (HELO mail-ig0-f171.google.com) (209.85.213.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 20 Sep 2015 21:39:05 +0000 Received: by igcrk20 with SMTP id rk20so49177403igc.1 for ; Sun, 20 Sep 2015 14:39:03 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.111.137 with SMTP id ii9mr8523453igb.91.1442785143014; Sun, 20 Sep 2015 14:39:03 -0700 (PDT) Received: by 10.36.133.5 with HTTP; Sun, 20 Sep 2015 14:39:02 -0700 (PDT) Date: Sun, 20 Sep 2015 17:39:02 -0400 Message-ID: Subject: [PATCH] DWARF support for AIX v2 From: David Edelsohn To: GCC Patches 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" 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 *); 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 *); 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 *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