From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id FyEMOG7OWmhedhwAWB0awg (envelope-from ) for ; Tue, 24 Jun 2025 12:12:30 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=t+wM/wH4; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D21791E11C; Tue, 24 Jun 2025 12:12:30 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1F0C11E0C2 for ; Tue, 24 Jun 2025 12:12:30 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D311B3852762 for ; Tue, 24 Jun 2025 16:12:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D311B3852762 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=t+wM/wH4 Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id 49EE33852104 for ; Tue, 24 Jun 2025 16:11:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49EE33852104 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 49EE33852104 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750781515; cv=none; b=eAB5cbnpg6Cg6Z+KkaFe8Oky2bmx+/X8vYU3dD3OzqvqdaElIOyHDKfSlBxSMlJaD32D0e95R7ls/FwsTyCjobdcxTnF9+ZpIe1qUvhCTbHE8E7Jgom3Tc9ODLD+/NU/WyXT/arFyZJnh84PadHIiEd6W33LqARKZNNFRPK7QUk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750781515; c=relaxed/simple; bh=lLuaJ/VNAuGQtgOhJLgz0VuZV+dpKXXRlOUVNFo/4eQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YsJLIaxVWV6Ql8+bSZbnviJsQLGGlQ+qFDWQK2RBOrS+uigSpfuoxQrUXNKfPz7xT/9FbK+zsu8wsvagCe9Kf+aG7Bx2g3P6KfHQrImBlfW1Hc52JAkj0NEXHnioPvaiqZP/MRgFKznbzZLGs3gzKiT98TqeNb/qK17jgdPVedo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49EE33852104 Received: from eig-obgw-6003a.ext.cloudfilter.net ([10.0.30.151]) by cmsmtp with ESMTPS id TuyvuzOHQXshwU6FWuZbRp; Tue, 24 Jun 2025 16:11:54 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id U6FVuNVxHh9ZxU6FVuBcpL; Tue, 24 Jun 2025 16:11:54 +0000 X-Authority-Analysis: v=2.4 cv=GODDEfNK c=1 sm=1 tr=0 ts=685ace4a a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=6IFa9wvqVegA:10 a=ItBw4LHWJt0A:10 a=TDl5R864AAAA:8 a=s9RQ4IMTfNCjrAVvZZ0A:9 a=qk2G_s147oCGCk26iTO3:22 a=4IKI_MBedZsHOhguCAbN:22 a=VS4QxaUSPT0UtbFnIvSC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RzJY+jST52L+fIvEXJlsDD+Rwd++0KeX0EpRGQIe++g=; b=t+wM/wH4vXNOnIlDNFlBmyFC0W 5vRaigYL6JlDnswnZONKdcoMha8XqhtQC/diOkfgyVZ0B1a/UZ51H5YwBG+MeKLOIolPg8EHcq4wh ynRXgI5FtNqrydYSz8C2puPfc; Received: from 97-118-59-152.hlrn.qwest.net ([97.118.59.152]:36654 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1uU6FU-00000003PNG-3AA8; Tue, 24 Jun 2025 10:11:52 -0600 From: Tom Tromey To: Jan Vrany Cc: gdb-patches@sourceware.org, Eli Zaretskii Subject: Re: [RFC v5 05/18] gdb/python: add function () method to gdb.Type object In-Reply-To: <20250623161013.650814-6-jan.vrany@labware.com> (Jan Vrany's message of "Mon, 23 Jun 2025 17:10:00 +0100") References: <20250623161013.650814-1-jan.vrany@labware.com> <20250623161013.650814-6-jan.vrany@labware.com> X-Attribution: Tom Date: Tue, 24 Jun 2025 10:11:50 -0600 Message-ID: <87y0thxgop.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.118.59.152 X-Source-L: No X-Exim-ID: 1uU6FU-00000003PNG-3AA8 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-59-152.hlrn.qwest.net (bapiya) [97.118.59.152]:36654 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfE2fNa7zVDUvq6Mr9XFB/FbsIr3WbCQFcqRKMwhPf6IqRfdMjq4HbPa1yOVr7ISPObZ6Q0OCjGKYZXIrcG+TF8UeHRcQ2FnDDp6pTPc7WcqEoZcvmuPK 1mQQV3U1pWtZ5fhO6OE2m/Ktj3cquU8O/ZHnn1uOqESiZzhQmBwKwqvaUbFVrmhENZuTHtayV4DQCgc61eGST6ygWhqDA7aMYtQ= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org >>>>> "Jan" == Jan Vrany writes: Jan> +/* See gdbtypes.h. */ Jan> + Jan> +bool Jan> +type::is_void () Jan> +{ Jan> + return check_typedef (this)->code () == TYPE_CODE_VOID; Jan> +} This should be moved to the earlier patch that calls it. Jan> +const std::string Jan> +type::printable_name () const Jan> +{ This isn't called in this patch but I don't think it really matters as long as it's used eventually. Jan> + string_file thetype; Jan> + Jan> + current_language->print_type (const_cast(this), "", Space before "(this)" Jan> + param_types[i] = type_object_to_type (param_type_obj); Jan> + if (param_types[i] == nullptr) Jan> + { Jan> + PyErr_Format (PyExc_TypeError, Jan> + _("Argument at index %d is %s, not a gdb.Type " Jan> + "object."), Jan> + i, Py_TYPE (param_type_obj)->tp_name); Jan> + return nullptr; It's kind of lame that we don't have a type_object_to_type_checked variant. Jan> + if (param_types[i]->is_void ()) Can check_typedef throw an exception? If so this must be wrapped in a try/catch. That's a good practice for all calls into gdb anyway, because things like this may change over time. Jan> + if (kw != nullptr) Jan> + { Jan> + if (!PyDict_Check (kw)) Jan> + { Jan> + PyErr_Format (PyExc_ValueError, Jan> + _("Arguments is %s, not a dict."), Jan> + Py_TYPE (args)->tp_name); Jan> + return nullptr; Jan> + } Jan> + This code should probably call PyArg_ValidateKeywordArguments. I don't know whether that includes the PyDict_Check on its own. Jan> + /* Copy all objfile-owned types to arch. This way user does not Jan> + need to care about mixing types from different objfiles and Jan> + architectures and we do not need to expose this implementation Jan> + detail to the user. */ Jan> + Jan> + copied_types_hash_t copied_types; Jan> + return_type = copy_type_recursive (return_type, copied_types); This whole block should probably be wrapped in a try/catch. Jan> + function_type = lookup_function_type_with_arguments Jan> + (return_type, param_types.size (), param_types.data ()); May be mildly nicer to use an array_view here. Jan> + gdb_test "python print(repr(int_t.function(varargs=True)))" \ Jan> + "" Jan> + Jan> + gdb_test "python print(repr(int_t.function(varargs=False)))" \ Jan> + "" Seems weird that these print the same thing. Tom