Skip to content

Commit 8c080d3

Browse files
VincentZWCpalmer-dabbelt
authored andcommitted
kgdb: enable arch to support XML packet.
The XML packet could be supported by required architecture if the architecture defines CONFIG_HAVE_ARCH_KGDB_QXFER_PKT and implement its own kgdb_arch_handle_qxfer_pkt(). Except for the kgdb_arch_handle_qxfer_pkt(), the architecture also needs to record the feature supported by gdb stub into the kgdb_arch_gdb_stub_feature, and these features will be reported to host gdb when gdb stub receives the qSupported packet. Signed-off-by: Vincent Chen <[email protected]> Acked-by: Daniel Thompson <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent dcb7fd8 commit 8c080d3

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

include/linux/kgdb.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ kgdb_arch_handle_exception(int vector, int signo, int err_code,
176176
char *remcom_out_buffer,
177177
struct pt_regs *regs);
178178

179+
/**
180+
* kgdb_arch_handle_qxfer_pkt - Handle architecture specific GDB XML
181+
* packets.
182+
* @remcom_in_buffer: The buffer of the packet we have read.
183+
* @remcom_out_buffer: The buffer of %BUFMAX bytes to write a packet into.
184+
*/
185+
186+
extern void
187+
kgdb_arch_handle_qxfer_pkt(char *remcom_in_buffer,
188+
char *remcom_out_buffer);
189+
179190
/**
180191
* kgdb_call_nmi_hook - Call kgdb_nmicallback() on the current CPU
181192
* @ignored: This parameter is only here to match the prototype.

kernel/debug/gdbstub.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,19 @@ static void gdb_cmd_query(struct kgdb_state *ks)
792792
}
793793
break;
794794
#endif
795+
#ifdef CONFIG_HAVE_ARCH_KGDB_QXFER_PKT
796+
case 'S':
797+
if (!strncmp(remcom_in_buffer, "qSupported:", 11))
798+
strcpy(remcom_out_buffer, kgdb_arch_gdb_stub_feature);
799+
break;
800+
case 'X':
801+
if (!strncmp(remcom_in_buffer, "qXfer:", 6))
802+
kgdb_arch_handle_qxfer_pkt(remcom_in_buffer,
803+
remcom_out_buffer);
804+
break;
805+
#endif
806+
default:
807+
break;
795808
}
796809
}
797810

lib/Kconfig.kgdb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
config HAVE_ARCH_KGDB
44
bool
55

6+
# set if architecture has the its kgdb_arch_handle_qxfer_pkt
7+
# function to enable gdb stub to address XML packet sent from GDB.
8+
config HAVE_ARCH_KGDB_QXFER_PKT
9+
bool
10+
611
menuconfig KGDB
712
bool "KGDB: kernel debugger"
813
depends on HAVE_ARCH_KGDB

0 commit comments

Comments
 (0)