Don't call bx_gdbstub_exception when we're not compiling the gdb stub.
[pintos-anon] / src / misc / bochs-2.2.6-page-fault-segv.patch
1 Index: bochs-2.2.6/cpu/exception.cc
2 diff -u bochs-2.2.6/cpu/exception.cc\~ bochs-2.2.6/cpu/exception.cc
3 --- bochs-2.2.6/cpu/exception.cc~ 2006-09-28 15:51:39.000000000 -0700
4 +++ bochs-2.2.6/cpu/exception.cc 2006-12-08 11:14:33.000000000 -0800
5 @@ -1033,6 +1033,10 @@ void BX_CPU_C::exception(unsigned vector
6      BX_CPU_THIS_PTR curr_exception[0] = exception_type;
7    }
8  
9 +#if BX_GDBSTUB
10 +  bx_gdbstub_exception(vector);
11 +#endif
12 +
13  #if BX_CPU_LEVEL >= 2
14    if (!real_mode()) {
15      BX_CPU_THIS_PTR interrupt(vector, 0, push_error, error_code);
16 Index: bochs-2.2.6/gdbstub.cc
17 diff -u bochs-2.2.6/gdbstub.cc\~ bochs-2.2.6/gdbstub.cc
18 --- bochs-2.2.6/gdbstub.cc~ 2006-09-28 15:51:39.000000000 -0700
19 +++ bochs-2.2.6/gdbstub.cc 2006-12-08 11:12:03.000000000 -0800
20 @@ -26,6 +26,7 @@ static int last_stop_reason = GDBSTUB_ST
21  #define GDBSTUB_EXECUTION_BREAKPOINT    (0xac1)
22  #define GDBSTUB_TRACE                   (0xac2)
23  #define GDBSTUB_USER_BREAK              (0xac3)
24 +#define GDBSTUB_EXCEPTION_0E            (0xac4)
25  
26  static int listen_socket_fd;
27  static int socket_fd;
28 @@ -271,6 +272,12 @@ int bx_gdbstub_check(unsigned int eip)
29     return(GDBSTUB_STOP_NO_REASON);
30  }
31  
32 +void bx_gdbstub_exception(unsigned int nr) 
33 +{
34 +    if (nr == 0x0e)
35 +        last_stop_reason = GDBSTUB_EXCEPTION_0E;
36 +}
37 +
38  static int remove_breakpoint(unsigned int addr, int len)
39  {
40     unsigned int i;
41 @@ -452,6 +459,10 @@ static void debug_loop(void)
42                     {
43                        write_signal(&buf[1], SIGTRAP);
44                     }
45 +                 else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
46 +                   {
47 +                      write_signal(&buf[1], SIGSEGV);
48 +                   }
49                   else
50                     {
51                        write_signal(&buf[1], 0);
52 @@ -476,10 +487,14 @@ static void debug_loop(void)
53                     {
54                        write_signal(&buf[1], SIGTRAP);
55                     }
56 -                 else
57 +                 else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
58                     {
59                        write_signal(&buf[1], SIGSEGV);
60                     }
61 +                 else
62 +                   {
63 +                      write_signal(&buf[1], 0);
64 +                   }
65                   put_reply(buf);
66                   break;
67                }
68 Index: bochs-2.2.6/bochs.h
69 diff -u bochs-2.2.6/bochs.h\~ bochs-2.2.6/bochs.h
70 --- bochs-2.2.6/bochs.h~ 2006-09-28 15:51:39.000000000 -0700
71 +++ bochs-2.2.6/bochs.h 2006-12-08 11:14:19.000000000 -0800
72 @@ -375,6 +375,7 @@ BOCHSAPI extern logfunc_t *genlog;
73  // defines for GDB stub
74  void bx_gdbstub_init(int argc, char* argv[]);
75  int bx_gdbstub_check(unsigned int eip);
76 +void bx_gdbstub_exception(unsigned int nr);
77  #define GDBSTUB_STOP_NO_REASON   (0xac0)
78  
79  #if BX_SUPPORT_SMP