From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id AC86C381FE7D; Fri, 16 Sep 2022 15:14:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC86C381FE7D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663341278; bh=FPw01IgnJTzA4DHBx4an1kJKSVwH7k3nFHMA+xUE6e0=; h=From:To:Subject:Date:From; b=iKbNjLe83HzVUvqXAtDG/+6TDxqtYhO6drYnqa9tUC1gG0cl9IBw3MjS4YnfNXBTB iEDoB7Gu8cn2LNjzHPhmluIJZbkx87nQ8AArNPMtoMeoobXIaYyBQNfPPN4ZXIrm1e N3BJSHzh2PewKjqr64FXhRTBrYRuz2AGiCsR8+Z0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/symtab] Handle named DW_TAG_unspecified_type DIE X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: ff84aaf3e338702f982274ffb79e93562d05070c X-Git-Newrev: 80eaec735e36598a312f9b184ee4f32bd6c0bab4 Message-Id: <20220916151438.AC86C381FE7D@sourceware.org> Date: Fri, 16 Sep 2022 15:14:38 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D80eaec735e36= 598a312f9b184ee4f32bd6c0bab4 commit 80eaec735e36598a312f9b184ee4f32bd6c0bab4 Author: Tom de Vries Date: Fri Sep 16 17:14:34 2022 +0200 [gdb/symtab] Handle named DW_TAG_unspecified_type DIE =20 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 ... =20 Fix the complaint by handling DW_TAG_unspecified_type in new_symbol, an= d verify in the test-case using "maint print symbols" that the symbol exists. =20 Tested on x86_64-linux, with gcc 7.5.0 and clang 13.0. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D17271 Diff: --- 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 29ccd00a1da..0a3c29212b4 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -21066,6 +21066,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 =3D cu->list_in_scope; diff --git a/gdb/testsuite/gdb.dwarf2/nullptr_t.cc b/gdb/testsuite/gdb.dwar= f2/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 . = */ + +#include + +void +foo (std::nullptr_t) +{ +} + +int +main (void) +{ + foo (nullptr); +} diff --git a/gdb/testsuite/gdb.dwarf2/nullptr_t.exp b/gdb/testsuite/gdb.dwa= rf2/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 . + +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"