From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5762 invoked by alias); 29 Mar 2019 22:02:04 -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 5747 invoked by uid 89); 29 Mar 2019 22:02:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= 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; Fri, 29 Mar 2019 22:02:02 +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 x2TM1sue017643 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 29 Mar 2019 18:01:59 -0400 Received: by simark.ca (Postfix, from userid 112) id B11471E623; Fri, 29 Mar 2019 18:01:54 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id EAE401E4A2; Fri, 29 Mar 2019 18:01:52 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 29 Mar 2019 22:02:00 -0000 From: Simon Marchi To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Handle DW_AT_ranges when reading partial symtabs In-Reply-To: <20190329200030.8368-1-tromey@adacore.com> References: <20190329200030.8368-1-tromey@adacore.com> Message-ID: <42d48bb2f79941b8fd646c7089492907@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00753.txt.bz2 On 2019-03-29 16:00, Tom Tromey wrote: > add_partial_subprogram does not handle DW_AT_ranges, while the full > symtab reader does. This can lead to discrepancies where a function > is not put into a partial symtab, and so is not available to "break" > and the like -- but is available if the full symtab has somehow been > read. > > This patch fixes the bug by arranging to read DW_AT_ranges when > reading partial DIEs. > > This is PR symtab/23331. > > The new test case is derived from dw2-ranges-func.exp, which is why I > kept the copyright dates. > > gdb/ChangeLog > 2019-03-29 Tom Tromey > > PR symtab/23331: > * dwarf2read.c (partial_die_info::read): Handle DW_AT_ranges. > > gdb/testsuite/ChangeLog > 2019-03-29 Tom Tromey > > PR symtab/23331: > * gdb.dwarf2/dw2-ranges-main.c: New file. > * gdb.dwarf2/dw2-ranges-psym.c: New file. > * gdb.dwarf2/dw2-ranges-psym.exp: New file. I don't have much experience in this area, but I read the patch and it seems to make sense. I just have one tiny comment to help readability in the test. > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp > b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp > new file mode 100644 > index 00000000000..eb1130a2238 > --- /dev/null > +++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp > @@ -0,0 +1,134 @@ > +# Copyright 2018-2019 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 > . > + > +load_lib dwarf.exp > + > +# Test that psymbols are made when DW_AT_ranges is used. > + > +# This test can only be run on targets which support DWARF-2 and use > gas. > +if {![dwarf2_support]} { > + unsupported "dwarf2 support required for this test" > + return 0 > +} > + > +if [get_compiler_info] { > + return -1 > +} > +if !$gcc_compiled { > + unsupported "gcc required for this test" > + return 0 > +} > + > +standard_testfile dw2-ranges-main.c dw2-ranges-psym.c > dw2-ranges-psym-dw.S > + > +# We need to know the size of integer and address types in order to > +# write some of the debugging info we'd like to generate. > +# > +# For that, we ask GDB by debugging our test program. Any program > +# would do, but since we already have it specifically for this > +# testcase, might as well use that. > + > +if { [prepare_for_testing "failed to prepare" ${testfile} \ > + [list ${srcfile} ${srcfile2}]] } { > + return -1 > +} > + > +set asm_file [standard_output_file $srcfile3] > +Dwarf::assemble $asm_file { > + global srcdir subdir srcfile srcfile2 > + declare_labels integer_label volatile_label func_ranges_label > cu_ranges_label > + set int_size [get_sizeof "int" 4] > + > + # Find start address and length for our functions. > + set sources [list ${srcdir}/${subdir}/$srcfile > ${srcdir}/${subdir}/$srcfile2] > + lassign [function_range foo $sources] \ > + foo_start foo_len > + set foo_end "$foo_start + $foo_len" > + lassign [function_range foo_low $sources] \ > + foo_low_start foo_low_len > + set foo_low_end "$foo_low_start + $foo_low_len" > + lassign [function_range bar $sources] \ > + bar_start bar_len > + set bar_end "$bar_start + $bar_len" > + lassign [function_range baz $sources] \ > + baz_start baz_len > + set baz_end "$baz_start + $baz_len" To help readability, I'd suggest adding some empty lines in there, between each pair of lassign+set statements. At first it looked like a bit cryptic blob to me until I split it in smaller pieces. Simon