From patchwork Thu Nov 24 15:07:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 698886 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 3tPjHd4JxCz9sCZ for ; Fri, 25 Nov 2016 02:07:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TUPJPk/h"; 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=RRAot1pbryjkf5ZlV LLTA43KaAe1Cy4KYInBkUkABXuQqChGhvNv5EtmdEUYo2vde1Heupjadi5h1l944 iKziWlORvA4DsSdY2ZV01ItV19ujq6KrFFnRkiTcjqD9eSrcBhYG/t5f/XeZDRu2 NPuyxyZMbj3Jl9U6kBdfhdFXtA= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=na8a7ElQEu40BBPHhD/WAfJ TPmw=; b=TUPJPk/h3MR9mujvHHMdfDhCbLQDvtrjl31XAfHWYUdINQlZFIWqZW9 brnmKVB4f+u9Ns1CKST1yf4gpVkksJNjg9Z3FYO1mzjR1810ZoJt2By+Ou28UJOO Q6Xx8KRhuPd4PfW7L3bzuCwLZiE8kw9VQ5r0Sq2fUqp9vYwQktGA= Received: (qmail 12707 invoked by alias); 24 Nov 2016 15:07:30 -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 12670 invoked by uid 89); 24 Nov 2016 15:07:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=tabs, jkratoch, H*Ad:U*ccoutant, siz X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Nov 2016 15:07:28 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5C9D3A279; Thu, 24 Nov 2016 15:07:26 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-109.ams2.redhat.com [10.36.116.109]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAOF7Maw018076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Nov 2016 10:07:25 -0500 Date: Thu, 24 Nov 2016 16:07:22 +0100 From: Jan Kratochvil To: Jakub Jelinek Cc: Jason Merrill , Cary Coutant , gcc-patches@gcc.gnu.org Subject: [patch] DWARF5 .debug_line DW_LNCT_* reorder for readelf [Re: [PATCH] DWARF5 .debug_line{, _str} support] Message-ID: <20161124150722.GA26566@host1.jankratochvil.net> References: <20161019233039.GR7282@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161019233039.GR7282@tucnak.redhat.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes Hi, On Thu, 20 Oct 2016 01:30:39 +0200, Jakub Jelinek wrote: > This patch adds support for DWARF5 .debug_line{,_str} section format, > though only if !DWARF2_ASM_LINE_DEBUG_INFO, because otherwise > .debug_line is emitted by the assembler. with current GCC trunk (with the GCC patch above) binutils readelf DWARF-5 patch being prepared outputs: The File name Table (offset 0x30): Entry Name Dir 0 (indirect line string, offset: 0x0): /home/jkratoch/t/classic.C 0 1 (indirect line string, offset: 0x11): classic.C 1 Please see the tabs there. After this GCC patch below readelf would output: The File name Table (offset 0x30): Entry Dir Name 0 0 (indirect line string, offset: 0x0): /home/jkratoch/t/classic.C 1 1 (indirect line string, offset: 0x11): classic.C That 'indirect line string' may get removed, that is irrelevant for this mail. I could reorder that in readelf but I find it easier to do in GCC. Also binutils has not switched to C++ yet so I have found the reordering not trivial to do in readelf itself. The readelf patch being prepared - not yet submitted: https://people.redhat.com/jkratoch/readelf-dwarf5.patch OK for GCC trunk? Sorry I have not regression tested it, I would handle that before a check-in. Thanks, Jan gcc/ 2016-11-24 Jan Kratochvil * dwarf2out.c (output_file_names) Reorder DW_LNCT_directory_index and DW_LNCT_path. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 1dfff38..ff4318c 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -11592,8 +11592,7 @@ output_file_names (void) #else dw2_asm_output_data (1, 2, "File name entry format count"); #endif - dw2_asm_output_data_uleb128 (DW_LNCT_path, "DW_LNCT_path"); - dw2_asm_output_data_uleb128 (str_form, get_DW_FORM_name (str_form)); + /* Keep DW_LNCT_path last for better binutils readelf readability. */ dw2_asm_output_data_uleb128 (DW_LNCT_directory_index, "DW_LNCT_directory_index"); dw2_asm_output_data_uleb128 (idx_form, get_DW_FORM_name (idx_form)); @@ -11603,9 +11602,10 @@ output_file_names (void) dw2_asm_output_data_uleb128 (DW_LNCT_size, "DW_LNCT_size"); dw2_asm_output_data_uleb128 (DW_FORM_udata, "DW_FORM_udata"); #endif - dw2_asm_output_data_uleb128 (numfiles + 1, "File names count"); + dw2_asm_output_data_uleb128 (DW_LNCT_path, "DW_LNCT_path"); + dw2_asm_output_data_uleb128 (str_form, get_DW_FORM_name (str_form)); - output_line_string (str_form, filename0, "File Entry", 0); + dw2_asm_output_data_uleb128 (numfiles + 1, "File names count"); /* Include directory index. */ if (dwarf_version >= 5 && idx_form != DW_FORM_udata) @@ -11618,6 +11618,8 @@ output_file_names (void) dw2_asm_output_data_uleb128 (0, NULL); dw2_asm_output_data_uleb128 (0, NULL); #endif + + output_line_string (str_form, filename0, "File Entry", 0); } /* Now write all the file names. */ @@ -11644,7 +11646,8 @@ output_file_names (void) snprintf (filebuf, maxfilelen, "%s;%d", files[file_idx].path + dirs[dir_idx].length, ver); - output_line_string (str_form, filebuf, "File Entry", (unsigned) i + 1); + if (dwarf_version < 5) + output_line_string (str_form, filebuf, "File Entry", (unsigned) i + 1); /* Include directory index. */ if (dwarf_version >= 5 && idx_form != DW_FORM_udata) @@ -11662,10 +11665,14 @@ output_file_names (void) dw2_asm_output_data_uleb128 ((vms_file_stats_name (files[file_idx].path, 0, &siz, 0, 0) == 0) ? siz : 0, NULL); + + if (dwarf_version >= 5) + output_line_string (str_form, filebuf, "File Entry", (unsigned) i + 1); #else - output_line_string (str_form, - files[file_idx].path + dirs[dir_idx].length, - "File Entry", (unsigned) i + 1); + if (dwarf_version < 5) + output_line_string (str_form, + files[file_idx].path + dirs[dir_idx].length, + "File Entry", (unsigned) i + 1); /* Include directory index. */ if (dwarf_version >= 5 && idx_form != DW_FORM_udata) @@ -11675,13 +11682,17 @@ output_file_names (void) dw2_asm_output_data_uleb128 (dir_idx + idx_offset, NULL); if (dwarf_version >= 5) - continue; - - /* Modification time. */ - dw2_asm_output_data_uleb128 (0, NULL); + output_line_string (str_form, + files[file_idx].path + dirs[dir_idx].length, + "File Entry", (unsigned) i + 1); + else + { + /* Modification time. */ + dw2_asm_output_data_uleb128 (0, NULL); - /* File length in bytes. */ - dw2_asm_output_data_uleb128 (0, NULL); + /* File length in bytes. */ + dw2_asm_output_data_uleb128 (0, NULL); + } #endif /* VMS_DEBUGGING_INFO */ }