From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 47E4C3858D1E for ; Wed, 16 Mar 2022 15:18:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 47E4C3858D1E Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-yFPOxzPUOkmqvYfqCCihgA-1; Wed, 16 Mar 2022 11:18:47 -0400 X-MC-Unique: yFPOxzPUOkmqvYfqCCihgA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C4CC8D3765; Wed, 16 Mar 2022 15:18:47 +0000 (UTC) Received: from [10.97.116.47] (ovpn-116-47.gru2.redhat.com [10.97.116.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25C8B400E55A; Wed, 16 Mar 2022 15:18:45 +0000 (UTC) Message-ID: <4a9fc5ba-2053-f0ee-5ef7-450dfaf69d83@redhat.com> Date: Wed, 16 Mar 2022 12:18:42 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2 1/2] gdb/regcache: return REG_UNAVAILABLE if raw_update raises NOT_AVAILABLE_ERROR To: Tankut Baris Aktemur , gdb-patches@sourceware.org References: From: Bruno Larsen In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 16 Mar 2022 15:18:51 -0000 Hello Tankut, On 2/8/22 06:15, Tankut Baris Aktemur via Gdb-patches wrote: > In regcache's raw_read, it is possible that 'raw_update' fails with an > exception. Catch this exception and return REG_UNAVAILABLE if the > error is of kind NOT_AVAILABLE_ERROR. This makes clients' lives easier. This looks like a good idea for a change. I just have a few small comments. Firstly, I'm not sure this change is complex enough to warrant its own commit, since - from what I can see - there is no noticeable change in GDB, and the patch itself is quite small, it could maybe just be part of patch 2. However, I am not a global maintainer or very experienced in patch review, so take this comment with a grain of salt. If the commits do stay separate, I would add a mention of raw_read in the commit title, otherwise which function is returning REG_UNAVAILABLE is not mentioned at all. Also, the commit message is not very descriptive of what could cause the exception in the first place, and I feel like that could be good for future reference, but this may just be my GDB inexperience speaking. > > Regression-tested on X86_64-Linux. > --- > gdb/regcache.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/gdb/regcache.c b/gdb/regcache.c > index 00d7a10e289..0379e6a8d0f 100644 > --- a/gdb/regcache.c > +++ b/gdb/regcache.c > @@ -598,7 +598,16 @@ enum register_status > readable_regcache::raw_read (int regnum, gdb_byte *buf) > { > gdb_assert (buf != NULL); > - raw_update (regnum); > + try > + { > + raw_update (regnum); > + } > + catch (const gdb_exception_error &ex) > + { > + if (ex.error == NOT_AVAILABLE_ERROR) > + return REG_UNAVAILABLE; Lastly, Since this function is returning as if nothing unexpected happened, it should probably also set buf to 0 and possibly set m_register_status to REG_UNAVAILABLE - if it isn't set by whatever throws the exception. > + throw;> + } > > if (m_register_status[regnum] != REG_VALID) > memset (buf, 0, m_descr->sizeof_register[regnum]); -- Cheers! Bruno Larsen