From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id lRpAIZOAPmCVQwAAWB0awg (envelope-from ) for ; Tue, 02 Mar 2021 13:14:43 -0500 Received: by simark.ca (Postfix, from userid 112) id 7A8A11EF78; Tue, 2 Mar 2021 13:14:43 -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,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 0908F1E590 for ; Tue, 2 Mar 2021 13:14:43 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F8823950C79; Tue, 2 Mar 2021 18:14:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F8823950C79 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614708882; bh=GNELxG66T7h+oGuUfw5sft8H4Fe8S82iZuzsggK5Otc=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=m+rjNoaq6E6JBDVbUgH/Njn/sfyorbwCmV1gdiI3B2BZ7tDRcC5FtlfQ5jTaB8hl7 s8oPq3n59GVpw73HX28q+c0e/HmyiC816iUpwot/2ue/2625c4+YZSZRKOmttk41sD 3M3LbMiQdqj8kLE9Ipmz+4RAaB33TyMoWrYkr8m0= Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by sourceware.org (Postfix) with ESMTPS id 1F3423950C76 for ; Tue, 2 Mar 2021 18:14:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1F3423950C76 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 122I9PNR049828; Tue, 2 Mar 2021 18:12:36 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2130.oracle.com with ESMTP id 36ybkb8ryr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Mar 2021 18:12:36 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 122I51NY193314; Tue, 2 Mar 2021 18:12:35 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 37000088s3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 02 Mar 2021 18:12:35 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 122ICYUB000658; Tue, 2 Mar 2021 18:12:34 GMT Received: from [10.159.244.233] (/10.159.244.233) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 02 Mar 2021 18:12:34 +0000 Subject: Re: [PATCH,V2 2/5] CTF: set up debug info for function arguments To: Lancelot SIX References: <1614650018-9135-1-git-send-email-weimin.pan@oracle.com> <1614650018-9135-2-git-send-email-weimin.pan@oracle.com> <1614650018-9135-3-git-send-email-weimin.pan@oracle.com> Message-ID: <418217bc-16b2-f249-27fc-37685579f47a@oracle.com> Date: Tue, 2 Mar 2021 10:12:31 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9911 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103020141 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9911 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=1011 mlxlogscore=999 adultscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103020141 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: Wei-min Pan via Gdb-patches Reply-To: Wei-min Pan Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 3/2/2021 4:23 AM, Lancelot SIX wrote: > Hi, > > I just have style related comments bellow. > > Le Mon, Mar 01, 2021 at 08:53:35PM -0500, Weimin Pan via Gdb-patches a écrit : >> 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; > Could be nullptr instead of NULL (even if I am not sure the standard > enforces that). nullptr of std::nullptr_t, which is implicitly converted to null pointer value of any pointer type, seems more appropriate. Will do the necessary changes in other places too. > >> + >> + 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) > An explicit comparison against nullptr should be done here. See > https://urldefense.com/v3/__https://sourceware.org/gdb/wiki/Internals*20GDB-C-Coding-Standards*Comparison_With_NULL_And_Zero__;JSM!!GqivPVa7Brio!IXhIALJgGrsPK1dDbwNKp69KxLTd4Msy6ShNy9Euo18QeN2Iz4dEBg2rhM_3eUmx$ OK, will do. Thank you for your comments. > Thanks, > Lancelot. > >> + 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 >>