From: Simon Marchi <simon.marchi@polymtl.ca>
To: Andrew Burgess <andrew.burgess@embecosm.com>, gdb-patches@sourceware.org
Subject: Re: [PATCHv5 3/4] gdb/python: add gdb.RemoteTargetConnection.send_packet
Date: Sun, 14 Nov 2021 21:08:40 -0500 [thread overview]
Message-ID: <a459db1b-77ed-1911-c574-a18ece75589b@polymtl.ca> (raw)
In-Reply-To: <b86ba99ca57f78794e42405fa9e70f8daf36f571.1634922528.git.andrew.burgess@embecosm.com>
Just some minor comments (one about a possible bug), but otherwise this
looks fine to me.
> diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
> index 2234bbe1891..0fd31ca6cb3 100644
> --- a/gdb/doc/python.texi
> +++ b/gdb/doc/python.texi
> @@ -5989,9 +5989,9 @@
> Examples of different connection types are @samp{native} and
> @samp{remote}. @xref{Inferiors Connections and Programs}.
>
> -@value{GDBN} uses the @code{gdb.TargetConnection} object type to
> -represent a connection in Python code. To get a list of all
> -connections use @code{gdb.connections}
> +Connections in @value{GDBN} are represented as instances of
> +@code{gdb.TargetConnection}, or as one of its sub-classes. To get a
> +list of all connections use @code{gdb.connections}
> (@pxref{gdbpy_connections,,gdb.connections}).
>
> To get the connection for a single @code{gdb.Inferior} read its
> @@ -6044,6 +6044,40 @@
> to the remote target.
> @end defvar
>
> +The @code{gdb.RemoteTargetConnection} class is a sub-class of
> +@code{gdb.TargetConnection}, and is used to represent @samp{remote}
> +and @samp{extended-remote} connections. In addition to the attributes
> +and methods available from the @code{gdb.TargetConnection} base class,
> +a @code{gdb.RemoteTargetConnection} has the following method:
In your opinion, would it be ok (backwards-compatible-wise) to introduce
a gdb.ExtendedRemoteTargetConnection class in the future, should we ever need
that? The only case that I think of that would break is if somebody
does:
type(my_target) is gdb.RemoteTargetConnection
where my_target is an extended-remote connection. That expression would
return True today, and would return False after adding
gdb.ExtendedRemoteTargetConnection. But if that could would use
isinstance, then it would be fine.
> @@ -284,9 +295,111 @@ gdbpy_initialize_connection (void)
> (PyObject *) &connection_object_type) < 0)
> return -1;
>
> + if (PyType_Ready (&remote_connection_object_type) < 0)
> + return -1;
> +
> + if (gdb_pymodule_addobject (gdb_module, "RemoteTargetConnection",
> + (PyObject *) &remote_connection_object_type) < 0)
> + return -1;
> +
> return 0;
> }
>
> +/* Set of callbacks used to implement gdb.send_packet. */
> +
> +struct py_send_packet_callbacks : public send_remote_packet_callbacks
> +{
> + /* Constructor, initialise the result to None. */
> +
> + py_send_packet_callbacks ()
> + : m_result (Py_None)
> + { /* Nothing. */ }
I think you might need to incref Py_None here. the gdbpy_ref will
decref on destruction or when its value changes, but you never incref
it.
> +
> + /* There's nothing to do when the packet is sent. */
> +
> + void sending (const char *args) override
> + { /* Nothing. */ }
> +
> + /* When the result is returned create a Python string and assign this
> + into the result member variable. */
> +
> + void received (const gdb::char_vector &buf) override
> + {
> + /* m_result is initialized to None, leave it untouched unless we got
> + back a useful result. */
> + if (buf.data ()[0] != '\0')
> + {
> + PyObject *result;
> +
> +#ifdef IS_PY3K
> + result = Py_BuildValue("y#", buf.data (), strlen (buf.data ()));
Missing space.
Simon
next prev parent reply other threads:[~2021-11-15 2:08 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-11 16:03 [PATCH 0/3] Python API for target connections, and packet sending Andrew Burgess
2021-09-11 16:03 ` [PATCH 1/3] gdb/python: introduce gdb.TargetConnection object type Andrew Burgess
2021-09-11 16:19 ` Eli Zaretskii
2021-09-11 16:03 ` [PATCH 2/3] gdb: make packet_command function available outside remote.c Andrew Burgess
2021-09-11 16:03 ` [PATCH 3/3] gdb/python: add TargetConnection.send_remote_packet method Andrew Burgess
2021-09-11 16:10 ` Eli Zaretskii
2021-10-18 9:45 ` [PATCHv2 0/3] Python API for target connections, and packet sending Andrew Burgess
2021-10-18 9:45 ` [PATCHv2 1/3] gdb/python: introduce gdb.TargetConnection object type Andrew Burgess
2021-10-18 12:44 ` Eli Zaretskii
2021-10-18 15:53 ` Simon Marchi
2021-10-18 9:45 ` [PATCHv2 2/3] gdb: make packet_command function available outside remote.c Andrew Burgess
2021-10-18 9:45 ` [PATCHv2 3/3] gdb/python: add TargetConnection.send_remote_packet method Andrew Burgess
2021-10-18 12:57 ` Eli Zaretskii
2021-10-18 15:46 ` Simon Marchi
2021-10-19 10:17 ` [PATCHv3 0/3] Python API for target connections, and packet sending Andrew Burgess
2021-10-19 10:17 ` [PATCHv3 1/3] gdb/python: introduce gdb.TargetConnection object type Andrew Burgess
2021-10-19 12:26 ` Eli Zaretskii
2021-10-20 22:33 ` Lancelot SIX
2021-10-21 2:00 ` Simon Marchi
2021-10-19 10:17 ` [PATCHv3 2/3] gdb: make packet_command function available outside remote.c Andrew Burgess
2021-10-21 2:23 ` Simon Marchi
2021-10-19 10:17 ` [PATCHv3 3/3] gdb/python: add gdb.RemoteTargetConnection.send_packet Andrew Burgess
2021-10-19 12:28 ` Eli Zaretskii
2021-10-21 2:43 ` Simon Marchi
2021-10-22 11:08 ` Andrew Burgess
2021-10-22 11:18 ` Simon Marchi
2021-10-22 17:11 ` Andrew Burgess
2021-10-22 10:58 ` [PATCHv4 0/4] Python API for target connections, and packet sending Andrew Burgess
2021-10-22 10:58 ` [PATCHv4 1/4] gdb/python: introduce gdb.TargetConnection object type Andrew Burgess
2021-10-22 10:58 ` [PATCHv4 2/4] gdb: make packet_command function available outside remote.c Andrew Burgess
2021-10-22 10:58 ` [PATCHv4 3/4] gdb/python: add gdb.RemoteTargetConnection.send_packet Andrew Burgess
2021-10-22 10:58 ` [PATCHv4 4/4] gdb: handle binary data in 'maint packet' and RemoteTargetConnection.send_packet Andrew Burgess
2021-10-22 17:10 ` [PATCHv5 0/4] Python API for target connections, and packet sending Andrew Burgess
2021-10-22 17:10 ` [PATCHv5 1/4] gdb/python: introduce gdb.TargetConnection object type Andrew Burgess
2021-10-22 17:10 ` [PATCHv5 2/4] gdb: make packet_command function available outside remote.c Andrew Burgess
2021-10-22 17:10 ` [PATCHv5 3/4] gdb/python: add gdb.RemoteTargetConnection.send_packet Andrew Burgess
2021-11-15 2:08 ` Simon Marchi [this message]
2021-11-15 9:25 ` Andrew Burgess
2021-11-15 13:16 ` Simon Marchi
2021-10-22 17:10 ` [PATCHv5 4/4] gdb: handle binary data in 'maint packet' and RemoteTargetConnection.send_packet Andrew Burgess
2021-11-15 2:44 ` Simon Marchi
2021-11-09 10:04 ` [PATCHv5 0/4] Python API for target connections, and packet sending Andrew Burgess
2021-11-15 17:40 ` [PATCHv6 0/3] " Andrew Burgess
2021-11-15 17:40 ` [PATCHv6 1/3] gdb/python: introduce gdb.TargetConnection object type Andrew Burgess
2021-11-15 17:40 ` [PATCHv6 2/3] gdb: make packet_command function available outside remote.c Andrew Burgess
2021-11-15 17:40 ` [PATCHv6 3/3] gdb/python: add gdb.RemoteTargetConnection.send_packet Andrew Burgess
2021-11-15 18:42 ` Eli Zaretskii
2021-11-15 19:38 ` Simon Marchi
2021-11-15 19:29 ` Simon Marchi
2021-11-16 12:48 ` Andrew Burgess
2021-11-16 15:10 ` Simon Marchi
2021-11-30 12:15 ` 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=a459db1b-77ed-1911-c574-a18ece75589b@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=andrew.burgess@embecosm.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).