From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 3F7783857812 for ; Tue, 2 Mar 2021 09:06:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3F7783857812 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-lhb0A_NhOL-EHqUbBxwllQ-1; Tue, 02 Mar 2021 04:06:34 -0500 X-MC-Unique: lhb0A_NhOL-EHqUbBxwllQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA94884E244; Tue, 2 Mar 2021 09:06:32 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-197.ams2.redhat.com [10.36.112.197]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AB5262665; Tue, 2 Mar 2021 09:06:32 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 12296TTO2460035 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 2 Mar 2021 10:06:29 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 12296SQG2460034; Tue, 2 Mar 2021 10:06:28 +0100 Date: Tue, 2 Mar 2021 10:06:28 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Cary Coutant Subject: [PATCH] dwarf2out: Fix up split-dwarf .debug_macro handling [PR99319] Message-ID: <20210302090628.GA4020736@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2021 09:06:38 -0000 Hi! The -gsplit-dwarf changes came a few months after .debug_macro and the r0-120109 changes just changed the 2nd operand of DW_MACRO_GNU_{define,undef}_indirect from the usual .debug_str section offset argument to leb128 index into .debug_str_offsets without changing the opcodes. DWARF5 standardized different opcodes for those, but GCC hasn't been changed yet for that. This patch starts using DW_MACRO_define_strx and DW_MACRO_undef_strx instead of DW_MACRO_define_strp and DW_MACRO_undef_strp when -gsplit-dwarf -gdwarf-5 -g3. I'm not sure what to do if anything with the -gdwarf-4 -gsplit-dwarf -g3 -gno-strict-dwarf case, we've been emitting it that way for 8 years and it is an extension, so presumably the consumers that cared have already hacks to handle DW_MACRO_GNU_{define,undef}_indirect differently in .debug_macro 4 sections depending on if it is .debug_macro.dwo or .debug_macro. Another change the patch does is that it will use DW_MACRO_{define,undef}_str{p,x} even with -gdwarf-5 -gstrict-dwarf -g3, for DWARF 4 we were doing that only for -gno-strict-dwarf as we've emitted .debug_macro section only in that case. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2021-03-02 Jakub Jelinek PR debug/99319 * dwarf2out.c (output_macinfo_op): Use DW_MACRO_*_str* even with -gdwarf-5 -gstrict-dwarf. For -gsplit-dwarf -gdwarf-5 use DW_MACRO_*_strx instead of DW_MACRO_*_strp. Handle DW_MACRO_define_strx and DW_MACRO_undef_strx. (save_macinfo_strings): Use DW_MACRO_*_str* even with -gdwarf-5 -gstrict-dwarf. Handle DW_MACRO_define_strx and DW_MACRO_undef_strx. --- gcc/dwarf2out.c.jj 2021-02-27 10:40:22.759330948 +0100 +++ gcc/dwarf2out.c 2021-03-01 16:14:55.150163790 +0100 @@ -28267,13 +28267,17 @@ output_macinfo_op (macinfo_entry *ref) case DW_MACINFO_define: case DW_MACINFO_undef: len = strlen (ref->info) + 1; - if (!dwarf_strict + if ((!dwarf_strict || dwarf_version >= 5) && len > (size_t) dwarf_offset_size && !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET && (debug_str_section->common.flags & SECTION_MERGE) != 0) { - ref->code = ref->code == DW_MACINFO_define - ? DW_MACRO_define_strp : DW_MACRO_undef_strp; + if (dwarf_split_debug_info && dwarf_version >= 5) + ref->code = ref->code == DW_MACINFO_define + ? DW_MACRO_define_strx : DW_MACRO_undef_strx; + else + ref->code = ref->code == DW_MACINFO_define + ? DW_MACRO_define_strp : DW_MACRO_undef_strp; output_macinfo_op (ref); return; } @@ -28285,7 +28289,18 @@ output_macinfo_op (macinfo_entry *ref) dw2_asm_output_nstring (ref->info, -1, "The macro"); break; case DW_MACRO_define_strp: + dw2_asm_output_data (1, ref->code, "Define macro strp"); + goto do_DW_MACRO_define_strpx; case DW_MACRO_undef_strp: + dw2_asm_output_data (1, ref->code, "Undefine macro strp"); + goto do_DW_MACRO_define_strpx; + case DW_MACRO_define_strx: + dw2_asm_output_data (1, ref->code, "Define macro strx"); + goto do_DW_MACRO_define_strpx; + case DW_MACRO_undef_strx: + dw2_asm_output_data (1, ref->code, "Undefine macro strx"); + /* FALLTHRU */ + do_DW_MACRO_define_strpx: /* NB: dwarf2out_finish performs: 1. save_macinfo_strings 2. hash table traverse of index_string @@ -28302,10 +28317,6 @@ output_macinfo_op (macinfo_entry *ref) gcc_assert (node && (node->form == DW_FORM_strp || node->form == dwarf_FORM (DW_FORM_strx))); - dw2_asm_output_data (1, ref->code, - ref->code == DW_MACRO_define_strp - ? "Define macro strp" - : "Undefine macro strp"); dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu", (unsigned long) ref->lineno); if (node->form == DW_FORM_strp) @@ -28475,7 +28486,7 @@ save_macinfo_strings (void) case DW_MACINFO_define: case DW_MACINFO_undef: len = strlen (ref->info) + 1; - if (!dwarf_strict + if ((!dwarf_strict || dwarf_version >= 5) && len > (unsigned) dwarf_offset_size && !DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET && (debug_str_section->common.flags & SECTION_MERGE) != 0) @@ -28489,6 +28500,8 @@ save_macinfo_strings (void) /* Fall through. */ case DW_MACRO_define_strp: case DW_MACRO_undef_strp: + case DW_MACRO_define_strx: + case DW_MACRO_undef_strx: set_indirect_string (find_AT_string (ref->info)); break; default: Jakub