From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id pam5J++1sWjGVw8AWB0awg (envelope-from ) for ; Fri, 29 Aug 2025 10:15:11 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aR8xX7Dr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7A16E1E043; Fri, 29 Aug 2025 10:15:11 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no 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 D344A1E043 for ; Fri, 29 Aug 2025 10:15:10 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6E1D43857C6C for ; Fri, 29 Aug 2025 14:15:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E1D43857C6C Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aR8xX7Dr Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 6FC763857BA2 for ; Fri, 29 Aug 2025 14:14:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6FC763857BA2 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6FC763857BA2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756476876; cv=none; b=nGYlSx0Bmj60lKwCyPgqxENkGebdv93W/UegsTVob1tnUfgkUYU0X9066ck9Ec5z5NqafzUx2LRS1Kcl+iDuWCQXSfAbq8kZjA9SwRWo9OcgwJXHV/e7GSgh4+WdUh5yoJD3JHymrD248Q7zGZw462oWaac8w5OOZ8BT0S7w1+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1756476876; c=relaxed/simple; bh=dN+F64mYdhwQOirdZXF4CzgfVK0pomO2m5seo+j4kK0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LoEOqTBvYTGT9TwHyfCpn48O/QyNQ/+TsGVj7AzF55aDlsE3xiLNeC6M4q2QL3VoGeKxOnXR0eDwhZ8d6SHDWTHGTweJl/rnFewOXgyRM8xDVJeoxcofFg3ysmbTz5FnkQsHGonl4e+fmUCkKhJaXilIYwxNPdvOWKN5itMN8vI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FC763857BA2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756476876; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=i+KkkG62E+NF4KTt+cx6DASOIrLj037Z/+602FjONYk=; b=aR8xX7DryV1FpbZE3W0WEHsE7PCFfY4wNrxmw7H8CQLUP8nrw9Uy71bFkbdu10NzlPgF7E xpu128i6OQNrIiMFzAa+bSLvxltdqPV7deI5VZLr/C0fOh0wvqasD+cdFrH2mNK628+LLv KrhY3KYQ+UZFtHsewf8cSLkIrwARIs8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-Wj-NIIycNOeyh6pFym699w-1; Fri, 29 Aug 2025 10:14:34 -0400 X-MC-Unique: Wj-NIIycNOeyh6pFym699w-1 X-Mimecast-MFC-AGG-ID: Wj-NIIycNOeyh6pFym699w_1756476873 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-45a1b0b2b5cso17028445e9.2 for ; Fri, 29 Aug 2025 07:14:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756476873; x=1757081673; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i+KkkG62E+NF4KTt+cx6DASOIrLj037Z/+602FjONYk=; b=brAMCNJ3qX0jJe77adPZpnbBi53nnWYmas0zgRpW+q4VQ0NmX0hbIFtjzI8gyoUs8k L+IfFG2KEzKGDwzq1hR3NftENUwnA4084ki08Fyy274gfM6PBrL6FtU7DFXTKNcy9ROd pQBPqP+mxSRj1wkaM64PR6MdwxYBTPe3Rxir3lGUn3+OAuXZRG06AnqzugsVL4p4DMom 3OmvXhLZyGoi4MsksMl8KxfHYU+jT1P/caMnyeLCzJDgv1NmOX7eMYqbXXsp8Tpf4s45 Kk53BIF6Qurg7gPyzfJzsQJ+oIbagc/s/p6d2Ms7DiyMNMTGmhUU3CyNRaATo55X9T7G KZAw== X-Forwarded-Encrypted: i=1; AJvYcCUk5nYjnSgltqqL/AhtA4HSDNnTL1Y2VBloSQbbu3xuiUeAfSV1nmIk9ZdQhdwzY2jJDDW84nrpMLYrCA==@sourceware.org X-Gm-Message-State: AOJu0YxY2JORc0oB538PQutBwaaqnlrnluJj5gxTVy5dEMrpC5aYnyzf 1KyFbDoWhgCP8tRcGGyi0sNcio/2eEa3FbcO1HoDkZC0/pP+L2JWBtXmrwNx2rvypX1RTwgbSdA pguosRecxtqiKksTiKeJ1r+n7O5IyymOxCxII+TzGMvab78Y8EHIa0m5epIHZqmI= X-Gm-Gg: ASbGncuB6uK+/+4gz6vd9uCXKEHWOsoGDQ6s7PHJ/ctE7CJa+7yx/t7dj5uIKb9OHrp 28fBRJy5uYxZqGMYvZ0q6PXXKkXmIGf7IoxObXz2SFXc+gJF/yp2Rr62EtZs+HV7DLFn8pqmGow yNp57jfa21FtGYhLLh4nGWg8m4ZcyIJekQ/msZG2bS60AjFHyrifVy+Mlo2y7hG2TZ/TPBGesNE 3m06TKFQ9XCbk4mY9N4TxrFV2ckSAsnfn0gJLbuZJ4K1Bl1oMS3bn0Y38M+yzQsaqBj4H3we3io D8R+xL9l/oqjKFIy5CMmyRSrwBgdpvhhRyY= X-Received: by 2002:a05:600c:354f:b0:456:18ca:68db with SMTP id 5b1f17b1804b1-45b6a31a192mr104955255e9.8.1756476873372; Fri, 29 Aug 2025 07:14:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOQHIY7qf32wVHvlFZgOUciMXkI+KVC7t9Rt4XDPvpFre0c2Kfr7tiHdyy2QLga7/az1joog== X-Received: by 2002:a05:600c:354f:b0:456:18ca:68db with SMTP id 5b1f17b1804b1-45b6a31a192mr104954985e9.8.1756476872893; Fri, 29 Aug 2025 07:14:32 -0700 (PDT) Received: from localhost ([31.111.84.207]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3cf34494776sm3512552f8f.61.2025.08.29.07.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Aug 2025 07:14:32 -0700 (PDT) From: Andrew Burgess To: Jan Vrany , gdb-patches@sourceware.org Cc: Jan Vrany , Eli Zaretskii Subject: Re: [RFC v5 14/18] gdb/python: add add_symbol () method to gdb.Block In-Reply-To: <87ecsuqkux.fsf@redhat.com> References: <20250623161013.650814-1-jan.vrany@labware.com> <20250623161013.650814-15-jan.vrany@labware.com> <87ecsuqkux.fsf@redhat.com> Date: Fri, 29 Aug 2025 15:14:31 +0100 Message-ID: <87bjnyqkoo.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mZyrl3bp8LP7ZEi2I13CwmOSQHc52raXT3_Jz3LTcuQ_1756476873 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Andrew Burgess writes: > Jan Vrany writes: > >> This commit adds new method add_symbol () to gdb.Block objects. >> A typical use of it is to add previously instantiated gdb.Symbol object >> to block when interfacing with JIT compiler. >> >> Reviewed-By: Eli Zaretskii >> --- >> gdb/doc/python.texi | 5 +++ >> gdb/python/py-block.c | 52 +++++++++++++++++++++++---- >> gdb/testsuite/gdb.python/py-block.exp | 20 +++++++++++ >> 3 files changed, 71 insertions(+), 6 deletions(-) >> >> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi >> index 709ef7c9d1a..15f851e5fd0 100644 >> --- a/gdb/doc/python.texi >> +++ b/gdb/doc/python.texi >> @@ -6180,6 +6180,11 @@ The new block's @var{start}--@var{end} range must be within superblock's >> range and must not overlap with any block already contained in superblock. >> @end defun >> >> +@defun Block.add_symbol (symbol) >> +Add @var{symbol} to this block. Both the block and the @var{symbol} must >> +belong to the same compunit (@pxref{Compunits In Python}). >> +@end defun >> + >> @defun Block.is_valid () >> Returns @code{True} if the @code{gdb.Block} object is valid, >> @code{False} if not. A block object can become invalid if the block it >> diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c >> index 43b15b6013e..7926808d4db 100644 >> --- a/gdb/python/py-block.c >> +++ b/gdb/python/py-block.c >> @@ -263,6 +263,43 @@ blpy_is_static (PyObject *self, void *closure) >> Py_RETURN_FALSE; >> } >> >> +/* Implementation of gdb.Block.add_symbol (self, symbol). >> + Adds SYMBOL to this block. */ >> + >> +static PyObject * >> +blpy_add_symbol (PyObject *self, PyObject *symbol_obj) >> +{ >> + const struct block *block; >> + >> + BLPY_REQUIRE_VALID (self, block); >> + >> + struct symbol *symbol = symbol_object_to_symbol (symbol_obj); >> + if (symbol == nullptr) >> + { >> + return PyErr_Format (PyExc_TypeError, >> + _("The symbol argument is not valid gdb.Symbol")); >> + } >> + >> + if (symbol->symtab ()->compunit() != block->global_block ()->compunit ()) >> + { >> + return PyErr_Format (PyExc_TypeError, >> + _("The symbol argument belongs to different " >> + "compunit than block")); >> + } > > In both these `if` blocks, the '{' and '}' are not needed. In the > second one, is TypeError the best choice? Would ValueError? Or > RuntimeError? be better? > I just realised I managed to send both these emails to the v5 thread, rather than the v6 thread. Sorry about that, I was jumping back and forward looking at different past review comments, and got mixed up at some point. I think everything still applies to the v6 patches, if not then just ignore me :) The patches I actually downloaded are for sure the v6 ones though! Sorry about that. Thanks, Andrew