From: Tom Tromey <tromey@adacore.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] Add attributes and methods to gdb.Inferior
Date: Wed, 17 May 2023 09:32:22 -0600 [thread overview]
Message-ID: <87ednf0y9l.fsf@tromey.com> (raw)
In-Reply-To: <87edno7aoa.fsf@redhat.com> (Andrew Burgess's message of "Wed, 10 May 2023 11:17:25 +0100")
>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>> + const char *name;
>> + if (!PyArg_ParseTuple (args, "s", &name))
Andrew> I'd really prefer gdb_PyArg_ParseTupleAndKeywords be used here too. I
Andrew> know there's only a single argument, but I think it would be nice if our
Andrew> API was consistent in always accepting keywords.
Ok, I did this.
gdb doesn't generally do this for single-argument functions, but it's
also relatively harmless to do so ("relatively" since it does mean the
name is ABI).
>> + if (value == nullptr)
>> + {
>> + PyErr_SetString (PyExc_TypeError, _("Cannot delete 'arguments' attribute."));
Andrew> Line length?
Fixed.
>> + return -1;
>> + }
>> +
>> + if (PyUnicode_Check (value))
Andrew> I prefer gdbpy_is_string, which is used more. Though
Andrew> PyUnicode_Check is present in a few places.
I made this change, but it seems to me that gdbpy_is_string was probably
there for Python 2/3 compatibility. Now that it's just a simple wrapper
for PyUnicode_Check, it seems like it would be more "Pythonically
idiomatic" to just remove the wrapper.
>> + /* This is unfortunate but the implementation of main_name can
>> + reach into memory, among other things. */
>> + scoped_restore_current_inferior restore_inferior;
>> + set_current_inferior (inf->inferior);
>> +
>> + scoped_restore_current_program_space restore_current_progspace;
>> + set_current_program_space (inf->inferior->pspace);
Andrew> I guess switch_to_inferior_no_thread would be overkill here, if all
Andrew> we're doing is accessing inferior memory? Though you do tease us with
Andrew> "among other things", so hopefully nothing is using the incorrect
Andrew> thread....
I removed the "among other things" bit. I think the thread shouldn't
really matter.
The only offender here is Ada and there's a bug open about how it would
be better to get this info from the executable instead.
>> +
>> + name = main_name ();
>> + }
>> + catch (const gdb_exception &except)
>> + {
>> + /* We can just ignore this. */
>> + name = nullptr;
Andrew> Is this assignment necessary, given name is initialised to nullptr?
Apparently not, I removed it in v2.
Tom
next prev parent reply other threads:[~2023-05-17 15:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 16:01 [PATCH 0/2] Add more DAP launch parameters Tom Tromey
2023-05-09 16:01 ` [PATCH 1/2] Add attributes and methods to gdb.Inferior Tom Tromey
2023-05-09 16:15 ` Eli Zaretskii
2023-05-17 15:45 ` Tom Tromey
2023-05-10 10:17 ` Andrew Burgess
2023-05-17 15:32 ` Tom Tromey [this message]
2023-05-09 16:02 ` [PATCH 2/2] Add "args" and "env" parameters to DAP launch request Tom Tromey
2023-05-09 16:10 ` Eli Zaretskii
2023-05-16 19:06 ` Tom Tromey
2023-05-16 19:10 ` Eli Zaretskii
2023-05-16 19:20 ` Eli Zaretskii
2023-05-10 12:39 ` Andrew Burgess
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=87ednf0y9l.fsf@tromey.com \
--to=tromey@adacore.com \
--cc=aburgess@redhat.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).