From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8Ks5HwVqJWMcMjsAWB0awg (envelope-from ) for ; Sat, 17 Sep 2022 02:32:37 -0400 Received: by simark.ca (Postfix, from userid 112) id 71EBD1E112; Sat, 17 Sep 2022 02:32:37 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=x6J6LKB4; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.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 BE4511E0D3 for ; Sat, 17 Sep 2022 02:32:36 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 669CA395C013 for ; Sat, 17 Sep 2022 06:32:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 669CA395C013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663396356; bh=kqz8HOfNR7K53pP/3Bj2IsLfAJ9zQ9HUU7xSEgrdTOA=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=x6J6LKB4qAUkBiFq+WX4OrYmrXdgOZ0ajbFEtmiv9FcJTwseY4ybRN4D8NcHXM3qj T3q2c9BM3pTcuait/H6hel72oIBIxu45BinoJNWjzlxRck2MjsFP7xes4wLq9ny/X7 Yj3484w++j+AFw3TZIKxVkHYjTRciOCawjj2QjJc= Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 293A9392AC10 for ; Sat, 17 Sep 2022 06:32:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 293A9392AC10 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 66BBE5C594; Sat, 17 Sep 2022 06:32:06 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 540F3139F9; Sat, 17 Sep 2022 06:32:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eGd+E+ZpJWNjAwAAMHmgww (envelope-from ); Sat, 17 Sep 2022 06:32:06 +0000 Message-ID: <86e30d24-4cbd-c617-23f6-17b2c0a23f9d@suse.de> Date: Sat, 17 Sep 2022 08:32:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH][gdb/symtab] Fix "file index out of range" complaint Content-Language: en-US To: gdb-patches@sourceware.org References: <20220909065059.GA19794@delia.home> In-Reply-To: <20220909065059.GA19794@delia.home> Content-Type: text/plain; charset=UTF-8; format=flowed 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: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Cc: Tom Tromey Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 9/9/22 08:51, Tom de Vries wrote: > Hi, > > With the test-case included in this commit, we run into this FAIL: > ... > (gdb) p var^M > During symbol reading: file index out of range^M > $1 = 0^M > (gdb) FAIL: gdb.dwarf2/dw2-no-code-cu.exp: p var with no complaints > ... > > This is a regression since commit 6d263fe46e0 ("Avoid bad breakpoints with > --gc-sections"), which contains this change in read_file_scope: > ... > - handle_DW_AT_stmt_list (die, cu, fnd, lowpc); > + if (lowpc != highpc) > + handle_DW_AT_stmt_list (die, cu, fnd, lowpc); > ... > > The change intends to avoid a problem with a check in > lnp_state_machine::check_line_address, but also prevents the file and dir > tables from being read, which causes the complaint. > > Fix the FAIL by reducing the scope of the "lowpc != highpc" condition to the > call to dwarf_decode_lines in handle_DW_AT_stmt_list. > > Tested on x86_64-linux. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29561 > > Any comments? > Committed. Thanks, - Tom > > [gdb/symtab] Fix "file index out of range" complaint > > --- > gdb/dwarf2/read.c | 20 +++++++++---------- > gdb/testsuite/gdb.dwarf2/dw2-no-code-cu.c | 18 +++++++++++++++++ > gdb/testsuite/gdb.dwarf2/dw2-no-code-cu.exp | 31 +++++++++++++++++++++++++++++ > 3 files changed, 59 insertions(+), 10 deletions(-) > > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > index 3ca441c4cae..e86cc83b6f1 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -9495,8 +9495,8 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu) > > static void > handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, > - const file_and_directory &fnd, > - CORE_ADDR lowpc) /* ARI: editCase function */ > + const file_and_directory &fnd, CORE_ADDR lowpc, > + bool have_code) /* ARI: editCase function */ > { > dwarf2_per_objfile *per_objfile = cu->per_objfile; > struct attribute *attr; > @@ -9583,7 +9583,12 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu, > gdb_assert (die->tag != DW_TAG_partial_unit); > } > decode_mapping = (die->tag != DW_TAG_partial_unit); > - dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping); > + /* The have_code check is here because, if LOWPC and HIGHPC are both 0x0, > + then there won't be any interesting code in the CU, but a check later on > + (in lnp_state_machine::check_line_address) will fail to properly exclude > + an entry that was removed via --gc-sections. */ > + if (have_code) > + dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping); > } > > /* Process DW_TAG_compile_unit or DW_TAG_partial_unit. */ > @@ -9622,13 +9627,8 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) > > /* Decode line number information if present. We do this before > processing child DIEs, so that the line header table is available > - for DW_AT_decl_file. The PC check is here because, if LOWPC and > - HIGHPC are both 0x0, then there won't be any interesting code in > - the CU, but a check later on (in > - lnp_state_machine::check_line_address) will fail to properly > - exclude an entry that was removed via --gc-sections. */ > - if (lowpc != highpc) > - handle_DW_AT_stmt_list (die, cu, fnd, lowpc); > + for DW_AT_decl_file. */ > + handle_DW_AT_stmt_list (die, cu, fnd, lowpc, lowpc != highpc); > > /* Process all dies in compilation unit. */ > if (die->child != NULL) > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-no-code-cu.c b/gdb/testsuite/gdb.dwarf2/dw2-no-code-cu.c > new file mode 100644 > index 00000000000..576b1a21442 > --- /dev/null > +++ b/gdb/testsuite/gdb.dwarf2/dw2-no-code-cu.c > @@ -0,0 +1,18 @@ > +/* This testcase is part of GDB, the GNU debugger. > + > + Copyright 2022 Free Software Foundation, Inc. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see . */ > + > +int var; > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-no-code-cu.exp b/gdb/testsuite/gdb.dwarf2/dw2-no-code-cu.exp > new file mode 100644 > index 00000000000..911bb7e2a7d > --- /dev/null > +++ b/gdb/testsuite/gdb.dwarf2/dw2-no-code-cu.exp > @@ -0,0 +1,31 @@ > +# Copyright 2022 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +standard_testfile .c main.c > + > +if [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2"] { > + return -1 > +} > + > +set cmd "p var" > + > +set re \ > + [multi_line \ > + "$cmd" \ > + "\\\$1 = 0"] > + > +with_complaints 5 { > + gdb_test $cmd $re "$cmd with no complaints" > +}