From patchwork Sun Sep 20 14:25:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edelsohn X-Patchwork-Id: 519990 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 D3591140081 for ; Mon, 21 Sep 2015 00:25:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=u9XQvKi+; 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=Q9l1u9HKSgITz2mIdZZHTWNWVsYgPiRcvaKS9CUM7h0DjI Tbykwx5dsAV668XLkCIU24u4BfpKgedpzftZzkKM9T/oFwKj1lZvA+ReU2j27vjx 2YD4iVpdVjh80lCOxww+n4hcZ+/SGxctENizynQc1boTSsoE843awemVEt/Vs= 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=gfICcvYEM9PNJtmjMqKu5Y10lcE=; b=u9XQvKi+2a2wZNVJAXi/ tgXP7QqZ//ru/zeE2/XGs15cSSx7s3tEJfmdnUk81G7Rp8lFTRQyqA0GsmBESE5R kYsBchx7sx8dDhIlhkg1d69QrgdSKyZ//BmFzONyG1Rkrq68ALWhJs3KRs5vNUzR sUTujh1TpVmIc9yzM2SNhss= Received: (qmail 107970 invoked by alias); 20 Sep 2015 14:25:19 -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 107960 invoked by uid 89); 20 Sep 2015 14:25:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ig0-f172.google.com Received: from mail-ig0-f172.google.com (HELO mail-ig0-f172.google.com) (209.85.213.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 20 Sep 2015 14:25:17 +0000 Received: by igxx6 with SMTP id x6so43865449igx.1 for ; Sun, 20 Sep 2015 07:25:14 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.111.137 with SMTP id ii9mr7249997igb.91.1442759114015; Sun, 20 Sep 2015 07:25:14 -0700 (PDT) Received: by 10.36.133.5 with HTTP; Sun, 20 Sep 2015 07:25:13 -0700 (PDT) Date: Sun, 20 Sep 2015 10:25:13 -0400 Message-ID: Subject: [RFC,PATCH] DWARF support for AIX From: David Edelsohn To: GCC Patches Appended is an initial implementation of DWARF support for AIX. The patch emits the correct sections and works with the existing DWARF support for AIX XCOFF in GDB ... somewhat. First, AIX only supports a subset of DWARF sections. AIX does not support DWARF debug frame sections, although DWARF unwind frame sections are produced and consumed internally by GCC. I initially tried bracketing dwarf2out.c:output_call_frame_info() with #ifdef, but then changed to setting targetm.debug_unwind_info() to UI_NONE. This change prevents the debug frame info, but the debug location section newly appeared, which AIX also does not support. So I must bracket output_location_lists with #ifdef AIX. Setting and checking for something like a NULL section name specifically for AIX seems more complicated and cumbersome. Second, recent releases of XLC support DWARF debug info. GDB understands the DWARF information from XLC. GDB xcoffread.c performs the mostly normal if (dwarf2_has_info (objfile, &dwarf2_xcoff_names)) dwarf2_build_psymtabs (objfile); dwarf2_build_frame_info (objfile); so I do not see anything unusual in what it expects to parse. HOWEVER, XLC DWARF sections begin with the DWARF version number, not the length, e.g., .dwsect 0x00020000 # section name .dwline .dwline: # 0x00000400 # section address # .long 0x00000049 # section length .short 0x0002 # dwarf version .dwsect 0x00010000 # section name .dwinfo .dwinfo: # 0x00000500 # section address # .long 0x0000013e # section length .short 0x0002 # dwarf version And that is exactly the way the XLC disassembly appears, comments and everything. The section length is commented out. If I manually comment out the section length information in the GCC DWARF debugging information, trivial tests of GDB on AIX function correctly, e.g., it shows the correct file, function and line numbers. GDB accepts and understands XLC DWARF debug information WITHOUT section length but does not understand GCC DWARF debug information WITH section length. DWARF for other ELF targets includes the section length and does appear to hinder GDB. How can I adjust the DWARF produced by GCC or the DWARF consumed by GDB to address the section length information? Thanks, David * dwarf2out.c (dwarf2out_finish): Don't output location lists on AIX. * 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) @@ -25486,6 +25486,7 @@ output_abbrev_section (); } +#ifndef TARGET_AIX_VERSION /* Output location list section if necessary. */ if (have_location_lists) { @@ -25494,6 +25495,7 @@ ASM_OUTPUT_LABEL (asm_out_file, loc_section_label); output_location_lists (comp_unit_die ()); } +#endif output_pubtables (); 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