mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-05 23:54:06 +08:00
[gdb/symtab] Fix missing breakpoint location for inlined function
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 <MULTIPLE> 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><d2>: Abbrev Number: 1 (DW_TAG_compile_unit) <d8> DW_AT_name : breakpoint-locs.cc <1><f4>: Abbrev Number: 2 (DW_TAG_namespace) <f5> DW_AT_name : N1 <2><fe>: Abbrev Number: 3 (DW_TAG_class_type) <ff> 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. gdb/ChangeLog: 2020-06-03 Tom de Vries <tdevries@suse.de> 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-06-03 Tom de Vries <tdevries@suse.de> 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.
This commit is contained in:
parent
338d56a848
commit
f9b5d5ea18
@ -1,3 +1,11 @@
|
||||
2020-06-03 Tom de Vries <tdevries@suse.de>
|
||||
|
||||
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.
|
||||
|
||||
2020-06-02 Andrew Burgess <andrew.burgess@embecosm.com>
|
||||
|
||||
* ada-lang.c (ada_language_data): Delete skip_trampoline
|
||||
|
@ -8146,6 +8146,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:
|
||||
@ -18246,7 +18249,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;
|
||||
|
@ -1,3 +1,11 @@
|
||||
2020-06-03 Tom de Vries <tdevries@suse.de>
|
||||
|
||||
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.
|
||||
|
||||
2020-06-03 Tom de Vries <tdevries@suse.de>
|
||||
|
||||
PR testsuite/25609
|
||||
|
29
gdb/testsuite/gdb.cp/breakpoint-locs-2.cc
Normal file
29
gdb/testsuite/gdb.cp/breakpoint-locs-2.cc
Normal file
@ -0,0 +1,29 @@
|
||||
/* This testcase is part of GDB, the GNU debugger.
|
||||
|
||||
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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "breakpoint-locs.h"
|
||||
|
||||
namespace N1
|
||||
{
|
||||
void bar () { C1::baz (); }
|
||||
}
|
||||
|
||||
void
|
||||
N1_bar (void)
|
||||
{
|
||||
N1::bar ();
|
||||
}
|
33
gdb/testsuite/gdb.cp/breakpoint-locs.cc
Normal file
33
gdb/testsuite/gdb.cp/breakpoint-locs.cc
Normal file
@ -0,0 +1,33 @@
|
||||
/* This testcase is part of GDB, the GNU debugger.
|
||||
|
||||
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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "breakpoint-locs.h"
|
||||
|
||||
namespace N1
|
||||
{
|
||||
void foo () { C1::baz (); }
|
||||
}
|
||||
|
||||
extern void N1_bar (void);
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
N1::foo ();
|
||||
N1_bar ();
|
||||
return 0;
|
||||
}
|
27
gdb/testsuite/gdb.cp/breakpoint-locs.exp
Normal file
27
gdb/testsuite/gdb.cp/breakpoint-locs.exp
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
# 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\\)"
|
25
gdb/testsuite/gdb.cp/breakpoint-locs.h
Normal file
25
gdb/testsuite/gdb.cp/breakpoint-locs.h
Normal file
@ -0,0 +1,25 @@
|
||||
/* This testcase is part of GDB, the GNU debugger.
|
||||
|
||||
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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
namespace N1
|
||||
{
|
||||
class C1
|
||||
{
|
||||
public:
|
||||
static void __attribute__((always_inline)) baz () { volatile unsigned i; i++; }
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user