[PATCH 4/4] kgdb: x86: Detach gdb if machine shuts down or reboots
From: Jan Kiszka
Date: Fri Mar 16 2012 - 08:17:41 EST
Hook into machine restart/power-off/halt handlers and call gdbstub_exit
so that a attached gdb frontend is properly informed. If kgdb is
disabled or no frontend attached, gdbstub_exit will do nothing.
CC: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CC: Ingo Molnar <mingo@xxxxxxxxxx>
CC: "H. Peter Anvin" <hpa@xxxxxxxxx>
CC: x86@xxxxxxxxxx
Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
arch/x86/kernel/reboot.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index d840e69..926ac17 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -7,6 +7,7 @@
#include <linux/sched.h>
#include <linux/tboot.h>
#include <linux/delay.h>
+#include <linux/kgdb.h>
#include <acpi/reboot.h>
#include <asm/io.h>
#include <asm/apic.h>
@@ -683,6 +684,7 @@ void native_machine_shutdown(void)
static void __machine_emergency_restart(int emergency)
{
reboot_emergency = emergency;
+ gdbstub_exit(1);
machine_ops.emergency_restart();
}
@@ -730,6 +732,7 @@ struct machine_ops machine_ops = {
void machine_power_off(void)
{
+ gdbstub_exit(0);
machine_ops.power_off();
}
@@ -745,17 +748,20 @@ void machine_emergency_restart(void)
void machine_restart(char *cmd)
{
+ gdbstub_exit(0);
machine_ops.restart(cmd);
}
void machine_halt(void)
{
+ gdbstub_exit(0);
machine_ops.halt();
}
#ifdef CONFIG_KEXEC
void machine_crash_shutdown(struct pt_regs *regs)
{
+ gdbstub_exit(1);
machine_ops.crash_shutdown(regs);
}
#endif
--
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/