From f46c110e4fc598d44722e82e85ca8d9d01f4680a Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Sat, 28 Nov 2020 17:29:18 +0100 Subject: [PATCH] Fix partial symbols The DW_AT_ranges attribute is of type DW_FORM_sec_offset or DW_FORM_rnglistx. But the function attribute attribute::constant_value () does only handle DW_FORM_sdata, DW_FORM_implicit_const, DW_FORM_udata DW_FORM_data1, DW_FORM_data2, DW_FORM_data4, DW_FORM_data8 and returns the default value for anything else. Therefore the wrong range is parsed. Fixes: 529908cbd0a ("Remove DW_UNSND") gdb: 2021-01-03 Bernd Edlinger * dwarf2/read.c (partial_die_info::read): Fix DW_AT_ranges. gdb/testsuite: 2021-01-03 Bernd Edlinger * gdb.cp/step-and-next-psymtab.exp: New test. * gdb.cp/step-and-next-psymtab.cc: New test. --- gdb/dwarf2/read.c | 2 +- gdb/testsuite/gdb.cp/step-and-next-psymtab.cc | 27 ++++++++++++++++++++++ gdb/testsuite/gdb.cp/step-and-next-psymtab.exp | 31 ++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.cp/step-and-next-psymtab.cc create mode 100644 gdb/testsuite/gdb.cp/step-and-next-psymtab.exp diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 9032186..d87d22c8 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -19805,7 +19805,7 @@ struct type * /* It would be nice to reuse dwarf2_get_pc_bounds here, but that requires a full DIE, so instead we just reimplement it. */ - unsigned int ranges_offset = (attr.constant_value (0) + unsigned int ranges_offset = (attr.as_unsigned () + (need_ranges_base ? cu->ranges_base : 0)); diff --git a/gdb/testsuite/gdb.cp/step-and-next-psymtab.cc b/gdb/testsuite/gdb.cp/step-and-next-psymtab.cc new file mode 100644 index 0000000..1bb724b --- /dev/null +++ b/gdb/testsuite/gdb.cp/step-and-next-psymtab.cc @@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2021 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 . */ + +#include "step-and-next-inline.h" + +int +get_alias_set1 (tree *t) +{ + if (t != NULL + && TREE_TYPE (t).z != 1) + return 0; + return 1; +} diff --git a/gdb/testsuite/gdb.cp/step-and-next-psymtab.exp b/gdb/testsuite/gdb.cp/step-and-next-psymtab.exp new file mode 100644 index 0000000..2afc4d9 --- /dev/null +++ b/gdb/testsuite/gdb.cp/step-and-next-psymtab.exp @@ -0,0 +1,31 @@ +# Copyright 2021 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 step-and-next-inline.cc .cc + +if [get_compiler_info "c++"] { + unsupported "couldn't find a valid c++ compiler" + return -1 +} + +set options {c++ debug nowarnings optimize=-O2} + +set sources [list $srcfile $srcfile2] + +if { [prepare_for_testing "failed to prepare" $testfile $sources $options] } { + return -1 +} + +gdb_test "b tree_check" ".*Breakpoint .* \\(4 locations\\).*" "test1" -- 1.9.1