From: Tom Tromey <tom@tromey.com>
To: Jan Vrany <jan.vrany@labware.com>
Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>
Subject: Re: [RFC v5 05/18] gdb/python: add function () method to gdb.Type object
Date: Tue, 24 Jun 2025 10:11:50 -0600 [thread overview]
Message-ID: <87y0thxgop.fsf@tromey.com> (raw)
In-Reply-To: <20250623161013.650814-6-jan.vrany@labware.com> (Jan Vrany's message of "Mon, 23 Jun 2025 17:10:00 +0100")
>>>>> "Jan" == Jan Vrany <jan.vrany@labware.com> writes:
Jan> +/* See gdbtypes.h. */
Jan> +
Jan> +bool
Jan> +type::is_void ()
Jan> +{
Jan> + return check_typedef (this)->code () == TYPE_CODE_VOID;
Jan> +}
This should be moved to the earlier patch that calls it.
Jan> +const std::string
Jan> +type::printable_name () const
Jan> +{
This isn't called in this patch but I don't think it really matters as
long as it's used eventually.
Jan> + string_file thetype;
Jan> +
Jan> + current_language->print_type (const_cast<type*>(this), "",
Space before "(this)"
Jan> + param_types[i] = type_object_to_type (param_type_obj);
Jan> + if (param_types[i] == nullptr)
Jan> + {
Jan> + PyErr_Format (PyExc_TypeError,
Jan> + _("Argument at index %d is %s, not a gdb.Type "
Jan> + "object."),
Jan> + i, Py_TYPE (param_type_obj)->tp_name);
Jan> + return nullptr;
It's kind of lame that we don't have a type_object_to_type_checked
variant.
Jan> + if (param_types[i]->is_void ())
Can check_typedef throw an exception? If so this must be wrapped in a
try/catch. That's a good practice for all calls into gdb anyway,
because things like this may change over time.
Jan> + if (kw != nullptr)
Jan> + {
Jan> + if (!PyDict_Check (kw))
Jan> + {
Jan> + PyErr_Format (PyExc_ValueError,
Jan> + _("Arguments is %s, not a dict."),
Jan> + Py_TYPE (args)->tp_name);
Jan> + return nullptr;
Jan> + }
Jan> +
This code should probably call PyArg_ValidateKeywordArguments.
I don't know whether that includes the PyDict_Check on its own.
Jan> + /* Copy all objfile-owned types to arch. This way user does not
Jan> + need to care about mixing types from different objfiles and
Jan> + architectures and we do not need to expose this implementation
Jan> + detail to the user. */
Jan> +
Jan> + copied_types_hash_t copied_types;
Jan> + return_type = copy_type_recursive (return_type, copied_types);
This whole block should probably be wrapped in a try/catch.
Jan> + function_type = lookup_function_type_with_arguments
Jan> + (return_type, param_types.size (), param_types.data ());
May be mildly nicer to use an array_view here.
Jan> + gdb_test "python print(repr(int_t.function(varargs=True)))" \
Jan> + "<gdb.Type code=TYPE_CODE_FUNC name=int \\(void\\)>"
Jan> +
Jan> + gdb_test "python print(repr(int_t.function(varargs=False)))" \
Jan> + "<gdb.Type code=TYPE_CODE_FUNC name=int \\(void\\)>"
Seems weird that these print the same thing.
Tom
next prev parent reply other threads:[~2025-06-24 16:12 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 [this message]
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
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=87y0thxgop.fsf@tromey.com \
--to=tom@tromey.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