From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id C4XkAM7ykl8uZAAAWB0awg (envelope-from ) for ; Fri, 23 Oct 2020 11:12:14 -0400 Received: by simark.ca (Postfix, from userid 112) id EAF491EE09; Fri, 23 Oct 2020 11:12:13 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5DD361E552 for ; Fri, 23 Oct 2020 11:12:13 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E3D04398B17F; Fri, 23 Oct 2020 15:12:12 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 14F55398B166 for ; Fri, 23 Oct 2020 15:12:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 14F55398B166 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 52B251E552; Fri, 23 Oct 2020 11:12:10 -0400 (EDT) Subject: Re: [PATCH][gdb/testsuite] Don't use default form in Dwarf::_guess_form To: Tom de Vries , gdb-patches@sourceware.org References: <20201023114652.GA26275@delia> From: Simon Marchi Message-ID: <5b248ed3-29f8-75de-3aef-1986df7976cc@simark.ca> Date: Fri, 23 Oct 2020 11:12:09 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201023114652.GA26275@delia> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 2020-10-23 7:46 a.m., Tom de Vries wrote: > Hi, > > The only possible form for a DW_AT_low_pc attribute is DW_FORM_addr. > > When specifying in dwarf assembly a low_pc attribute without explicit form: > ... > {low_pc {main_label - 4}} > ... > the resulting attribute uses DW_FORM_string, which is misinterpreted by gdb > when reading it as: > ... > cu->base_address = attr->as_address (); > ... > > Stop using DW_FORM_string as default form. Instead, use a default form based > on the attribute name, if possible and unambiguous. Otherwise, error out. > > F.i.: > - for DW_AT_low_pc we use DW_FORM_addr. > - For DW_AT_high_pc, we don't specify a default form because it could be > either address or constant class. > - For DW_AT_name, we use DW_FORM_string. While we could encode with > DW_FORM_strp instead, DW_FORM_string is always ok. > > Tested on x86_64-linux. > > Any comments? > > Thanks, > - Tom I like it, I like specifying explicit forms in any case. I think it makes the "If the value looks like an integer, a form is required." redundant though. You could remove it, in which case specifying an integer attribute without a form would fall in the "No form for..." error branch. Simon