From: Andrew Burgess <aburgess@redhat.com>
To: Jan Vrany <jan.vrany@labware.com>, gdb-patches@sourceware.org
Cc: Jan Vrany <jan.vrany@labware.com>, Eli Zaretskii <eliz@gnu.org>
Subject: Re: [RFC v5 14/18] gdb/python: add add_symbol () method to gdb.Block
Date: Fri, 29 Aug 2025 15:14:31 +0100 [thread overview]
Message-ID: <87bjnyqkoo.fsf@redhat.com> (raw)
In-Reply-To: <87ecsuqkux.fsf@redhat.com>
Andrew Burgess <aburgess@redhat.com> writes:
> Jan Vrany <jan.vrany@labware.com> 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 <eliz@gnu.org>
>> ---
>> 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
next prev parent reply other threads:[~2025-08-29 14:15 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 16:09 [RFC v5 00/19] Add Python "JIT" API Jan Vrany
2025-06-23 16:09 ` [RFC v5 01/18] gdb: introduce expand_symtabs_maybe_overlapping Jan Vrany
2025-06-24 15:22 ` Tom Tromey
2025-06-26 15:05 ` Jan Vraný
2025-06-23 16:09 ` [RFC v5 02/18] gdb: introduce compunit_symtab::maybe_contains Jan Vrany
2025-06-23 16:09 ` [RFC v5 03/18] gdb: update is_addr_in_objfile to support "dynamic" objfiles Jan Vrany
2025-06-23 16:09 ` [RFC v5 04/18] gdb: introduce new function create_function_type Jan Vrany
2025-06-24 15:29 ` Tom Tromey
2025-06-26 11:12 ` Jan Vraný
2025-06-27 14:21 ` Tom Tromey
2025-06-27 14:30 ` Jan Vraný
2025-06-23 16:10 ` [RFC v5 05/18] gdb/python: add function () method to gdb.Type object Jan Vrany
2025-06-24 16:11 ` Tom Tromey
2025-06-26 11:13 ` Jan Vraný
2025-06-23 16:10 ` [RFC v5 06/18] gdb: use std::vector<> to hold on blocks in struct blockvector Jan Vrany
2025-06-23 16:10 ` [RFC v5 07/18] gdb/python: add gdb.Compunit Jan Vrany
2025-06-23 16:10 ` [RFC v5 08/18] gdb/python: allow instantiation of gdb.Objfile from Python Jan Vrany
2025-06-23 16:10 ` [RFC v5 09/18] gdb/python: add unlink () method to gdb.Objfile object Jan Vrany
2025-06-23 16:10 ` [RFC v5 10/18] gdb/python: allow instantiation of gdb.Compunit from Python Jan Vrany
2025-06-23 16:10 ` [RFC v5 11/18] gdb/python: allow instantiation of gdb.Symtab " Jan Vrany
2025-06-23 16:10 ` [RFC v5 12/18] gdb/python: allow instantiation of gdb.Block " Jan Vrany
2025-06-23 16:10 ` [RFC v5 13/18] gdb/python: allow instantiation of gdb.Symbol " Jan Vrany
2025-06-23 16:10 ` [RFC v5 14/18] gdb/python: add add_symbol () method to gdb.Block Jan Vrany
2025-08-29 14:10 ` Andrew Burgess
2025-08-29 14:14 ` Andrew Burgess [this message]
2025-06-23 16:10 ` [RFC v5 15/18] gdb/python: add more attributes to gdb.LinetableEntry objects Jan Vrany
2025-08-29 14:00 ` Andrew Burgess
2025-09-02 11:03 ` Jan Vraný
2025-06-23 16:10 ` [RFC v5 16/18] gdb/python: allow instantiation of gdb.LineTableEntry objects Jan Vrany
2025-06-23 16:10 ` [RFC v5 17/18] gdb/python: allow instantiation of gdb.LineTable objects Jan Vrany
2025-06-23 16:10 ` [RFC v5 18/18] gdb/python: add section in documentation on implementing JIT interface Jan Vrany
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bjnyqkoo.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=jan.vrany@labware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox