From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 9CE013887006 for ; Wed, 3 Jun 2020 21:51:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9CE013887006 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0540AAD75; Wed, 3 Jun 2020 21:51:39 +0000 (UTC) Subject: Re: [PATCH][gdb/symtab] Fix missing breakpoint location for inlined function From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey References: <20200527103716.GA26761@delia> Autocrypt: addr=tdevries@suse.de; keydata= xsBNBF0ltCcBCADDhsUnMMdEXiHFfqJdXeRvgqSEUxLCy/pHek88ALuFnPTICTwkf4g7uSR7 HvOFUoUyu8oP5mNb4VZHy3Xy8KRZGaQuaOHNhZAT1xaVo6kxjswUi3vYgGJhFMiLuIHdApoc u5f7UbV+egYVxmkvVLSqsVD4pUgHeSoAcIlm3blZ1sDKviJCwaHxDQkVmSsGXImaAU+ViJ5l CwkvyiiIifWD2SoOuFexZyZ7RUddLosgsO0npVUYbl6dEMq2a5ijGF6/rBs1m3nAoIgpXk6P TCKlSWVW6OCneTaKM5C387972qREtiArTakRQIpvDJuiR2soGfdeJ6igGA1FZjU+IsM5ABEB AAHNH1RvbSBkZSBWcmllcyA8dGRldnJpZXNAc3VzZS5kZT7CwKsEEwEIAD4WIQSsnSe5hKbL MK1mGmjuhV2rbOJEoAUCXSW0JwIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAh CRDuhV2rbOJEoBYhBKydJ7mEpsswrWYaaO6FXats4kSgc48H/Ra2lq5p3dHsrlQLqM7N68Fo eRDf3PM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A6bEGwM22dP8OUY6SC94x1G81A9/xbtm9LQxKm0EiDH8KBMLfQ== Message-ID: <1a7e6af5-7d2f-01ef-efe9-6382903cf841@suse.de> Date: Wed, 3 Jun 2020 23:51:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200527103716.GA26761@delia> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-16.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 03 Jun 2020 21:51:39 -0000 On 27-05-2020 12:37, Tom de Vries wrote: > Hi, > > Consider the test-case contained in this patch. > > With -readnow, we have two breakpoint locations: > ... > $ gdb -readnow -batch breakpoint-locs -ex "b N1::C1::baz" -ex "info break" > Breakpoint 1 at 0x4004cb: N1::C1::baz. (2 locations) > Num Type Disp Enb Address What > 1 breakpoint keep y > 1.1 y 0x00000000004004cb in N1::C1::baz() \ > at breakpoint-locs.h:6 > 1.2 y 0x00000000004004f0 in N1::C1::baz() \ > at breakpoint-locs.h:6 > ... > > But without -readnow, we have instead only one breakpoint location: > ... > $ gdb -batch breakpoint-locs -ex "b N1::C1::baz" -ex "info break" > Breakpoint 1 at 0x4004f0: file breakpoint-locs.h, line 6. > Num Type Disp Enb Address What > 1 breakpoint keep y 0x00000000004004f0 in N1::C1::baz() \ > at breakpoint-locs.h:6 > ... > > The relevant dwarf is this bit: > ... > <0>: Abbrev Number: 1 (DW_TAG_compile_unit) > DW_AT_name : breakpoint-locs.cc > <1>: Abbrev Number: 2 (DW_TAG_namespace) > DW_AT_name : N1 > <2>: Abbrev Number: 3 (DW_TAG_class_type) > DW_AT_name : C1 > <3><109>: Abbrev Number: 4 (DW_TAG_subprogram) > <10a> DW_AT_name : baz > <110> DW_AT_linkage_name: _ZN2N12C13bazEv > <2><116>: Abbrev Number: 5 (DW_TAG_subprogram) > <117> DW_AT_name : foo > <11d> DW_AT_linkage_name: _ZN2N13fooEv > <1><146>: Abbrev Number: 8 (DW_TAG_subprogram) > <147> DW_AT_specification: <0x116> > <14b> DW_AT_low_pc : 0x4004c7 > <153> DW_AT_high_pc : 0x10 > <2><161>: Abbrev Number: 9 (DW_TAG_inlined_subroutine) > <162> DW_AT_abstract_origin: <0x194> > <166> DW_AT_low_pc : 0x4004cb > <16e> DW_AT_high_pc : 0x9 > <1><194>: Abbrev Number: 12 (DW_TAG_subprogram) > <195> DW_AT_specification: <0x109> > <199> DW_AT_inline : 3 (declared as inline and inlined) > ... > > The missing breakpoint location is specified by DIE 0x161, which is ignored by > the partial DIE reader because it's a child of a DW_TAG_subprogram DIE (at > 0x146, for foo). > > Fix this by not ignoring the DIE during partial DIE reading. > > Tested on x86_64-linux. > > Any comments? > I've pushed this patch (after adding missing copyright notices). Thanks, - Tom > [gdb/symtab] Fix missing breakpoint location for inlined function > > gdb/ChangeLog: > > 2020-05-27 Tom de Vries > > PR symtab/26046 > * dwarf2/read.c (scan_partial_symbols): Recurse into DW_TAG_subprogram > children for C++. > (load_partial_dies): Don't skip DW_TAG_inlined_subroutine child of > DW_TAG_subprogram. > > gdb/testsuite/ChangeLog: > > 2020-05-27 Tom de Vries > > PR symtab/26046 > * gdb.cp/breakpoint-locs-2.cc: New test. > * gdb.cp/breakpoint-locs.cc: New test. > * gdb.cp/breakpoint-locs.exp: New file. > * gdb.cp/breakpoint-locs.h: New test. > > --- > gdb/dwarf2/read.c | 6 +++++- > gdb/testsuite/gdb.cp/breakpoint-locs-2.cc | 12 ++++++++++++ > gdb/testsuite/gdb.cp/breakpoint-locs.cc | 16 ++++++++++++++++ > gdb/testsuite/gdb.cp/breakpoint-locs.exp | 27 +++++++++++++++++++++++++++ > gdb/testsuite/gdb.cp/breakpoint-locs.h | 8 ++++++++ > 5 files changed, 68 insertions(+), 1 deletion(-) > > diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c > index ec3844188e..7ab521a656 100644 > --- a/gdb/dwarf2/read.c > +++ b/gdb/dwarf2/read.c > @@ -8054,6 +8054,9 @@ scan_partial_symbols (struct partial_die_info *first_die, CORE_ADDR *lowpc, > case DW_TAG_subprogram: > case DW_TAG_inlined_subroutine: > add_partial_subprogram (pdi, lowpc, highpc, set_addrmap, cu); > + if (cu->language == language_cplus) > + scan_partial_symbols (pdi->die_child, lowpc, highpc, > + set_addrmap, cu); > break; > case DW_TAG_constant: > case DW_TAG_variable: > @@ -18125,7 +18128,8 @@ load_partial_dies (const struct die_reader_specs *reader, > if (!load_all > && cu->language == language_cplus > && parent_die != NULL > - && parent_die->tag == DW_TAG_subprogram) > + && parent_die->tag == DW_TAG_subprogram > + && abbrev->tag != DW_TAG_inlined_subroutine) > { > info_ptr = skip_one_die (reader, info_ptr + bytes_read, abbrev); > continue; > diff --git a/gdb/testsuite/gdb.cp/breakpoint-locs-2.cc b/gdb/testsuite/gdb.cp/breakpoint-locs-2.cc > new file mode 100644 > index 0000000000..0bce5caa93 > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/breakpoint-locs-2.cc > @@ -0,0 +1,12 @@ > +#include "breakpoint-locs.h" > + > +namespace N1 > +{ > + void bar () { C1::baz (); } > +} > + > +void > +N1_bar (void) > +{ > + N1::bar (); > +} > diff --git a/gdb/testsuite/gdb.cp/breakpoint-locs.cc b/gdb/testsuite/gdb.cp/breakpoint-locs.cc > new file mode 100644 > index 0000000000..e73e721335 > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/breakpoint-locs.cc > @@ -0,0 +1,16 @@ > +#include "breakpoint-locs.h" > + > +namespace N1 > +{ > + void foo () { C1::baz (); } > +} > + > +extern void N1_bar (void); > + > +int > +main () > +{ > + N1::foo (); > + N1_bar (); > + return 0; > +} > diff --git a/gdb/testsuite/gdb.cp/breakpoint-locs.exp b/gdb/testsuite/gdb.cp/breakpoint-locs.exp > new file mode 100644 > index 0000000000..46b64e9de6 > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/breakpoint-locs.exp > @@ -0,0 +1,27 @@ > +# Copyright 2020 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 . > + > +# This file is part of the gdb testsuite > + > +if {[skip_cplus_tests]} { continue } > + > +standard_testfile .cc breakpoint-locs-2.cc > + > +if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2"\ > + {debug c++}] } { > + return -1 > +} > + > +gdb_test "break N1::C1::baz" "\\(2 locations\\)" > diff --git a/gdb/testsuite/gdb.cp/breakpoint-locs.h b/gdb/testsuite/gdb.cp/breakpoint-locs.h > new file mode 100644 > index 0000000000..52c2b8d84e > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/breakpoint-locs.h > @@ -0,0 +1,8 @@ > +namespace N1 > +{ > + class C1 > + { > + public: > + static void __attribute__((always_inline)) baz () { volatile unsigned i; i++; } > + }; > +} >