From: Bernd Edlinger <bernd.edlinger@hotmail.de>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH][gdb/symtab] Handle DW_AT_ranges with DW_FORM_sec_off in partial DIE
Date: Mon, 25 Jan 2021 13:52:56 +0100 [thread overview]
Message-ID: <AM8PR10MB4708F2698699E12B6CBB754CE4BD0@AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20210125122444.GA15885@delia>
[-- Attachment #1: Type: text/plain, Size: 1078 bytes --]
On 1/25/21 1:24 PM, Tom de Vries wrote:
> Hi,
>
> While looking into a failure in gdb.go/package.exp with gcc-11, I noticed that
> gdb shows some complaints when loading the executable (also with gcc-10, where
> the test-case passes):
> ...
> $ gdb -batch -iex "set complaints 100" package.10 -ex start
> During symbol reading: Attribute value is not a constant (DW_FORM_sec_offset)
> Temporary breakpoint 1 at 0x402ae6: file gdb.go/package1.go, line 8.
> During symbol reading: Attribute value is not a constant (DW_FORM_sec_offset)
> During symbol reading: Invalid .debug_rnglists data (no base address)
> ...
>
> Fix this by using as_unsigned () to read DW_AT_ranges in the partial DIE
> reader, similar to how that is done in dwarf2_get_pc_bounds.
>
> Tested on x86_64-linux.
>
> Any comments?
>
Oh, interesting.
This is exactly what I have posted here:
https://sourceware.org/pipermail/gdb-patches/2021-January/174660.html
but my test case shows the regression in the partial symbols.
Maybe you can take my test case and merge it to your patch?
Thanks
Bernd.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-partial-symbols.patch --]
[-- Type: text/x-patch; name="0001-Fix-partial-symbols.patch", Size: 4460 bytes --]
From 338f196f9cb4da8b85e42f435424f1c6dc396b36 Mon Sep 17 00:00:00 2001
From: Bernd Edlinger <bernd.edlinger@hotmail.de>
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 <bernd.edlinger@hotmail.de>
* dwarf2/read.c (partial_die_info::read): Fix DW_AT_ranges.
gdb/testsuite:
2021-01-03 Bernd Edlinger <bernd.edlinger@hotmail.de>
* 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 | 34 ++++++++++++++++++++++++++
3 files changed, 62 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 309ff83..5191d69 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -19810,7 +19810,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 <http://www.gnu.org/licenses/>. */
+
+#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..2268f16
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/step-and-next-psymtab.exp
@@ -0,0 +1,34 @@
+# 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 <http://www.gnu.org/licenses/>.
+
+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}
+# avoid DW_TAG_compile_unit with low_pc != 0 (gcc-8 and earlier)
+lappend options additional_flags=-ffunction-sections
+
+set sources [list $srcfile $srcfile2]
+
+if { [prepare_for_testing "failed to prepare" $testfile $sources $options] } {
+ return -1
+}
+
+# there are 4 tree_check instances not 3
+gdb_test "b tree_check" ".*Breakpoint .* \\(4 locations\\).*" "test1"
--
1.9.1
next prev parent reply other threads:[~2021-01-25 12:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-25 12:24 Tom de Vries
2021-01-25 12:52 ` Bernd Edlinger [this message]
2021-01-25 15:27 ` Simon Marchi via Gdb-patches
2021-01-25 15:37 ` Tom de Vries
2021-01-25 15:47 ` Bernd Edlinger
2021-01-25 16:36 ` Simon Marchi via Gdb-patches
2021-01-25 17:42 ` Bernd Edlinger
2021-01-25 18:12 ` Simon Marchi via Gdb-patches
2021-01-25 18:53 ` Bernd Edlinger
2021-01-25 19:20 ` Bernd Edlinger
2021-01-26 1:52 ` Simon Marchi via Gdb-patches
2021-01-26 7:47 ` Bernd Edlinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM8PR10MB4708F2698699E12B6CBB754CE4BD0@AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM \
--to=bernd.edlinger@hotmail.de \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox