[PATCHv3 2/3] gdb: make packet_command function available outside remote.c

Simon Marchi simon.marchi@polymtl.ca
Thu Oct 21 02:23:04 GMT 2021



On 2021-10-19 06:17, Andrew Burgess wrote:
> In a later commit I will add a Python API to access the 'maint packet'
> functionality, that is, sending a user specified packet to the target.
> 
> To make implementing this easier, this commit refactors how this
> command is currently implemented so that the packet_command function
> is now global.
> 
> The new global send_remote_packet function takes an object that is an
> implementation of an abstract interface.  Two functions within this
> interface are then called, one just before a packet is sent to the
> remote target, and one when the reply has been received from the
> remote target.  Using an interface object in this way allows (1) for
> the error checking to be done before the first callback is made, this
> means we only print out what packet it being sent once we know we are
> going to actually send it, and (2) we don't need to make a copy of the
> reply if all we want to do is print it.
> 
> The only user visible changes after this commit are the error
> messages, which I've changed to be less 'maint packet' command
> focused, this will make them (I hope) better for when
> send_remote_packet can be called from Python code.
> 
> So:      "command can only be used with remote target"
> Becomes: "packets can only be sent to a remote target"
> 
> And:     "remote-packet command requires packet text as argument"
> Becomes: "a remote packet must not be empty"

This LGTM.

Simon


More information about the Gdb-patches mailing list