pintos: Avoid literal control character in Perl variable name.
[pintos-anon] / src / misc / bochs-2.2.6-triple-fault.patch
1 diff -u bochs-2.2.6.orig/cpu/exception.cc bochs-2.2.6/cpu/exception.cc
2 --- bochs-2.2.6.orig/cpu/exception.cc
3 +++ bochs-2.2.6/cpu/exception.cc
4 @@ -841,6 +841,13 @@ void BX_CPU_C::exception(unsigned vector
5  
6    BX_CPU_THIS_PTR errorno++;
7    if (BX_CPU_THIS_PTR errorno >= 3) {
8 +#if BX_GDBSTUB
9 +    if (bx_dbg.gdbstub_enabled) {
10 +        fprintf(stderr, "Triple fault: stopping for gdb\n");
11 +        BX_CPU_THIS_PTR ispanic = 1;
12 +        longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1);
13 +    }
14 +#endif
15  #if BX_RESET_ON_TRIPLE_FAULT
16      BX_ERROR(("exception(): 3rd (%d) exception with no resolution, shutdown status is %02xh, resetting", vector, DEV_cmos_get_reg(0x0f)));
17      debug(BX_CPU_THIS_PTR prev_eip);
18 @@ -860,6 +867,13 @@ void BX_CPU_C::exception(unsigned vector
19  
20    /* if 1st was a double fault (software INT?), then shutdown */
21    if ( (BX_CPU_THIS_PTR errorno==2) && (BX_CPU_THIS_PTR curr_exception[0]==BX_ET_DOUBLE_FAULT) ) {
22 +#if BX_GDBSTUB
23 +    if (bx_dbg.gdbstub_enabled) {
24 +        fprintf(stderr, "Triple fault: stopping for gdb\n");
25 +        BX_CPU_THIS_PTR ispanic = 1;
26 +        longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1);
27 +    }
28 +#endif
29  #if BX_RESET_ON_TRIPLE_FAULT
30      BX_INFO(("exception(): triple fault encountered, shutdown status is %02xh, resetting", DEV_cmos_get_reg(0x0f)));
31      debug(BX_CPU_THIS_PTR prev_eip);
32 diff -u bochs-2.2.6.orig/gdbstub.cc bochs-2.2.6/gdbstub.cc
33 --- bochs-2.2.6.orig/gdbstub.cc
34 +++ bochs-2.2.6/gdbstub.cc
35 @@ -466,19 +466,19 @@ static void debug_loop(void)
36                   
37                   BX_INFO (("stepping"));
38                   stub_trace_flag = 1;
39 +                 bx_cpu.ispanic = 0;
40                   bx_cpu.cpu_loop(-1);
41                   DEV_vga_refresh();
42                   stub_trace_flag = 0;
43                   BX_INFO (("stopped with %x", last_stop_reason));
44                   buf[0] = 'S';
45 -                 if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT ||
46 -                     last_stop_reason == GDBSTUB_TRACE)
47 +                 if (last_stop_reason == GDBSTUB_TRACE && !bx_cpu.ispanic)
48                     {
49                        write_signal(&buf[1], SIGTRAP);
50                     }
51                   else
52                     {
53 -                      write_signal(&buf[1], SIGTRAP);
54 +                      write_signal(&buf[1], SIGSEGV);
55                     }
56                   put_reply(buf);
57                   break;