public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH][gdb/symtab] Handle named DW_TAG_unspecified_type DIE
@ 2022-09-09  9:32 Tom de Vries
  2022-09-16 15:15 ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2022-09-09  9:32 UTC (permalink / raw)
  To: gdb-patches

Hi,

With the test-case included in the patch, we run into:
...
(gdb) info types -q std::nullptr_t^M
During symbol reading: unsupported tag: 'DW_TAG_unspecified_type'^M
^M
File /usr/include/c++/7/x86_64-suse-linux/bits/c++config.h:^M
2198:   typedef decltype(nullptr) std::nullptr_t;^M
(gdb) FAIL: gdb.dwarf2/nullptr_t.exp: info types -q std::nullptr_t \
  without complaint
...

Fix the complaint by handling DW_TAG_unspecified_type in new_symbol, and verify
in the test-case using "maint print symbols" that the symbol exists.

Tested on x86_64-linux, with gcc 7.5.0 and clang 13.0.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17271

Any comments?

Thanks,
- Tom

[gdb/symtab] Handle named DW_TAG_unspecified_type DIE

---
 gdb/dwarf2/read.c                      |  1 +
 gdb/testsuite/gdb.dwarf2/nullptr_t.cc  | 29 +++++++++++++++++++++++++
 gdb/testsuite/gdb.dwarf2/nullptr_t.exp | 39 ++++++++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3ca441c4cae..a382d217def 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -21063,6 +21063,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_base_type:
 	case DW_TAG_subrange_type:
 	case DW_TAG_generic_subrange:
+	case DW_TAG_unspecified_type:
 	  sym->set_aclass_index (LOC_TYPEDEF);
 	  sym->set_domain (VAR_DOMAIN);
 	  list_to_add = cu->list_in_scope;
diff --git a/gdb/testsuite/gdb.dwarf2/nullptr_t.cc b/gdb/testsuite/gdb.dwarf2/nullptr_t.cc
new file mode 100644
index 00000000000..85fe801e193
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/nullptr_t.cc
@@ -0,0 +1,29 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2022 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 <cstddef>
+
+void
+foo (std::nullptr_t)
+{
+}
+
+int
+main (void)
+{
+  foo (nullptr);
+}
diff --git a/gdb/testsuite/gdb.dwarf2/nullptr_t.exp b/gdb/testsuite/gdb.dwarf2/nullptr_t.exp
new file mode 100644
index 00000000000..c597c660a36
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/nullptr_t.exp
@@ -0,0 +1,39 @@
+# Copyright 2022 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/>.
+
+if {[skip_cplus_tests]} { continue }
+
+standard_testfile .cc
+
+if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}] {
+    return -1
+}
+
+set cmd "info types -q std::nullptr_t"
+
+set re \
+    [multi_line \
+	 "$cmd" \
+	 "" \
+	 "File .*:" \
+	 "$decimal:\ttypedef decltype\\(nullptr\\) std::nullptr_t;"]
+
+with_complaints 5 {
+    gdb_test $cmd $re "$cmd without complaints"
+}
+
+gdb_test "maint print symbols -source $srcfile" \
+    "typedef void decltype\\(nullptr\\); \r\n.*" \
+    "decltype(nullptr) symbol"

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][gdb/symtab] Handle named DW_TAG_unspecified_type DIE
  2022-09-09  9:32 [PATCH][gdb/symtab] Handle named DW_TAG_unspecified_type DIE Tom de Vries
@ 2022-09-16 15:15 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2022-09-16 15:15 UTC (permalink / raw)
  To: gdb-patches

On 9/9/22 11:32, Tom de Vries wrote:
> Hi,
> 
> With the test-case included in the patch, we run into:
> ...
> (gdb) info types -q std::nullptr_t^M
> During symbol reading: unsupported tag: 'DW_TAG_unspecified_type'^M
> ^M
> File /usr/include/c++/7/x86_64-suse-linux/bits/c++config.h:^M
> 2198:   typedef decltype(nullptr) std::nullptr_t;^M
> (gdb) FAIL: gdb.dwarf2/nullptr_t.exp: info types -q std::nullptr_t \
>    without complaint
> ...
> 
> Fix the complaint by handling DW_TAG_unspecified_type in new_symbol, and verify
> in the test-case using "maint print symbols" that the symbol exists.
> 
> Tested on x86_64-linux, with gcc 7.5.0 and clang 13.0.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17271
> 
> Any comments?
> 

Committed.

Thanks,
- Tom

> [gdb/symtab] Handle named DW_TAG_unspecified_type DIE
> 
> ---
>   gdb/dwarf2/read.c                      |  1 +
>   gdb/testsuite/gdb.dwarf2/nullptr_t.cc  | 29 +++++++++++++++++++++++++
>   gdb/testsuite/gdb.dwarf2/nullptr_t.exp | 39 ++++++++++++++++++++++++++++++++++
>   3 files changed, 69 insertions(+)
> 
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 3ca441c4cae..a382d217def 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -21063,6 +21063,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
>   	case DW_TAG_base_type:
>   	case DW_TAG_subrange_type:
>   	case DW_TAG_generic_subrange:
> +	case DW_TAG_unspecified_type:
>   	  sym->set_aclass_index (LOC_TYPEDEF);
>   	  sym->set_domain (VAR_DOMAIN);
>   	  list_to_add = cu->list_in_scope;
> diff --git a/gdb/testsuite/gdb.dwarf2/nullptr_t.cc b/gdb/testsuite/gdb.dwarf2/nullptr_t.cc
> new file mode 100644
> index 00000000000..85fe801e193
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/nullptr_t.cc
> @@ -0,0 +1,29 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> +   Copyright 2022 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 <cstddef>
> +
> +void
> +foo (std::nullptr_t)
> +{
> +}
> +
> +int
> +main (void)
> +{
> +  foo (nullptr);
> +}
> diff --git a/gdb/testsuite/gdb.dwarf2/nullptr_t.exp b/gdb/testsuite/gdb.dwarf2/nullptr_t.exp
> new file mode 100644
> index 00000000000..c597c660a36
> --- /dev/null
> +++ b/gdb/testsuite/gdb.dwarf2/nullptr_t.exp
> @@ -0,0 +1,39 @@
> +# Copyright 2022 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/>.
> +
> +if {[skip_cplus_tests]} { continue }
> +
> +standard_testfile .cc
> +
> +if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}] {
> +    return -1
> +}
> +
> +set cmd "info types -q std::nullptr_t"
> +
> +set re \
> +    [multi_line \
> +	 "$cmd" \
> +	 "" \
> +	 "File .*:" \
> +	 "$decimal:\ttypedef decltype\\(nullptr\\) std::nullptr_t;"]
> +
> +with_complaints 5 {
> +    gdb_test $cmd $re "$cmd without complaints"
> +}
> +
> +gdb_test "maint print symbols -source $srcfile" \
> +    "typedef void decltype\\(nullptr\\); \r\n.*" \
> +    "decltype(nullptr) symbol"

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-16 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09  9:32 [PATCH][gdb/symtab] Handle named DW_TAG_unspecified_type DIE Tom de Vries
2022-09-16 15:15 ` 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).