From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mCyRBMKaPWA3MAAAWB0awg (envelope-from ) for ; Mon, 01 Mar 2021 20:54:10 -0500 Received: by simark.ca (Postfix, from userid 112) id 0F86E1EF78; Mon, 1 Mar 2021 20:54:10 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A99E21E793 for ; Mon, 1 Mar 2021 20:54:09 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4FEB0393BC3D; Tue, 2 Mar 2021 01:54:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4FEB0393BC3D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614650049; bh=wXQOVd2oGYf8Xy00xK02H8SzKUcrrqqCqoeVzK8r/RA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RIRwF90wh/+QhszjVgN/6ZHazfRnz1C9xaObfzeTfwGhWG6uWrRCJ+pzGRiPChwxt R1NLuxQ6ecbZKF0ghL1ueyUwGSTPJEq8DeReUKaXHZxXcZ4VvWRaBql7fbUEWAgMSt ys5qoUZKCA2cmW31bCDlD4Xx70eDM1yCw3TnZjw0= Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by sourceware.org (Postfix) with ESMTPS id 0CD99393BC3D for ; Tue, 2 Mar 2021 01:54:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0CD99393BC3D Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 1221s5UZ085938 for ; Tue, 2 Mar 2021 01:54:05 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 36ydgr5wj5-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 1221oVto066218 for ; Tue, 2 Mar 2021 01:54:05 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-2 (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=Npx4/4xQ06T1z2FQ5Xp7XNErvTrsXxiSWuhz1QBJoMMmhClZno3z8oJXempIa/92P3gi3qE42I5uev7jWiY9dFE6DuGVNZDmgQeX7INJX2NVhnrcovG5k9plnQNkOxOtjHmFgSE1PQ27h2metwGSqKjtIhk+O77T5SzJ2gqtF2IoqK9tkcTIwqSgh/xkOEnzE/+gTZ7RT9K0FNJMtDtSJueYncwtlp1vh7zy6q+vGHCEiWXEMDxtfKfpYdW7dTbb5TapAi2rVG+E5f13HIRf+RR9s3akobn/hhouTsWeYlhHXvDl+dBIoBRz8FFEimQqGO1Prhl7bI/Kb07q7Q51eA== 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=wXQOVd2oGYf8Xy00xK02H8SzKUcrrqqCqoeVzK8r/RA=; b=AIjMwHJzl5UOTpuSK/GQnzSDGfJ4S4rIYGOQCAfNp1U4Wo4O/x8BZZmvsD6jY0m3pG27whjzr8XR1ykhG9GGWhb41IfpvWbxhJGzzIRraHthBgrg4edN5UJC4cB3ov5752Gg1L8o2J800VW9/uYy7ItLkWE88HubzkdjbzY2qE/sF17c/JwJxHRvglJRN2rVWzPvzMaf3VvjA4j1zg4TKv0OVnM2Elv2qeKx84iOhoF5WPtgSZ18idb9tXYfWNl0kgDAWHeX/eyX3s5RGgwEHYUkuOCfhSpOIuwtdYtCUp8UW7+eCJBRZfYgYNFLs8xOu/FugwUngkoKtKALbiRQjg== 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 To: gdb-patches@sourceware.org Subject: [PATCH,V2 2/5] CTF: set up debug info for function arguments Date: Mon, 1 Mar 2021 20:53:35 -0500 Message-Id: <1614650018-9135-3-git-send-email-weimin.pan@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614650018-9135-2-git-send-email-weimin.pan@oracle.com> References: <1614650018-9135-1-git-send-email-weimin.pan@oracle.com> <1614650018-9135-2-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:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78415f0c-6587-4301-43ec-08d8dd1e0de2 X-MS-TrafficTypeDiagnostic: BN0PR10MB5383: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0ABIa9FBu7qqF3eCROK6VE8eXXSnjGfQTlGWrX5GMUTac6erYgXP/5SvMbJVLBntYmsgl57MJRMrWns4wLvi/ac8thxhb6OhMIOcevg2TJ3gGUaVBdhqSh6NLfgX0H6MaKxS1VZeLXZ/N0UGVyfz4Z0zLpYtA/b0AInY4kEW0seSDKQVPvKXNz7D18aPa2SUPYx64V/qfGmNnquWh7mMSwPIqiji0sRJ+1DJsLM0G8vMBuNcR9RCYzh5RhG2DO/DhFSWryAC4gBgxFl+11iHGvGNoY1sOw6ygaanrOnaTGqpJQafe7bYQ3e6bBUibR/gbvgsoL9tgFAGkA4ocwOsZUC2M7XE4UJ1T3eFyo+mq2XLhWYBmv71B4kqVYf5syPg4XRi156Osc/pbU0e1EeNIJCW5WLav5MjnJWA1ilFK6Ub6dQhBQynrZCuVtWBOLo289jBuH7u8RiEGfMUb7VcZrd9y4snWO6a0EVLkZiYI/W9p4a/GhS102bY+n0BF0lrkBDQB6o7af+m/mUd98djIA== 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)(66946007)(16526019)(66556008)(66476007)(6666004)(316002)(83380400001)(6486002)(44832011)(956004)(8676002)(5660300002)(2616005)(2906002)(8936002)(6916009)(478600001)(36756003)(7696005)(52116002)(86362001)(26005)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?B2MAfYfvAgRk/3chVZLU7XMYaPwI8KNIcmp6UJ/vlDZ212obRA/w7H2kP1rS?= =?us-ascii?Q?5aSjyVQ3unmdXRiHFyFzrR4iSgJAVLT4t08DvNByKgvzbyBqjfkAGCdQWJ41?= =?us-ascii?Q?VJk/Flx+EXwRPE4OBKmrmhqN67URTcF2sPrXGkIfo3k1mM7VbG2B9qpMYVJ2?= =?us-ascii?Q?OzDvdQn+sC8IibJrWUshgVESfp/SAmV3rISU1hpxMWpENV37ApAzzLAZ2aAK?= =?us-ascii?Q?hnzhgxUSNyt0DfGAB6wQh4eablN6xVrc9tTgjcVD7F2NiMx2uWeiODXo3e0L?= =?us-ascii?Q?Xk32wGWzWT6KpRlLjR07k07N9ftL9B5rbeYTOPW+rozCRcdSU7CTn5HpSiVu?= =?us-ascii?Q?6Fpb75I+cmUFbA9YZU1nL9y7zbXHn08E84MwaOKLzx/4hFjuM67h5148SvWr?= =?us-ascii?Q?6E1A9wggXkQ33UiE5qRXcsDt5SvU/Sfpg8cvc8bKCSiLHmn0G04hakWPfLVu?= =?us-ascii?Q?78YFi1NQZhK6ZAwkRERNNZmw5qaQq12nBXaEPcTAy7xjcA2THLpN6N8AaErb?= =?us-ascii?Q?RkgLFzky9G9KdxeOcofHwcUdloc9mMgKSfxwLTMwNX/0llhrJo8jJstmEmjw?= =?us-ascii?Q?dHxrSxz4izB6Kq59A5ouTVLL1yB7h74Pid7x9RkbRYzh0twunkihMaZGH3vt?= =?us-ascii?Q?Iwrff19zdWvub+Qn9BGO293uo7D+MQH+uwGPaLqILGFjyYIT7lMIGlYdBQaV?= =?us-ascii?Q?UKcWCaaB7TjooYXA0ktYEhOuT0iHhqXyx5J7HWg47WiloCGCugBW38vw2hSY?= =?us-ascii?Q?hAr+UKB/CG9trUq7naEip+01OgjaQSctUyf4oQrjBazkI5tDGpGSGOJCVuNE?= =?us-ascii?Q?fNaGx8xXZnAgX98H5sreVwOXghXderW5WBjtJZu0AA9rg+wXYTfVF2AouAn5?= =?us-ascii?Q?IovTNRC1XoFBMUnFEEuSAvxYvhRpxXDeg8o13f1vP6APn1ZR/0K7mf1rJgc+?= =?us-ascii?Q?MEFwdGkUvOHYnbH6ft4Rye42sbRzkd5vyIk21L30wbcR2reRAa+17uT8Nwaa?= =?us-ascii?Q?9JwlcgxLGuSzz0/TFoLUcC8MicOTtDRewriAvy9ovTLunG/pcVNTl4a15C6Q?= =?us-ascii?Q?+fYpxUcFg1xa2Yga5O9K2NJZMu1qvU6NICVRXXH91KaiwCj44OKEJdUYyi0Y?= =?us-ascii?Q?G8dIqtQkqp9xaBZmlXJYe/Nlrc/9da/roiHjIzCaiDblmCAqSs5HU6LqEW5S?= =?us-ascii?Q?5cPDQLPI6xPLOXu/7CtPkvgcdfKJwGNdkmYIxPrUFY8zArdJ+koAlS0surVm?= =?us-ascii?Q?ZXmyFCoEDLmcsGaDMWj9b2xXtwR1xFGgTjpJIz+NV02aKN7rMXQEwQ2iHlZM?= =?us-ascii?Q?ZWFasMF4PONOrsb1yTf7YJgH?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78415f0c-6587-4301-43ec-08d8dd1e0de2 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:02.8053 (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: msW7ZulfgtDBEBXHKmkqflRseU6N4Bgs3QMc818WNB7CC0QWA82K8zSdN+PnAhCHVPpvmvxXlyckG9xdWHhWnw== 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 adultscore=0 impostorscore=0 clxscore=1015 suspectscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103020012 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: , From: Weimin Pan via Gdb-patches Reply-To: Weimin Pan Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Added this support in read_func_kind_type after gcc started generating CTF for function arguments. Expanded gdb.base/ctf-ptype.exp to test function arguments. Also fixed some typos. --- gdb/ChangeLog | 4 ++++ gdb/ctfread.c | 29 ++++++++++++++++++++++++++++- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/ctf-ptype.exp | 19 ++++++++++++++++--- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 88278d1..0a839ba 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2021-02-26 Weimin Pan + * ctfread.c (read_func_kind_type): Set up function arguments. + +2021-02-26 Weimin Pan + * ctfread.c (new_symbol): Set function address. (read_func_kind_type): Remove incorrect type name setting. diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 5a68d9c..75b098c 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -652,8 +652,9 @@ struct ctf_tid_and_type { struct objfile *of = ccp->of; ctf_dict_t *fp = ccp->fp; - struct type *type, *rettype; + struct type *type, *rettype, *atype; ctf_funcinfo_t cfi; + uint32_t argc; type = alloc_type (of); @@ -663,6 +664,32 @@ struct ctf_tid_and_type TYPE_TARGET_TYPE (type) = rettype; set_type_align (type, ctf_type_align (fp, tid)); + /* Set up function's arguments. */ + argc = cfi.ctc_argc; + type->set_num_fields (argc); + if (cfi.ctc_flags & CTF_FUNC_VARARG) + type->set_has_varargs (true); + + if (argc != 0) + { + std::vector argv (argc); + if (ctf_func_type_args (fp, tid, argc, argv.data ()) == CTF_ERR) + return NULL; + + type->set_fields + ((struct field *) TYPE_ZALLOC (type, argc * sizeof (struct field))); + struct type *void_type = objfile_type (of)->builtin_void; + /* If failed to find the argument type, fill it with void_type. */ + for (int iparam = 0; iparam < argc; iparam++) + { + atype = get_tid_type (of, argv[iparam]); + if (atype) + type->field (iparam).set_type (atype); + else + type->field (iparam).set_type (void_type); + } + } + return set_tid_type (of, tid, type); } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 3d71354..9445362 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2021-02-26 Weimin Pan + * gdb.base/ctf-ptype.exp: Add function tests and fix typos. + +2021-02-26 Weimin Pan + * gdb.base/ctf-funcreturn.exp: New file. 2021-01-29 Tom de Vries diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp index ffe40f1..056f712 100644 --- a/gdb/testsuite/gdb.base/ctf-ptype.exp +++ b/gdb/testsuite/gdb.base/ctf-ptype.exp @@ -63,10 +63,10 @@ gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\] (unsign # Test the equivalence between '.' and '->' for struct member references. -if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then { +if [gdb_test "ptype v_struct1.v_float_member" "type = float"]<0 then { return -1 } -if [gdb_test "ptype v_t_struct_p->v_float_member" "type = float"]<0 then { +if [gdb_test "ptype v_struct1->v_float_member" "type = float"]<0 then { return -1 } if [gdb_test "ptype v_t_struct_p.v_float_member" "type = float"]<0 then { @@ -211,7 +211,7 @@ gdb_test "ptype the_highest" \ gdb_test "ptype the_highest.anonymous_level_1" \ "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \ - "ptype the_highest" + "ptype the_highest.anonymous_level_1" # Print the type of the identifier ID, and check the response: # - Expect to see PROTOTYPED as the type. PROTOTYPED is not a regular @@ -255,8 +255,21 @@ proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" } } } +ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \ + "int (*)()" ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()" \ "double (*)(void)" +ptype_maybe_prototyped "new_fptr" "double (*)()" "double (*)()" +ptype_maybe_prototyped "fptr" "int (*)(int, float)" "int (*)()" +ptype_maybe_prototyped "fptr2" "int *(*)(int (*)(int, float), float)" \ + "int *(*)()" +ptype_maybe_prototyped "xptr" "int (*)(int (*)(), int (*)(), int)" \ + "int (*)()" \ + "int (*)(int (*)(void), int (*)(void), int)" +ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \ + "int (*(*)())()" +ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \ + "int (*(*(*)())())()" # Test printing type of string constants and array constants, but # requires a running process. These call malloc, and can take a long -- 1.8.3.1