2 # Parent adebc6b144a3a0cb9c22cc939431ace635414d0e
4 diff -r adebc6b144a3 cpu-defs.h
5 --- a/cpu-defs.h Mon Aug 30 13:09:19 2010 -0400
6 +++ b/cpu-defs.h Tue Aug 31 12:15:14 2010 -0400
8 #define EXCP_HLT 0x10001 /* hlt instruction reached */
9 #define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */
10 #define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */
11 +#define EXCP_TRIPLE 0x10004 /* cpu encountered triple fault */
13 #define TB_JMP_CACHE_BITS 12
14 #define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)
15 diff -r adebc6b144a3 gdbstub.c
16 --- a/gdbstub.c Mon Aug 30 13:09:19 2010 -0400
17 +++ b/gdbstub.c Tue Aug 31 12:15:14 2010 -0400
23 +int gdbserver_running(void)
25 + return gdbserver_state != NULL;
27 diff -r adebc6b144a3 gdbstub.h
28 --- a/gdbstub.h Mon Aug 30 13:09:19 2010 -0400
29 +++ b/gdbstub.h Tue Aug 31 12:15:14 2010 -0400
32 int gdbserver_start(const char *port);
34 +int gdbserver_running(void);
35 /* Get or set a register. Returns the size of the register. */
36 typedef int (*gdb_reg_cb)(CPUState *env, uint8_t *buf, int reg);
37 void gdb_register_coprocessor(CPUState *env,
38 diff -r adebc6b144a3 target-i386/op_helper.c
39 --- a/target-i386/op_helper.c Mon Aug 30 13:09:19 2010 -0400
40 +++ b/target-i386/op_helper.c Tue Aug 31 12:15:14 2010 -0400
41 @@ -1297,8 +1297,18 @@
43 qemu_log_mask(CPU_LOG_RESET, "Triple fault\n");
46 qemu_system_reset_request();
49 + // QEMU traditionally resets the machine on triple fault
50 + // because programs written for 286 protected mode would exit
51 + // protected mode by intentionally triple faulting the machine
52 + // (after setting the boot vector to point to their code).
53 + // This sucks for debugging programs that were written after
54 + // 1985, so we instead halt the machine for inspection.
60 diff -r adebc6b144a3 vl.c
61 --- a/vl.c Mon Aug 30 13:09:19 2010 -0400
62 +++ b/vl.c Tue Aug 31 12:15:14 2010 -0400
63 @@ -4057,6 +4057,15 @@
67 + if (ret == EXCP_TRIPLE) {
68 + cpu_dump_state(env, stderr, fprintf, 0);
69 + fprintf(stderr, "Triple fault. Halting for inspection via QEMU monitor.\n");
70 + if (gdbserver_running())
76 if (ret == EXCP_DEBUG) {
77 gdb_set_stop_cpu(env);