From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by sourceware.org (Postfix) with ESMTPS id DC3BE393BC18 for ; Tue, 2 Mar 2021 01:54:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DC3BE393BC18 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1221plkm150485 for ; Tue, 2 Mar 2021 01:54:05 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 36ybkb60pj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 02 Mar 2021 01:54:05 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1221oVtm066218 for ; Tue, 2 Mar 2021 01:54:04 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by userp3020.oracle.com with ESMTP id 36yyurbp8c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 02 Mar 2021 01:54:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W1cfrIsm/GhFDoDxV1n5kgSeCVEdtwBI+SPovGnt4DCjnfj3UOl4yioAf9Ei26ej/LiDEjQvq2oK2xbq8bZnjOFsKW92vIg/mSJ0b6huKHV1iynYCjMNoXYltd9K512XiPr/qbAEV4qEoOc/JS26qmZ+XYzdMmRGSrtjLhUSHIJqr21DYkKlZh+dH/zWvxK3nHSunPu68WRSVVWSAoXu3pKepMvkTkChSFZAVou4tVtXTeCY59D63kVBt/Fk8WBrZAoBRj76KClAjrwEYKvkAJLJ3PKcC4oXijtxNnRcnHmbnGkTEuv1wxvjvP8W/KO7cVVlK6/SqqDg0xoafiVnaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I3Htvyv3BC61/QrqXnaMfvpcdmRaIDKeMu7JqV7/a1Q=; b=aU3PQE0Yns77nY5R9PhEHRn4qYg3zR/kINCi9ZgZtM864HOsGR52MHYc9Yl7q/8KGu4F4LACcsyinfpyW921s78szryv9PpqL90E7JASXvcWxC7825uUwaCDcYeuNCYxNa2lgGiLgPdBknX2Xc1G4aUOZ9ycgR26MEAKlH5iRu9bsgcq3u5y69B1CQZIzlTbKHNXiMBioSWp4fMncBLpDadOciI1hpLdEqCiqDSnfpZ11Vzt6DJOMq1b+g2nAxo0Ar/sNNVku4viZvKGnotubQL9KkLfmFaKzUMZxbQrIdeJWOEoTxL6N7KkouJsozY4EcaL/OHPAeGobQPC1tuODw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from BN6PR10MB1748.namprd10.prod.outlook.com (2603:10b6:405:9::16) by BN0PR10MB5383.namprd10.prod.outlook.com (2603:10b6:408:124::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.20; Tue, 2 Mar 2021 01:54:02 +0000 Received: from BN6PR10MB1748.namprd10.prod.outlook.com ([fe80::1163:f828:25bb:2538]) by BN6PR10MB1748.namprd10.prod.outlook.com ([fe80::1163:f828:25bb:2538%7]) with mapi id 15.20.3890.029; Tue, 2 Mar 2021 01:54:02 +0000 From: Weimin Pan To: gdb-patches@sourceware.org Subject: [PATCH,V2 1/5] CTF: fix incorrect function return type Date: Mon, 1 Mar 2021 20:53:34 -0500 Message-Id: <1614650018-9135-2-git-send-email-weimin.pan@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614650018-9135-1-git-send-email-weimin.pan@oracle.com> References: <1614650018-9135-1-git-send-email-weimin.pan@oracle.com> Content-Type: text/plain X-Originating-IP: [148.87.23.7] X-ClientProxiedBy: SJ0PR05CA0203.namprd05.prod.outlook.com (2603:10b6:a03:330::28) To BN6PR10MB1748.namprd10.prod.outlook.com (2603:10b6:405:9::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.us.oracle.com (148.87.23.7) by SJ0PR05CA0203.namprd05.prod.outlook.com (2603:10b6:a03:330::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.11 via Frontend Transport; Tue, 2 Mar 2021 01:54:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5127c123-66e8-4d05-8b9e-08d8dd1e0d34 X-MS-TrafficTypeDiagnostic: BN0PR10MB5383: X-MS-Exchange-MinimumUrlDomainAge: gnu.org#9230 X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1923; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ARTHlzArmcQ7JJmzRENk/xo5et1vPiJO6IrFewY4xzP7lkA5S8DP8EtD9N0HmNiXvnwi9V4uMhcuKR5m06T+ezLPwpnMU3UgUX/KbUf/FT8qE+hZ36ZySrxW7asrKFV1KJVIrX2+UeSB0Gh+k08MCK74BbTsHCGysb99IPB42p6HwLEwWddHK+V2mmVwsNexKamVPQXNDfqIkWGCRhKNDdZE8QDy+xRCf0OLfPvqgU2DSFNSUiZlz3gVwansZQ/5l8cjUKLYp+06XOr1E53YyREwE9MKqrQO1M311VduT2rBsVqDJKqWA86FxmXgls9aCz/luVvPv4Z+Cb/hxYumpuFLPewh3lovKA7cywA25SEFHvB4jUnGFk9E9uUdV7h6druR9Hu9/JAImEQB0IgS9QSIaKei/FL7AD9yrYupJRJQH7F659P1ZaEwYOqvXVWuB40pRhQm0ZZ1qnURwTjvijnFqFkOY68muFOrhY004t9LdcQQCX7HR3FUyAZpsEi4Tem8l6n3dinf4pEskr8Za7FyYWKnFBpuHyFph8UN6JceDHKQ/zlYDwbz1smo4iVSBzn7X+XZ3vqd0vBm9npHJB7ElZroMTDeMzOUugwnkzBi2ihHTHlnLpg88Ngxioy6CUkcp68Hi6blCGpxEBOwAg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN6PR10MB1748.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(376002)(136003)(346002)(396003)(39860400002)(30864003)(66946007)(16526019)(66556008)(66476007)(6666004)(316002)(83380400001)(6486002)(44832011)(956004)(8676002)(5660300002)(2616005)(2906002)(8936002)(6916009)(478600001)(36756003)(7696005)(52116002)(86362001)(26005)(186003)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Psif/jfdaJ94N7vWYmbSUbiSnpM55pqdmctvE2r9rxlSmCepaKQfWHb8HFNB?= =?us-ascii?Q?KR6w/ZHat4ebepDPMhMbjC+jND5wHT8fv3NtderLiAvKv/+JCSCxvSQ/f33y?= =?us-ascii?Q?0laiPO7FT8bxU0dfJbczlivMVriLufYcMRFIBAOE4kkekZMmcJLBf5pME+u6?= =?us-ascii?Q?cLBY2MXAwiUgFDcLwdAtEeB03GB8cZIKnRMMk4YBZtbB8DvjrHtUJNLwgr7p?= =?us-ascii?Q?JyEzULTn3Blb7+R+K1Nh4zFLBgsfkpEIq08rN/HP6BICTBhVvGPhCQeKQw2+?= =?us-ascii?Q?uGDaRnjA47gVjm8HBBIqRO8dhrIWPrFdaX7BbBT6fUpo7LeXgTHlNuBqBXBV?= =?us-ascii?Q?7siXhblz998NbiH61dhEYMHVWSlDHWBkXhcrkMFg69LPxmwrU8FIfGeKVk0f?= =?us-ascii?Q?LlFieu98usrAAPdG2QA5cP9xYqy8s1geC69gUgD3FuknehcQdrssfsa6gxcQ?= =?us-ascii?Q?mnRtBz6T14YCC6TDV366vsyuXNt96mXxA9kx4TeQhpPcjPlHaTvgiv0DZnp6?= =?us-ascii?Q?b+2ozXPPHsg2NKhLsASQr0qTooOMn/Zco746jgG5I0pz6WjyJsGErX5x80bk?= =?us-ascii?Q?nDO/y9GDzZR2vixAJoBHi19mtVec4b9+jO1VTH6227cSG2DzG9JYF+MLpvzx?= =?us-ascii?Q?x7Am6GqrEvf01j/mGc1AhYzOQXgYH6z3S9YQnBEjGTNhG4PSWVWamw+1hKP3?= =?us-ascii?Q?NxoUyOVz1W284IjHQV9ySg9/lNCRfCjsLDkVdfjGfu8RiIjp7tIlQAbyAsE8?= =?us-ascii?Q?HJaBpMKAMZ7bDHv3EaamVeogkPZ1Pkzf9RcY9qbomRlJuktrkdpu3GpZ/n4X?= =?us-ascii?Q?YymYLix0NwIcHLwP4pu7o77T8P03h6vWDUJ+rRkRggCDNmak3N7ObBJ/GjAs?= =?us-ascii?Q?HsIi5fIihi7i918AOfTrlO6Upmvtlv1Qezy27/ROxO//L+xbdSOGMLURc2t3?= =?us-ascii?Q?kiY84iuJhNan/GteEO1ul0Xs/nPE7D1L3oxr5iZUOPC8tPsscGTJVdTyfFb5?= =?us-ascii?Q?wJPHJr9RC+b5NqllAd77B/g5Rp3kEDim+kS+/SyGdZSZPdI0wqFRG9rMIg9u?= =?us-ascii?Q?hRRqJP+MO0cb0npPT/tM959c/7pmCLTTH/phxoNNQ+I+2p6Uwg84AoHRBAA0?= =?us-ascii?Q?zD+cltrla6P7c1puvTt6uAqRkL0hELG2U9bfF3fFs9evjTLeTenCoiL64LZ4?= =?us-ascii?Q?zA9qkWKWJ3umH7AeOB7xZdAHLdV6fv8eTNHnMQuL9d8Xo8FOWKmvFNvMX2C7?= =?us-ascii?Q?MwBaGFF4vQbSkom98WUiE7UAHCQuhpug3OzPENdbU5MVicipks7Ysrx3eltk?= =?us-ascii?Q?yhfZNtAF4QC0PiV6AbFROLlm?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5127c123-66e8-4d05-8b9e-08d8dd1e0d34 X-MS-Exchange-CrossTenant-AuthSource: BN6PR10MB1748.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2021 01:54:01.9197 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zSGOnxpjTK6nK1ZrpGPN7DyTR/En/klUANedtSV5yabkfgrQZXJ3sTAwoX6WGrsGxnH3xJx13MCpl6xVa2oYLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB5383 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9910 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103020011 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9910 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 impostorscore=0 suspectscore=0 phishscore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103020011 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, MSGID_FROM_MTA_HEADER, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2021 01:54:08 -0000 The problems can be illustrated, with any program, below: (gdb) print main $1 = {main} 0x0 The return type was incorrectly set in read_func_kind_type, with the name of the function, which leads c_type_print_base_1 to print it. In addition, the address of a new function needs to be set with that info in its minimal symtab entry, when the new function is added. After the fix: (gdb) print main $1 = {int ()} 0x4004b7
A new test, gdb.ctf/funcreturn.exp, is added to the testsuite. --- gdb/ChangeLog | 5 + gdb/ctfread.c | 5 +- gdb/testsuite/ChangeLog | 4 + gdb/testsuite/gdb.ctf/funcreturn.exp | 190 ++++++++++++++++++++ gdb/testsuite/gdb.ctf/whatis.c | 339 +++++++++++++++++++++++++++++++++++ 5 files changed, 539 insertions(+), 4 deletions(-) create mode 100644 gdb/testsuite/gdb.ctf/funcreturn.exp create mode 100644 gdb/testsuite/gdb.ctf/whatis.c diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9d928b0..88278d1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-02-26 Weimin Pan + + * ctfread.c (new_symbol): Set function address. + (read_func_kind_type): Remove incorrect type name setting. + 2021-01-29 Tom de Vries PR breakpoints/26063 diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 866977a..5a68d9c 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -462,6 +462,7 @@ struct ctf_tid_and_type break; case CTF_K_FUNCTION: SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC; + set_symbol_address (objfile, sym, sym->linkage_name ()); break; case CTF_K_CONST: if (SYMBOL_TYPE (sym)->code () == TYPE_CODE_VOID) @@ -656,10 +657,6 @@ struct ctf_tid_and_type type = alloc_type (of); - gdb::unique_xmalloc_ptr name (ctf_type_aname_raw (fp, tid)); - if (name != NULL && strlen (name.get ()) != 0) - type->set_name (obstack_strdup (&of->objfile_obstack, name.get ())); - type->set_code (TYPE_CODE_FUNC); ctf_func_type_info (fp, tid, &cfi); rettype = get_tid_type (of, cfi.ctc_return); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 36ba5d0..3d71354 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2021-02-26 Weimin Pan + + * gdb.base/ctf-funcreturn.exp: New file. + 2021-01-29 Tom de Vries PR breakpoints/26063 diff --git a/gdb/testsuite/gdb.ctf/funcreturn.exp b/gdb/testsuite/gdb.ctf/funcreturn.exp new file mode 100644 index 0000000..874160e --- /dev/null +++ b/gdb/testsuite/gdb.ctf/funcreturn.exp @@ -0,0 +1,190 @@ +# 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 . + +if [skip_ctf_tests] { + unsupported "no CTF debug format support, or CTF disabled in GDB" + return 0 +} + +if [target_info exists no_long_long] { + set exec_opts [list debug additional_flags=-DNO_LONG_LONG] +} else { + set exec_opts [list debug] +} + +standard_testfile whatis.c + +# Using `-gt` generates full-fledged CTF debug information. +set opts "additional_flags=-gt -Wl,--export-dynamic" + +if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile] [list $opts nowarnings]] } { + return 0 +} + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info] { + return -1 +} + +# test print command with functions return type +set void "(void|)" +gdb_test "print v_char_func" \ + "$decimal = \{char \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print char function" + +gdb_test "print v_signed_char_func" \ + "$decimal = \{signed char \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print signed char function" + +gdb_test "print v_unsigned_char_func" \ + "$decimal = \{unsigned char \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print unsigned char function" + +gdb_test "print v_short_func" \ + "$decimal = \{short \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print short function" + +gdb_test "print v_signed_short_func" \ + "$decimal = \{signed short|short \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print signed short function" + +gdb_test "print v_unsigned_short_func" \ + "$decimal = \{unsigned short \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print unsigned short function" + +gdb_test "print v_int_func" \ + "$decimal = \{int \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print int function" + +gdb_test "print v_signed_int_func" \ + "$decimal = \{signed int|int \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print signed int function" + +gdb_test "print v_unsigned_int_func" \ + "$decimal = \{unsigned int \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print unsigned int function" + +gdb_test "print v_long_func" \ + "$decimal = \{long \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print long function" + +gdb_test "print v_signed_long_func" \ + "$decimal = \{signed long|long \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print signed long function" + +gdb_test "print v_unsigned_long_func" \ + "$decimal = \{unsigned long|long \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print unsigned long function" + +if ![target_info exists no_long_long] { + gdb_test "print v_long_long_func" \ + "$decimal = \{long long \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print long long function" + + gdb_test "print v_signed_long_long_func" \ + "$decimal = \{long long \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print signed long long function" + + gdb_test "print v_unsigned_long_long_func" \ + "$decimal = \{unsigned long long \\(\\)\} 0x\[0-9a-z\]+ .*" \ + "print unsigned long long function" +} + +# Sun /bin/cc calls this a function returning double. +if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"} + gdb_test "print v_float_func" \ + "$decimal = \{float \\(\\)\} 0x\[0-9a-z\]+.*" \ + "print float function" + + gdb_test "print v_double_func" \ + "$decimal = \{double \\(\\)\} 0x\[0-9a-z\]+.*" \ + "print double function" \ +} + +# test whatis command with functions return type +gdb_test "whatis v_char_func" \ + "type = (signed |unsigned |)char \\($void\\)" \ + "whatis char function" + +gdb_test "whatis v_signed_char_func" \ + "type = (signed |unsigned |)char \\($void\\)" \ + "whatis signed char function" + +gdb_test "whatis v_unsigned_char_func" \ + "type = unsigned char \\($void\\)" \ + "whatis unsigned char function" + +gdb_test "whatis v_short_func" \ + "type = short (int |)\\($void\\)" \ + "whatis short function" + +gdb_test "whatis v_signed_short_func" \ + "type = (signed |)short (int |)\\($void\\)" \ + "whatis signed short function" + +gdb_test "whatis v_unsigned_short_func" \ + "type = (unsigned short|short unsigned int) \\($void\\)" \ + "whatis unsigned short function" + +gdb_test "whatis v_int_func" \ + "type = int \\($void\\)" \ + "whatis int function" + +gdb_test "whatis v_signed_int_func" \ + "type = (signed |)int \\($void\\)" \ + "whatis signed int function" + +gdb_test "whatis v_unsigned_int_func" \ + "type = unsigned int \\($void\\)" \ + "whatis unsigned int function" + +gdb_test "whatis v_long_func" \ + "type = (long|int|long int) \\($void\\)" \ + "whatis long function" + +gdb_test "whatis v_signed_long_func" \ + "type = (signed |)(int|long|long int) \\($void\\)" \ + "whatis signed long function" + +gdb_test "whatis v_unsigned_long_func" \ + "type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \ + "whatis unsigned long function" + +if ![target_info exists no_long_long] { + gdb_test "whatis v_long_long_func" \ + "type = long long(| int) \\($void\\)" \ + "whatis long long function" + + gdb_test "whatis v_signed_long_long_func" \ + "type = (signed |)long long(| int) \\($void\\)" \ + "whatis signed long long function" + + gdb_test "whatis v_unsigned_long_long_func" \ + "type = (unsigned long long(| int)|long long unsigned int) \\($void\\)" \ + "whatis unsigned long long function" +} + +# Sun /bin/cc calls this a function returning double. +if {!$gcc_compiled} then {setup_xfail "*-sun-sunos4*"} + gdb_test "whatis v_float_func" \ + "type = float \\($void\\)" \ + "whatis float function" + + gdb_test "whatis v_double_func" \ + "type = double \\($void\\)" \ + "whatis double function" \ +} diff --git a/gdb/testsuite/gdb.ctf/whatis.c b/gdb/testsuite/gdb.ctf/whatis.c new file mode 100644 index 0000000..aec899d --- /dev/null +++ b/gdb/testsuite/gdb.ctf/whatis.c @@ -0,0 +1,339 @@ +/* This test program is part of GDB, the GNU debugger. + + Copyright 1992-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 . */ + +/* + * Test file with lots of different types, for testing the + * "whatis" command. + */ + +/* + * First the basic C types. + */ + +char v_char; +signed char v_signed_char; +unsigned char v_unsigned_char; + +short v_short; +signed short v_signed_short; +unsigned short v_unsigned_short; + +int v_int; +signed int v_signed_int; +unsigned int v_unsigned_int; + +long v_long; +signed long v_signed_long; +unsigned long v_unsigned_long; + +#ifndef NO_LONG_LONG +long long v_long_long; +signed long long v_signed_long_long; +unsigned long long v_unsigned_long_long; +#endif + +float v_float; +double v_double; + +/* + * Now some derived types, which are arrays, functions-returning, + * pointers, structures, unions, and enumerations. + */ + +/**** arrays *******/ + +char v_char_array[2]; +signed char v_signed_char_array[2]; +unsigned char v_unsigned_char_array[2]; + +short v_short_array[2]; +signed short v_signed_short_array[2]; +unsigned short v_unsigned_short_array[2]; + +int v_int_array[2]; +signed int v_signed_int_array[2]; +unsigned int v_unsigned_int_array[2]; + +long v_long_array[2]; +signed long v_signed_long_array[2]; +unsigned long v_unsigned_long_array[2]; + +#ifndef NO_LONG_LONG +long long v_long_long_array[2]; +signed long long v_signed_long_long_array[2]; +unsigned long long v_unsigned_long_long_array[2]; +#endif + +float v_float_array[2]; +double v_double_array[2]; + +/**** pointers *******/ + +/* Make sure they still print as pointer to foo even there is a typedef + for that type. Test this not just for char *, which might be + a special case kludge in GDB (Unix system include files like to define + caddr_t), but for a variety of types. */ +typedef char *char_addr; +char_addr a_char_addr; +typedef unsigned short *ushort_addr; +ushort_addr a_ushort_addr; +typedef signed long *slong_addr; +slong_addr a_slong_addr; +#ifndef NO_LONG_LONG +typedef signed long long *slong_long_addr; +slong_long_addr a_slong_long_addr; +#endif + +char *v_char_pointer; +signed char *v_signed_char_pointer; +unsigned char *v_unsigned_char_pointer; + +short *v_short_pointer; +signed short *v_signed_short_pointer; +unsigned short *v_unsigned_short_pointer; + +int *v_int_pointer; +signed int *v_signed_int_pointer; +unsigned int *v_unsigned_int_pointer; + +long *v_long_pointer; +signed long *v_signed_long_pointer; +unsigned long *v_unsigned_long_pointer; + +#ifndef NO_LONG_LONG +long long *v_long_long_pointer; +signed long long *v_signed_long_long_pointer; +unsigned long long *v_unsigned_long_long_pointer; +#endif + +float *v_float_pointer; +double *v_double_pointer; + +/**** structs *******/ + +struct t_struct { + char v_char_member; + short v_short_member; + int v_int_member; + long v_long_member; +#ifndef NO_LONG_LONG + long long v_long_long_member; +#endif + float v_float_member; + double v_double_member; +} v_struct1, *v_struct_ptr1; + +struct { + char v_char_member; + short v_short_member; + int v_int_member; + long v_long_member; +#ifndef NO_LONG_LONG + long long v_long_long_member; +#endif + float v_float_member; + double v_double_member; +} v_struct2, *v_struct_ptr2; + +/**** unions *******/ + +union t_union { + char v_char_member; + short v_short_member; + int v_int_member; + long v_long_member; +#ifndef NO_LONG_LONG + long long v_long_long_member; +#endif + float v_float_member; + double v_double_member; +} v_union, *v_union_ptr; + +union { + char v_char_member; + short v_short_member; + int v_int_member; + long v_long_member; +#ifndef NO_LONG_LONG + long long v_long_long_member; +#endif + float v_float_member; + double v_double_member; +} v_union2, *v_union_ptr2; + +/*** Functions returning type ********/ + +char v_char_func () { return(0); } +signed char v_signed_char_func () { return (0); } +unsigned char v_unsigned_char_func () { return (0); } + +short v_short_func () { return (0); } +signed short v_signed_short_func () { return (0); } +unsigned short v_unsigned_short_func () { return (0); } + +int v_int_func () { return (0); } +signed int v_signed_int_func () { return (0); } +unsigned int v_unsigned_int_func () { return (0); } + +long v_long_func () { return (0); } +signed long v_signed_long_func () { return (0); } +unsigned long v_unsigned_long_func () { return (0); } + +#ifndef NO_LONG_LONG +long long v_long_long_func () { return (0); } +signed long long v_signed_long_long_func () { return (0); } +unsigned long long v_unsigned_long_long_func () { return (0); } +#endif + +float v_float_func () { return (0.0); } +double v_double_func () { return (0.0); } + +/**** Some misc more complicated things *******/ + +struct link { + struct link *next; +#ifdef __STDC__ + struct link *(*linkfunc) (struct link *self, int flags); +#else + struct link *(*linkfunc) (); +#endif + struct t_struct stuff[1][2][3]; +} *s_link; + +union tu_link { + struct link *next; +#ifdef __STDC__ + struct link *(*linkfunc) (struct link *self, int flags); +#else + struct link *(*linkfunc) (); +#endif + struct t_struct stuff[1][2][3]; +} u_link; + +struct outer_struct { + int outer_int; + struct inner_struct { + int inner_int; + long inner_long; + }inner_struct_instance; + union inner_union { + int inner_union_int; + long inner_union_long; + }inner_union_instance; + long outer_long; +} nested_su; + +/**** Enumerations *******/ + +enum colors {red, green, blue} color; +enum cars {chevy, ford, porsche} clunker; + +/***********/ + +int main () +{ + /* Some linkers (e.g. on AIX) remove unreferenced variables, + so make sure to reference them. */ + v_char = 0; + v_signed_char = 1; + v_unsigned_char = 2; + + v_short = 3; + v_signed_short = 4; + v_unsigned_short = 5; + + v_int = 6; + v_signed_int = 7; + v_unsigned_int = 8; + + v_long = 9; + v_signed_long = 10; + v_unsigned_long = 11; + +#ifndef NO_LONG_LONG + v_long_long = 12; + v_signed_long_long = 13; + v_unsigned_long_long = 14; +#endif + + v_float = 100.0; + v_double = 200.0; + + + v_char_array[0] = v_char; + v_signed_char_array[0] = v_signed_char; + v_unsigned_char_array[0] = v_unsigned_char; + + v_short_array[0] = v_short; + v_signed_short_array[0] = v_signed_short; + v_unsigned_short_array[0] = v_unsigned_short; + + v_int_array[0] = v_int; + v_signed_int_array[0] = v_signed_int; + v_unsigned_int_array[0] = v_unsigned_int; + + v_long_array[0] = v_long; + v_signed_long_array[0] = v_signed_long; + v_unsigned_long_array[0] = v_unsigned_long; + +#ifndef NO_LONG_LONG + v_long_long_array[0] = v_long_long; + v_signed_long_long_array[0] = v_signed_long_long; + v_unsigned_long_long_array[0] = v_unsigned_long_long; +#endif + + v_float_array[0] = v_float; + v_double_array[0] = v_double; + + v_char_pointer = &v_char; + v_signed_char_pointer = &v_signed_char; + v_unsigned_char_pointer = &v_unsigned_char; + + v_short_pointer = &v_short; + v_signed_short_pointer = &v_signed_short; + v_unsigned_short_pointer = &v_unsigned_short; + + v_int_pointer = &v_int; + v_signed_int_pointer = &v_signed_int; + v_unsigned_int_pointer = &v_unsigned_int; + + v_long_pointer = &v_long; + v_signed_long_pointer = &v_signed_long; + v_unsigned_long_pointer = &v_unsigned_long; + +#ifndef NO_LONG_LONG + v_long_long_pointer = &v_long_long; + v_signed_long_long_pointer = &v_signed_long_long; + v_unsigned_long_long_pointer = &v_unsigned_long_long; +#endif + + v_float_pointer = &v_float; + v_double_pointer = &v_double; + + color = red; + clunker = porsche; + + u_link.next = s_link; + + v_union2.v_short_member = v_union.v_short_member; + + v_struct1.v_char_member = 0; + v_struct2.v_char_member = 0; + + nested_su.outer_int = 0; + return 0; +} -- 1.8.3.1