From: "Alkallas, Mouhanad" <Mouhanad.Alkallas@amd.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Proposed Addition to GDB packets
Date: Thu, 21 Aug 2025 21:05:35 +0000 [thread overview]
Message-ID: <DM6PR12MB362505230AEE5BF14BCE7869F332A@DM6PR12MB3625.namprd12.prod.outlook.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 4241 bytes --]
[Public]
Hi,
I am looking extend the capabilities of KGDB for Linux, however in order to do this I need to define a new packet format.
See proposed Linux kernel patch below.
The proposal is to add a packet "J" for customization in privately defined KGDB IO Module.
Packet format would "J <custom data>", instead of gdbstub.c handling the packet, it would forward the call to the attached KGDB IO Module to service the packet.
This allows developers to create custom commands meeting their needs, such as but not limited to:
- Extend KGDBoE functionality to handle reading register from MMMIO physical address prior to driver load
- Extend KGDBoE functionality to perform pci re-enumeration and device reset prior to driver load
- Extend packets to work cohesively with onboard device firmware's and debuggers
This change does not require any GDB functional changes or code update, but does require documentation update and reservation of packets starting with 'J'
The questions I have are:
- Are there any reservations about this change?
- Is there a process I need to follow to get this change acknowledged across multiple open source projects, Linux & GDB?
Linux patch below
Subject: [PATCH] KGDB: Extend Serial GDB packet such that custom KGDB IO modules can extend the functionality for specific devices without having to modify the kernel. Extended functionality is meant to be proprietary to each developer and should have no impact on kernel operation.
Sample Use Case:
- Extend KGDBoE functionality to handle reading register from MMMIO physical address prior to driver load
- Extend KGDBoE functionality to perform pci re-enumeration and device reset prior to driver load
- Extend packets to work cohesively with onboard device firmwares and debuggers
Signed-off-by: Mouhanad Alkallas <malkalla@amd.com<mailto:malkalla@amd.com>>
---
include/linux/kgdb.h | 3 +++
kernel/debug/gdbstub.c | 15 +++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index 5eebbe7a3545..7f260ad3ded6 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -285,6 +285,8 @@ struct kgdb_arch {
* the I/O driver.
* @post_exception: Pointer to a function that will do any cleanup work
* for the I/O driver.
+ * @custom_packet: Pointer to a function that will handle customer packets.
+ * provided parameters are input buffer and output buffer.
* @cons: valid if the I/O device is a console; else NULL.
*/
struct kgdb_io {
@@ -296,6 +298,7 @@ struct kgdb_io {
void (*deinit) (void);
void (*pre_exception) (void);
void (*post_exception) (void);
+ int (*custom_packet) (char *, char *);
struct console *cons;
};
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c index f625172d4b67..326356f431a6 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -842,6 +842,18 @@ static void gdb_cmd_task(struct kgdb_state *ks)
}
}
+/* Handle the 'J' task query packets */ static void
+gdb_cmd_custom_packet(struct kgdb_state *ks) {
+ if (dbg_io_ops->custom_packet) {
+ if (!dbg_io_ops->custom_packet(remcom_in_buffer, remcom_out_buffer)) {
+ return;
+ } else
+ error_packet(remcom_out_buffer, -EINVAL);
+ }
+ error_packet(remcom_out_buffer, -EINVAL); }
+
/* Handle the 'T' thread query packets */ static void gdb_cmd_thread(struct kgdb_state *ks) { @@ -1029,6 +1041,9 @@ int gdb_serial_stub(struct kgdb_state *ks)
case 'H': /* task related */
gdb_cmd_task(ks);
break;
+ case 'J': /* Handle custom packet */
+ gdb_cmd_custom_packet(ks);
+ break;
case 'T': /* Query thread status */
gdb_cmd_thread(ks);
break;
--
2.43.0
[-- Attachment #2: Type: text/html, Size: 11353 bytes --]
next reply other threads:[~2025-08-21 21:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 21:05 Alkallas, Mouhanad [this message]
2025-08-21 23:07 ` Aaron Griffith
2025-08-25 14:54 ` Alkallas, Mouhanad
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=DM6PR12MB362505230AEE5BF14BCE7869F332A@DM6PR12MB3625.namprd12.prod.outlook.com \
--to=mouhanad.alkallas@amd.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