From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id x1zzLLtVvmAcQwAAWB0awg (envelope-from ) for ; Mon, 07 Jun 2021 13:22:03 -0400 Received: by simark.ca (Postfix, from userid 112) id B06B31F163; Mon, 7 Jun 2021 13:22:03 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.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 EADE81E939 for ; Mon, 7 Jun 2021 13:22:02 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55EA33892454 for ; Mon, 7 Jun 2021 17:22:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55EA33892454 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623086522; bh=krEL49eGsZVYVShBLrfvI9L2rohat1YsrCiP88oz0bA=; 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=B1k/PHLfTcvx6uzI/OemXz/N/i5fOE4P3whcDRFTRFNUUBaNR4gFw1cfR+T+cKUfG l59y9nFGGdylCbxDCkfGOqbXREm+/RWW3M7PYuq33IquIGdxoSK9uUEIUyIqmu+1SF CPY0I73Zk44INb0xCr2I6JCMO80J7e5xI1XsulC8= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 9FBC5389043D for ; Mon, 7 Jun 2021 17:21:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9FBC5389043D Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 157HKYi2022817 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 7 Jun 2021 13:20:39 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 157HKYi2022817 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 528831E939; Mon, 7 Jun 2021 13:20:34 -0400 (EDT) Subject: Re: [PATCH 1/5] gdb/python: handle saving user registers in a frame unwinder To: Lancelot SIX , Andrew Burgess References: <20210607170710.a2dtukyyjjxwzmes@Plymouth> Message-ID: Date: Mon, 7 Jun 2021 13:20:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210607170710.a2dtukyyjjxwzmes@Plymouth> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 7 Jun 2021 17:20:34 +0000 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: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2021-06-07 1:07 p.m., Lancelot SIX via Gdb-patches wrote: > Hi, > > I just have a minor stylistic remark in the python code in the test: > >> […] >> + >> + def __call__(self, pending_frame): >> + pc_desc = pending_frame.architecture().registers().find("pc") >> + pc = pending_frame.read_register(pc_desc) >> + >> + sp_desc = pending_frame.architecture().registers().find("sp") >> + sp = pending_frame.read_register(sp_desc) >> + >> + block = gdb.block_for_pc(int(pc)) >> + if block == None: > > When looking for None, it is usually prefered to use 'is None' instead > of '== None'. The result is the same unless there is a strange overload > of __eq__. > > This pattern can also be seen in patch 3 and 4 of your series (patch 4 > using both '==' and 'is' to check for None). I agree, that's the convention in Python. It is not in our coding standards, but I suggest using flake8 to check the Python code, it reports this (and much more): $ flake8 testsuite/gdb.python/py-unwind-user-regs.py testsuite/gdb.python/py-unwind-user-regs.py:52:18: E711 comparison to None should be 'if cond is None:' testsuite/gdb.python/py-unwind-user-regs.py:55:17: E711 comparison to None should be 'if cond is None:' Simon