* [RFC][PATCH][symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count
@ 2018-07-18 17:18 Tom de Vries
2018-07-19 14:40 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2018-07-18 17:18 UTC (permalink / raw)
To: gdb-patches
Hi,
this patch (without test-case for now) generates a warning if
DW_AT_upper_bound or DW_AT_count is defined, but can't be translated. This
is triggered for current gcc in lto mode for vla test-cases.
F.i.:
...
$ gcc gcc/testsuite/gcc.dg/guality/vla-1.c -g -O2 -flto \
-DPREVENT_OPTIMIZATION -o ./vla-1.exe
$ ./gdb -batch -ex "set complaints 10" -ex "file ./vla-1.exe"
During symbol reading, Unresolved DW_AT_upper_bound - DIE at 0x337
[in module vla-1.exe].
...
Good idea?
Any other comments?
Thanks,
- Tom
[gdb/symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count
2018-07-18 Tom de Vries <tdevries@suse.de>
* dwarf2read.c (read_subrange_type): Warn if DW_AT_upper_bound or
DW_AT_count can't be translated to a dynamic prop.
---
gdb/dwarf2read.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b7933de49c..3f696ea060 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -17596,10 +17596,11 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
sect_offset_str (die->sect_off),
objfile_name (cu->per_cu->dwarf2_per_objfile->objfile));
- attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
+ struct attribute *attr_ub, *attr_count;
+ attr = attr_ub = dwarf2_attr (die, DW_AT_upper_bound, cu);
if (!attr_to_dynamic_prop (attr, die, cu, &high))
{
- attr = dwarf2_attr (die, DW_AT_count, cu);
+ attr = attr_count = dwarf2_attr (die, DW_AT_count, cu);
if (attr_to_dynamic_prop (attr, die, cu, &high))
{
/* If bounds are constant do the final calculation here. */
@@ -17608,6 +17609,20 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
else
high_bound_is_count = 1;
}
+ else
+ {
+ if (attr_ub)
+ complaint (_("Unresolved DW_AT_upper_bound "
+ "- DIE at %s [in module %s]"),
+ sect_offset_str (die->sect_off),
+ objfile_name (cu->per_cu->dwarf2_per_objfile->objfile));
+ if (attr_count)
+ complaint (_("Unresolved DW_AT_count "
+ "- DIE at %s [in module %s]"),
+ sect_offset_str (die->sect_off),
+ objfile_name (cu->per_cu->dwarf2_per_objfile->objfile));
+ }
+
}
/* Dwarf-2 specifications explicitly allows to create subrange types
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC][PATCH][symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count
2018-07-18 17:18 [RFC][PATCH][symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count Tom de Vries
@ 2018-07-19 14:40 ` Tom Tromey
2018-07-20 21:21 ` Tom de Vries
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2018-07-19 14:40 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> this patch (without test-case for now) generates a warning if
Tom> DW_AT_upper_bound or DW_AT_count is defined, but can't be translated. This
Tom> is triggered for current gcc in lto mode for vla test-cases.
Tom> F.i.:
Tom> ...
Tom> $ gcc gcc/testsuite/gcc.dg/guality/vla-1.c -g -O2 -flto \
Tom> -DPREVENT_OPTIMIZATION -o ./vla-1.exe
Tom> $ ./gdb -batch -ex "set complaints 10" -ex "file ./vla-1.exe"
Tom> During symbol reading, Unresolved DW_AT_upper_bound - DIE at 0x337
Tom> [in module vla-1.exe].
Tom> ...
Tom> Good idea?
I think so.
Tom> + if (attr_ub)
[...]
Tom> + if (attr_count)
The gdb style is to use a check against nullptr in these spots.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC][PATCH][symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count
2018-07-19 14:40 ` Tom Tromey
@ 2018-07-20 21:21 ` Tom de Vries
2018-07-25 18:55 ` Tom Tromey
0 siblings, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2018-07-20 21:21 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Thu, Jul 19, 2018 at 08:40:20AM -0600, Tom Tromey wrote:
> >>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> this patch (without test-case for now) generates a warning if
> Tom> DW_AT_upper_bound or DW_AT_count is defined, but can't be translated. This
> Tom> is triggered for current gcc in lto mode for vla test-cases.
>
> Tom> F.i.:
> Tom> ...
> Tom> $ gcc gcc/testsuite/gcc.dg/guality/vla-1.c -g -O2 -flto \
> Tom> -DPREVENT_OPTIMIZATION -o ./vla-1.exe
> Tom> $ ./gdb -batch -ex "set complaints 10" -ex "file ./vla-1.exe"
> Tom> During symbol reading, Unresolved DW_AT_upper_bound - DIE at 0x337
> Tom> [in module vla-1.exe].
> Tom> ...
>
> Tom> Good idea?
>
> I think so.
>
> Tom> + if (attr_ub)
> [...]
> Tom> + if (attr_count)
>
> The gdb style is to use a check against nullptr in these spots.
>
Updated accordingly, and added test-case.
OK for trunk?
Thanks,
- Tom
[gdb/symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count
This patch generates a warning if DW_AT_upper_bound or DW_AT_count is defined,
but can't be translated. This is triggered for current gcc in lto mode for
vla test-cases.
Build and reg-tested on x86_64-linux.
2018-07-18 Tom de Vries <tdevries@suse.de>
* dwarf2read.c (read_subrange_type): Warn if DW_AT_upper_bound or
DW_AT_count can't be translated to a dynamic prop.
* gdb.dwarf2/dw2-unresolved-ub.exp: new file.
---
gdb/dwarf2read.c | 19 +++++++++--
gdb/testsuite/gdb.dwarf2/dw2-unresolved-ub.exp | 47 ++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index b7933de49c..92107c0900 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -17596,10 +17596,11 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
sect_offset_str (die->sect_off),
objfile_name (cu->per_cu->dwarf2_per_objfile->objfile));
- attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
+ struct attribute *attr_ub, *attr_count;
+ attr = attr_ub = dwarf2_attr (die, DW_AT_upper_bound, cu);
if (!attr_to_dynamic_prop (attr, die, cu, &high))
{
- attr = dwarf2_attr (die, DW_AT_count, cu);
+ attr = attr_count = dwarf2_attr (die, DW_AT_count, cu);
if (attr_to_dynamic_prop (attr, die, cu, &high))
{
/* If bounds are constant do the final calculation here. */
@@ -17608,6 +17609,20 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
else
high_bound_is_count = 1;
}
+ else
+ {
+ if (attr_ub != NULL)
+ complaint (_("Unresolved DW_AT_upper_bound "
+ "- DIE at %s [in module %s]"),
+ sect_offset_str (die->sect_off),
+ objfile_name (cu->per_cu->dwarf2_per_objfile->objfile));
+ if (attr_count != NULL)
+ complaint (_("Unresolved DW_AT_count "
+ "- DIE at %s [in module %s]"),
+ sect_offset_str (die->sect_off),
+ objfile_name (cu->per_cu->dwarf2_per_objfile->objfile));
+ }
+
}
/* Dwarf-2 specifications explicitly allows to create subrange types
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unresolved-ub.exp b/gdb/testsuite/gdb.dwarf2/dw2-unresolved-ub.exp
new file mode 100644
index 0000000000..e8fcf0414e
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unresolved-ub.exp
@@ -0,0 +1,47 @@
+# Copyright 2018 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/>.
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+ return 0
+}
+
+if { ![test_compiler_info "gcc-9-*-*"] } {
+ return 0
+}
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" $testfile "${srcdir}/gdb.base/vla-optimized-out.c" \
+ {debug optimize=-O2 additional_flags=-flto additional_flags=-gstrict-dwarf}] } {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+
+# From gdb_file_cmd:
+if [is_remote host] {
+ set arg [remote_download host $binfile]
+ if { $arg == "" } {
+ perror "download failed"
+ return -1
+ }
+}
+
+gdb_test_no_output "set complaints 3"
+gdb_test "file $binfile" "DW_AT_upper_bound.*" "Unresolved upper bound"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC][PATCH][symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count
2018-07-20 21:21 ` Tom de Vries
@ 2018-07-25 18:55 ` Tom Tromey
2018-07-26 8:40 ` Tom de Vries
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2018-07-25 18:55 UTC (permalink / raw)
To: Tom de Vries; +Cc: Tom Tromey, gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> 2018-07-18 Tom de Vries <tdevries@suse.de>
Tom> * dwarf2read.c (read_subrange_type): Warn if DW_AT_upper_bound or
Tom> DW_AT_count can't be translated to a dynamic prop.
This part is fine.
Tom> * gdb.dwarf2/dw2-unresolved-ub.exp: new file.
It's great to test the warning, but I think this approach is mostly
testing whether gcc has a particular bug. The more future-proof way to
do this sort of test would be to use the DWARF assembler to craft a bit
of DWARF that has the problem.
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC][PATCH][symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count
2018-07-25 18:55 ` Tom Tromey
@ 2018-07-26 8:40 ` Tom de Vries
0 siblings, 0 replies; 5+ messages in thread
From: Tom de Vries @ 2018-07-26 8:40 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 07/25/2018 08:55 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> 2018-07-18 Tom de Vries <tdevries@suse.de>
>
> Tom> * dwarf2read.c (read_subrange_type): Warn if DW_AT_upper_bound or
> Tom> DW_AT_count can't be translated to a dynamic prop.
>
> This part is fine.
>
> Tom> * gdb.dwarf2/dw2-unresolved-ub.exp: new file.
>
> It's great to test the warning, but I think this approach is mostly
> testing whether gcc has a particular bug. The more future-proof way to
> do this sort of test would be to use the DWARF assembler to craft a bit
> of DWARF that has the problem.
I see, I'll keep that in mind. For now, I've committed without the
test-case.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-07-26 8:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-18 17:18 [RFC][PATCH][symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count Tom de Vries
2018-07-19 14:40 ` Tom Tromey
2018-07-20 21:21 ` Tom de Vries
2018-07-25 18:55 ` Tom Tromey
2018-07-26 8:40 ` Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).