From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uAi8AKvr0GDhRAAAWB0awg (envelope-from ) for ; Mon, 21 Jun 2021 15:42:35 -0400 Received: by simark.ca (Postfix, from userid 112) id 00CBF1F1F2; Mon, 21 Jun 2021 15:42:34 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4714A1E54D for ; Mon, 21 Jun 2021 15:42:34 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1457E393AC12 for ; Mon, 21 Jun 2021 19:42:34 +0000 (GMT) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id C7298385701F for ; Mon, 21 Jun 2021 19:42:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C7298385701F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x333.google.com with SMTP id t11-20020a1cc30b0000b02901cec841b6a0so467386wmf.0 for ; Mon, 21 Jun 2021 12:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FXbw51/5WPE9+CwEPfU+gEPo8mAmNOSXjD3id407Wno=; b=MBYhdUaFX0vRyDtnkDN4BEvJ1dnow/DgoEX87MjIriVp/5f6LjChj8f0GYAi5VmLuQ QKXTKhG6X4OjD7p2mHNVakZH0k04UiqKFYt7WShwyi/L58fqSMDDibfdpikt5xQwZO+E S8bCja/OxHvjVlpq1STV6r6OSnlaPDrPIFmtb/p/L37kmeHU8iF3lzEPdqV+E2T9ZYnt DymvgbKxEJGtQNWJIVWZdSVPBCuI+Qkp3H9qtYSDrc4tWsFxJVArKOus8kc87737uXbj unKGGUbSccaOGYA5lj5gBG6abTBgkXu3ZBSOEJ07j3JjEooAqvl2CnCvXgt+0Z0efYiu BHrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FXbw51/5WPE9+CwEPfU+gEPo8mAmNOSXjD3id407Wno=; b=IgYWX22f6oq8r8MMNPrh6TkA74tEcpiCRSY4pGGvl0A79GAbrgmjP+6hzdWwhgUapv F+jogYYwUHDF8pklf8Jxxrkh+VeAuNUF6nRNE/usG1lQoDmH3vgIhWK3QFaKC5B8QLVT FqeIlPpd8lM/rZFTZXiqc6FC3nLrkZ4HBtVnaAJvTkG/5ON2VMrsjdVbyV4KBYm5EdML cGz/EE/waMUb2JkhJ5+YgfaC6I1xWZ2/z5auf4P8mBMeYhO0VRV6OyQUZIn8JED91UJD QCbXeeFBXgkwCoG7RQM+BSQV5lzgIQOJ+vvVoo/gBS30ZWMWOpGafoSqckgpfdh3d1FO roOA== X-Gm-Message-State: AOAM533gM5jX1RMDklXke2KEQlkbjbo3fPdVZ32EHkWDRWjF0CvhoYit 89J+f8KcbMtUWFJGhoSFVWQuA9SBpebGPpZn X-Google-Smtp-Source: ABdhPJw4NsREzEosi67h71iNTIx/cWCUE9wQK1HRbxXxFaE/2AwhBjAKwhbN6T9C8vRrTyGJfw/9fQ== X-Received: by 2002:a05:600c:1d13:: with SMTP id l19mr126585wms.134.1624304541686; Mon, 21 Jun 2021 12:42:21 -0700 (PDT) Received: from localhost (host86-140-92-85.range86-140.btcentralplus.com. [86.140.92.85]) by smtp.gmail.com with ESMTPSA id n18sm18031715wmq.41.2021.06.21.12.42.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 12:42:21 -0700 (PDT) Date: Mon, 21 Jun 2021 20:42:20 +0100 From: Andrew Burgess To: gdb-patches@sourceware.org Subject: Re: [PATCH 2/5] gdb/python: move PyLong_From* calls into py-utils.c Message-ID: <20210621194220.GG2568@embecosm.com> References: <2e8e11d00b1eea71a99a49d5860deb3392372c91.1622321523.git.andrew.burgess@embecosm.com> <8735ttn2tb.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8735ttn2tb.fsf@tromey.com> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 20:41:19 up 5 days, 3:32, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] 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: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" * Tom Tromey [2021-06-07 08:53:52 -0600]: > >>>>> "Andrew" == Andrew Burgess writes: > > Andrew> gdb/ChangeLog: > > Andrew> * python/py-inferior.c (infpy_get_connection_num): Call new > Andrew> function gdb_py_object_from_int. > Andrew> * python/py-utils.c (gdb_py_object_from_int): New function. > Andrew> * python/python-internal.h (gdb_py_object_from_int): Declare. > > This seems fine to me. > > It would also probably be ok to just rely on promotion and always use > gdb_py_object_from_longest. I took this advice and pushed the patch below. Thanks, Andrew --- commit 8b9c48b287d42d1c816f441e4273dcb8c7af1876 Author: Andrew Burgess Date: Wed May 26 21:28:11 2021 +0100 gdb/python: move PyLong_From* calls into py-utils.c We already have two helper functions in py-utils.c: gdb_py_object_from_longest (LONGEST l) gdb_py_object_from_ulongest (ULONGEST l) these wrap around calls to either PyLong_FromLongLong, PyLong_FromLong, or PyInt_From_Long (if Python 2 is being used). There is one place in gdb/python/* where a call to PyLong_FromLong was added outside of the above utility functions, this was done in the recent commit: commit 55789354fcbaf879f3ca8475b647b2747dec486e Date: Fri May 14 11:56:31 2021 +0200 gdb/python: add a 'connection_num' attribute to Inferior objects In this commit I replace the direct use of PyLong_FromLong with a call to gdb_py_object_from_longest. The only real change with this commit, is that, for Python 2, we will now end up calling PyInt_FromLong instead of PyLong_FromLong, but this should be invisible to the user. For Python 3 there should be absolutely no change. gdb/ChangeLog: * python/py-inferior.c (infpy_get_connection_num): Call gdb_py_object_from_longest instead of PyLong_FromLong directly. diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 336c6426b8c..39efa804d80 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -441,7 +441,7 @@ infpy_get_connection_num (PyObject *self, void *closure) if (target == nullptr) Py_RETURN_NONE; - return PyLong_FromLong (target->connection_number); + return gdb_py_object_from_longest (target->connection_number).release (); } static PyObject *