From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 994E33858004; Wed, 15 Feb 2023 21:01:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 994E33858004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676494895; bh=EyFPh9xu8zd4qBgqEZRW3n72cLmegTHLK4pFMe8v2Nc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ClQV5GvTqyEdex2t4JCWt7MbMkANF9vSwFfzc9ii3iTR4Qek58d1Fzl/SGVAnsk+H yeY7mJUGZkDDjWLsiP+kCTII93Ty0g/3pksxzCHArmnn2oRTqkz6bbjNikwsC0ipil SK10KWwGEeBXAPDjj0NrXBF3/vf62FMMXfr2dDog= From: "cvs-commit at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/30105] ptype of internal convenience functions is broken Date: Wed, 15 Feb 2023 21:01:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: pedro at palves dot net X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30105 --- Comment #1 from cvs-commit at gcc dot gnu.org --- The master branch has been updated by Pedro Alves : https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Da975d4e6bcf8= 4d3676cbc47b1c9456cf4c3a32a6 commit a975d4e6bcf84d3676cbc47b1c9456cf4c3a32a6 Author: Pedro Alves Date: Fri Feb 10 11:32:35 2023 +0000 Fix "ptype INTERNAL_FUNC" (PR gdb/30105) Currently, looking at the type of an internal function, like below, hits an odd error: (gdb) ptype $_isvoid type =3D type not handled in c_type_print_varspec_prefix() That is an error thrown from c-typeprint.c:c_type_print_varspec_prefix, where it reads: ... case TYPE_CODE_DECFLOAT: case TYPE_CODE_FIXED_POINT: /* These types need no prefix. They are listed here so that gcc -Wall will reveal any types that haven't been handled. */ break; default: error (_("type not handled in c_type_print_varspec_prefix()")); break; Internal function types have type code TYPE_CODE_INTERNAL_FUNCTION, which is not explicitly handled by that switch. That comment quoted above says that gcc -Wall will reveal any types that haven't been handled, but that's not actually true, at least with modern GCCs. You would need to enable -Wswitch-enum for that, which we don't. If I do enable that warning, then I see that we're missing handling for the following type codes: TYPE_CODE_INTERNAL_FUNCTION, TYPE_CODE_MODULE, TYPE_CODE_NAMELIST, TYPE_CODE_XMETHOD TYPE_CODE_MODULE and TYPE_CODE_NAMELIST and Fortran-specific, so it'd be a little weird to handle them here. I tried to reach this code with TYPE_CODE_XMETHOD, but couldn't figure out how to. ptype on an xmethod isn't treated specially, it just complains that the method doesn't exist. I've extended the gdb.python/py-xmethods.exp testcase to make sure of that. My thinking is that whatever type code we add next, the most likely scenario is that it won't need any special handling, so we'd just be adding another case to that "do nothing" list. If we do need special casing for whatever type code, I think that tests added at the same time as the feature would uncover it anyhow. If we do miss adding the special casing, then it still looks better to me to print the type somewhat incompletely than to error out and make it harder for users to debug whatever they need. So I think that the best thing to do here is to just remove all those explicit "do nothing" cases, along with the error default case. After doing that, I decided to write a testcase that iterates over all supported languages doing "ptype INTERNAL_FUNC". That revealed that Pascal has a similar problem, except the default case hits a gdb_assert instead of an error: (gdb) with language pascal -- ptype $_isvoid type =3D ../../src/gdb/p-typeprint.c:268: internal-error: type_print_varspec_prefix: unexpected type A problem internal to GDB has been detected, further debugging may prove unreliable. That is fixed by this patch in the same way. You'll notice that the new testcase special-cases the Ada expected output: } elseif {$lang =3D=3D "ada"} { gdb_test "ptype \$_isvoid" "<>" } else { gdb_test "ptype \$_isvoid" "" } That will be subject of the following patch. Approved-By: Andrew Burgess Change-Id: I81aec03523cceb338b5180a0b4c2e4ad26b4c4db Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30105 --=20 You are receiving this mail because: You are on the CC list for the bug.=