From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61062 invoked by alias); 21 Oct 2019 05:55:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 60787 invoked by uid 89); 21 Oct 2019 05:55:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_1,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=Ali, underflows, H*r:8.14.7, dwarf2_cu X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Oct 2019 05:55:24 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id x9L5tGS3026769 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Oct 2019 01:55:21 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca x9L5tGS3026769 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1571637321; bh=DmpjOJ8nWHiTED+dZ4GKfrcVYjdTrAdRuPTjHiDbYz8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=NDmGzUXPWzMIZJZ6UdXdJgkG/8A12HecTabI+6xk3i/DtrD0jO7gNRdnuug9DWuxV jVW4rl+glJAmsPx9nNs4Zd3HS0LPbDr+qcuUaaKRHxS7UscjI3dZfbRXfj63abomup csPY97LvRYkWR47WRB/Yxa8n53e+BWuG/wkIq9Z8= Received: from [10.0.0.11] (unknown [192.222.164.54]) (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 BEE901E592; Mon, 21 Oct 2019 01:55:15 -0400 (EDT) Subject: Re: [PATCH] DWARF 5 support: Handle line table and file indexes To: Ali Tamur Cc: gdb-patches@sourceware.org References: <99f8963b76221d747d0564919217a2eb@polymtl.ca> <20191018193116.57020-1-tamur@google.com> From: Simon Marchi Message-ID: <0570f296-a2ca-c250-7e95-060014d76a97@polymtl.ca> Date: Mon, 21 Oct 2019 05:55:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191018193116.57020-1-tamur@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00712.txt.bz2 On 2019-10-18 3:31 p.m., Ali Tamur wrote: > I've done everything asked, except this bit: >> I'd still suggest adding a gdb_assert to verify that in the case of > DWARF <= 4, index should be > 0. > > This caused failure in multiple tests, I think the correct behaviour is to > return nullptr when DWARF <= 4 and index = 0 (done). Oh, right, requesting the entry 0 isn't invalid, it's just that it represents the compilation directory, which is not explicitly represented. We indeed return NULL at the moment when requesting index 0 (it underflows the unsigned variable), so you are right that we should continue doing that. > @@ -20651,12 +20689,11 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu) > Returns NULL if FILE_INDEX should be ignored, i.e., it is pst->filename. */ > > static const char * > -psymtab_include_file_name (const struct line_header *lh, int file_index, > +psymtab_include_file_name (const struct line_header *lh, const file_entry &fe, > const struct partial_symtab *pst, > const char *comp_dir, > gdb::unique_xmalloc_ptr *name_holder) The comment above this function says: Return the file name of the psymtab for included file FILE_INDEX It would need to be updated. > @@ -24190,6 +24221,14 @@ dwarf_alloc_die (struct dwarf2_cu *cu, int num_attrs) > > /* Macro support. */ > > +static bool > +is_valid_file_index (int file_index, struct line_header *lh) > +{ > + if (lh->version >= 5) > + return 0 <= file_index && file_index < lh->file_names_size (); > + return 1 <= file_index && file_index <= lh->file_names_size (); > +} I think it would make sense if this was a method of line_header, since it's related to the line_header::file_name_at method. Simon