From: Tom Tromey <tom@tromey.com>
To: Matheus Branco Borella <dark.ryu.550@gmail.com>
Cc: gdb-patches@sourceware.org, aburgess@redhat.com
Subject: Re: [PATCH v2] Add support for symbol addition to the Python API
Date: Tue, 06 Feb 2024 10:50:11 -0700 [thread overview]
Message-ID: <875xz1eb3g.fsf@tromey.com> (raw)
In-Reply-To: <20240113013631.109348-1-dark.ryu.550@gmail.com> (Matheus Branco Borella's message of "Fri, 12 Jan 2024 22:36:32 -0300")
>>>>> Matheus Branco Borella <dark.ryu.550@gmail.com> writes:
> I had to walk away from this for a while. I'm pinging it now and I've updated
> the code so that it works on master.
Thank you for the patch.
> This patch adds support for symbol creation and registration. It currently
> supports adding type symbols (VAR_DOMAIN/LOC_TYPEDEF), static symbols
> (VAR_DOMAIN/LOC_STATIC) and goto target labels (LABEL_DOMAIN/LOC_LABEL).
Symbol domains recently went through a change.
Also, a patch that changes the Python API requires a documentation
change and also an entry in NEWS.
> In the same vein, PC-based function name lookup also does not work, although
> there may be a way to have the feature work using overlays.
I guess because nothing makes any blocks. However this seems like a
kind of big issue to me, because it means that by-name lookups will
appear to succeed ("function xyz is at address 0xaaaaa") but then
stopping in that function won't show the name.
> + virtual void register_msymbol (const std::string& name,
gdb style puts the "&" next to "name", not next to "string".
There's a lot of instances of this.
> +/* Data being held by the gdb.ObjfileBuilder.
> + *
> + * This structure needs to have its constructor run in order for its lifetime
> + * to begin. Because of how Python handles its objects, we can't just reconstruct
> + * the object structure as a whole, as that would overwrite things the runtime
> + * cares about, so these fields had to be broken off into their own structure. */
gdb doesn't use the "leading *" style of comment.
> + /* We need to tell GDB what architecture the objfile uses. */
> + if (has_stack_frames ())
> + of->per_bfd->gdbarch = get_frame_arch (get_selected_frame (nullptr));
> + else
> + of->per_bfd->gdbarch = current_inferior ()->arch ();
gdb exposes a gdb.Architecture, maybe we could let the Python code
specify this.
> +/* Parses a language from a string (coming from Python) into a language
> + * variant. */
> +
> +static enum language
> +parse_language (const char *language)
> +{
> + if (strcmp (language, "c") == 0)
> + return language_c;
> + else if (strcmp (language, "objc") == 0)
> + return language_objc;
I think this should call language_enum instead.
> + if (language_name == nullptr)
> + language_name = "auto";
I think it's kind of weird to use auto here.
> +/* Builds the object file. */
> +static PyObject *
> +objbdpy_build (PyObject *self, PyObject *args)
> +{
> + auto builder = validate_objfile_builder_object (self);
> + if (builder == nullptr)
> + return nullptr;
> +
> + if (builder->inner.installed)
> + {
> + PyErr_SetString (PyExc_ValueError, "build() cannot be run twice on the \
> + same object");
> + return nullptr;
> + }
> + auto of = build_new_objfile (*builder);
There's a rule in the Python layer in gdb that code that calls into gdb
has to wrap the call in a try/catch and use GDB_PY_HANDLE_EXCEPTION.
This is because a lot of gdb code can throw exceptions, but letting an
exception cross the Python boundary is catastrophic.
> + auto objpy = objfile_to_objfile_object (of).get ();
> + Py_INCREF(objpy);
> + return objpy;
objfile_to_objfile_object returns a new reference so I think the incref
is wrong here.
We try to avoid explicit inc/dec-refs in gdb anyway.
Tom
next prev parent reply other threads:[~2024-02-06 17:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-27 1:24 [PATCH] " Matheus Branco Borella
2023-06-27 3:53 ` [PING] " Matheus Branco Borella
2023-07-04 15:14 ` Andrew Burgess
2023-07-07 23:13 ` Matheus Branco Borella
2024-01-13 1:36 ` [PATCH v2] " Matheus Branco Borella
2024-02-06 17:50 ` Tom Tromey [this message]
2024-02-24 17:35 ` Matheus Branco Borella
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=875xz1eb3g.fsf@tromey.com \
--to=tom@tromey.com \
--cc=aburgess@redhat.com \
--cc=dark.ryu.550@gmail.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).