diff options
author | David Howells <dhowells@redhat.com> | 2011-03-18 12:54:31 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2011-03-18 12:54:31 -0400 |
commit | d57f078b193981d1b7d24193f3118c6b806db0ff (patch) | |
tree | 4bbebe3427d64a37627e5626bc42ccfd4560d5cb | |
parent | e460d64405c04581e42aa9cbae76815a2d4e9abe (diff) |
KGDB: Notify GDB of machine halt, reboot or power off
Notify GDB of the machine halting, rebooting or powering off by sending it an
exited command (remote protocol command 'W'). This is done by calling:
void gdbstub_exit(int status)
from the arch's machine_{halt,restart,power_off}() functions with an
appropriate exit status to be reported to GDB.
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | include/linux/kgdb.h | 1 | ||||
-rw-r--r-- | kernel/debug/gdbstub.c | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index 092e4250a458..10ca03d0a250 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h | |||
@@ -297,6 +297,7 @@ extern int | |||
297 | kgdb_handle_exception(int ex_vector, int signo, int err_code, | 297 | kgdb_handle_exception(int ex_vector, int signo, int err_code, |
298 | struct pt_regs *regs); | 298 | struct pt_regs *regs); |
299 | extern int kgdb_nmicallback(int cpu, void *regs); | 299 | extern int kgdb_nmicallback(int cpu, void *regs); |
300 | extern void gdbstub_exit(int status); | ||
300 | 301 | ||
301 | extern int kgdb_single_step; | 302 | extern int kgdb_single_step; |
302 | extern atomic_t kgdb_active; | 303 | extern atomic_t kgdb_active; |
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c index 481a7bd2dfe7..a11db956dd62 100644 --- a/kernel/debug/gdbstub.c +++ b/kernel/debug/gdbstub.c | |||
@@ -1093,3 +1093,33 @@ int gdbstub_state(struct kgdb_state *ks, char *cmd) | |||
1093 | put_packet(remcom_out_buffer); | 1093 | put_packet(remcom_out_buffer); |
1094 | return 0; | 1094 | return 0; |
1095 | } | 1095 | } |
1096 | |||
1097 | /** | ||
1098 | * gdbstub_exit - Send an exit message to GDB | ||
1099 | * @status: The exit code to report. | ||
1100 | */ | ||
1101 | void gdbstub_exit(int status) | ||
1102 | { | ||
1103 | unsigned char checksum, ch, buffer[3]; | ||
1104 | int loop; | ||
1105 | |||
1106 | buffer[0] = 'W'; | ||
1107 | buffer[1] = hex_asc_hi(status); | ||
1108 | buffer[2] = hex_asc_lo(status); | ||
1109 | |||
1110 | dbg_io_ops->write_char('$'); | ||
1111 | checksum = 0; | ||
1112 | |||
1113 | for (loop = 0; loop < 3; loop++) { | ||
1114 | ch = buffer[loop]; | ||
1115 | checksum += ch; | ||
1116 | dbg_io_ops->write_char(ch); | ||
1117 | } | ||
1118 | |||
1119 | dbg_io_ops->write_char('#'); | ||
1120 | dbg_io_ops->write_char(hex_asc_hi(checksum)); | ||
1121 | dbg_io_ops->write_char(hex_asc_lo(checksum)); | ||
1122 | |||
1123 | /* make sure the output is flushed, lest the bootloader clobber it */ | ||
1124 | dbg_io_ops->flush(); | ||
1125 | } | ||