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