From: Luis Machado via Gdb <gdb@sourceware.org>
To: Andrew Burgess <aburgess@redhat.com>,
Stephen Brennan <stephen.s.brennan@oracle.com>,
Tom Tromey <tom@tromey.com>,
Luis Machado via Gdb <gdb@sourceware.org>
Cc: linux-debuggers@vger.kernel.org,
Omar Sandoval <osandov@osandov.com>,
Amal Raj T <tjarlama@gmail.com>
Subject: Re: GDB Remote Protocol Extension - Linux VMCOREINFO - Request for Feedback
Date: Thu, 16 Jan 2025 17:15:43 +0000 [thread overview]
Message-ID: <a6160f3b-8b9a-4e38-922a-3c026e26e275@arm.com> (raw)
In-Reply-To: <87y0zaogoh.fsf@redhat.com>
On 1/16/25 16:40, Andrew Burgess wrote:
> Luis Machado <luis.machado@arm.com> writes:
>
>> On 1/16/25 10:37, Andrew Burgess wrote:
>>> Stephen Brennan via Gdb <gdb@sourceware.org> writes:
>>>
>>>> Tom Tromey <tom@tromey.com> writes:
>>>>>>>>>> Luis Machado via Gdb <gdb@sourceware.org> writes:
>>>>>
>>>>>>> To sum up, my specific questions are:
>>>>>>>
>>>>>>> 1. What is the maximum protocol packet size, if any?
>>>>>
>>>>>> It is hardcoded by gdb, but the remote can also specify that, but...
>>>>>
>>>>>>> 2. Would this functionality be better implemented in a single "q
>>>>>>> linux.vmcoreinfo" packet, or as a "qXfer" packet?
>>>>>
>>>>>> ... we have packets like qXfer that can handle multi-part transfers. So the
>>>>>> packet size is not a critical concern anymore, and it is best to use this
>>>>>> newer mechanism, if the usage fits the packet structure.
>>>>>
>>>>> Agreed, qXfer is the way to go.
>>>>
>>>> Thank you Tom & Luis for confirmation, qXfer seems appropriate. With
>>>> that approach the buffer size is not really a concern: we can simply use
>>>> the minimum of the requested read size, and the stub's buffer size. So
>>>> long as clients use multiple requests until the data is fully read.
>>>>
>>>> While the "os" object also sounds like a good place to put this (e.g.
>>>> within a new annex), it seems like that contains XML-formatted data with
>>>> well-understood schema and semantics. The vmcoreinfo is free-form text
>>>> (generally of a "key=value" format), so it probably should be a separate
>>>> object.
>>>>
>>>> So I think we would prefer to add an object type, e.g. named "vmcoreinfo".
>>>> (But please do speak up if this sounds like a mistake)
>>>>
>>>>> If you're adding a new object type, a patch to the manual would be good.
>>>>
>>>> I'll definitely include a patch for the manual in the plan for this.
>>>> Another patch I'd like to write is to allow GDB's server to expose this
>>>> object type when the target is an ELF core dump with a VMCOREINFO note.
>>>> We're hoping for this to useful for all debuggers, not just drgn.
>>>
>>> Hi Stephen,
>>>
>>> I took a look at the wiki page and it seems like initially at least,
>>> your plan is to make the information from vmcoreinfo available via a new
>>> 'info' command.
>>>
>>> It is possible to send remote packets through GDB's Python API[1]. And
>>> of course, the Python API allows for new commands to be created[2].
>>> There is a test in GDB's test suite that makes use of the packet sending
>>> API, and it happens to send a qXfer packet[3].
>>>
>>> I say all this not to put you off contributing a patch to core GDB, but
>>> if what you want is a new user command which will send a packet to a
>>> remote target and process the results, then it should be possible to
>>> implement this as a Python extension.
>>
>> A bit off-topic, but wouldn't that have the potential to proliferate
>> remote packets gdb/debugging stubs have no control over or no documentation
>> to point at/refer to? Possibly contributing to greater confusion as to what
>> should be minimally supported in terms of remote packets?
>
> I don't see a problem, but that doesn't mean using an extension is the
> right choice in all cases.
>
> Using an extension, in my mind, ties the functionality to the project.
> So if we expect many remote targets to support the new packet then it
> begins to make more sense to move the functionality into the GDB tree
> (maybe as C++ code, or maybe as Python code). But if, really, the new
> feature only applies for one project, then it makes more sense (for me)
> to add GDB support via an project specific extension. Documentation
> would naturally live within the project itself.
>
> On the topic of control, I'm not entirely sure what problems you see.
> Using a project specific extension gives (IMHO) the project more control
> over the packet as they are free to change the packet over time.
> Currently GDB is pretty conservative with changing packets, so if a
> single project pushed their own custom packet to GDB core, and then
> wanted to change the packet, there's a risk we (GDB team) might refuse
> the change "just in case" someone else has since started to use the
> packet. That might be seen as the project having less control.
>
> Looking at GDB's control over packets, I'm not sure what control GDB
> needs. For sure, there's a risk that if extensions start creating their
> own packets then there is a risk that GDB might later add a conflicting
> packet, which could be a problem, and one reason we might want to move
> from an extension to a core packet. I doubt, right now, there are many
> "custom packets" in the wild, but maybe we should consider defining
> namespaces for custom packets, to avoid future conflicts?
>
> The minimally supported problem is usually about the minimal set of
> packets that a remote target needs to support, rather than the set GDB
> supports. In most cases, communication is initiated by GDB, so if GDB
> isn't aware of this packet (extension not loaded), GDB will just never
> ask for it.
>
> I'm certainly not making the argument that using an extension is the
> right choice in every case. Not every packet type is going to be right
> for implementing as an extension. Additionally, it might be that a
> project starts with an extension while prototyping a new packet, and
> then ports it to C++ and contributes it to GDB later once the design is
> solid.
>
> I've had success using packets via Python before, and not everyone is
> aware this feature is available, so I thought I'd mention it.
All good points. I wasn't aware this particular feature existed to be honest.
I suppose my concerns are more towards having a packet that eventually starts
getting wider usage, and then people rely on it, but gdb doesn't know about it.
But I agree by then we should be able to make the call to internalize such packet
in GDB.
To be fair, given the nature of the RSP packets, it would make more sense to
have that parsed/handled via Python for simplicity/efficiency, as opposed to C/C++.
>
> Thanks,
> Andrew
>
next prev parent reply other threads:[~2025-01-16 17:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <8734hmtfbr.fsf@oracle.com>
2025-01-14 15:03 ` Luis Machado via Gdb
2025-01-14 17:15 ` Tom Tromey
2025-01-14 17:39 ` Stephen Brennan via Gdb
2025-01-16 10:37 ` Andrew Burgess via Gdb
2025-01-16 10:49 ` Luis Machado via Gdb
2025-01-16 16:40 ` Andrew Burgess via Gdb
2025-01-16 17:15 ` Luis Machado via Gdb [this message]
2025-01-17 22:01 ` Tom Tromey
2025-01-16 17:58 ` Stephen Brennan via Gdb
2025-01-23 1:11 ` Stephen Brennan via Gdb
2025-01-26 18:07 ` Thomas Weißschuh via Gdb
2025-01-27 18:13 ` Omar Sandoval
2025-01-27 18:42 ` Stephen Brennan via Gdb
2025-01-27 22:40 ` Thomas Weißschuh via Gdb
2025-01-28 0:19 ` Stephen Brennan via Gdb
2025-01-29 21:16 ` Thomas Weißschuh via Gdb
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=a6160f3b-8b9a-4e38-922a-3c026e26e275@arm.com \
--to=gdb@sourceware.org \
--cc=aburgess@redhat.com \
--cc=linux-debuggers@vger.kernel.org \
--cc=luis.machado@arm.com \
--cc=osandov@osandov.com \
--cc=stephen.s.brennan@oracle.com \
--cc=tjarlama@gmail.com \
--cc=tom@tromey.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