forked from DrY-Courses/OSF16project2
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbochs-2.2.6-triple-fault.patch
57 lines (54 loc) · 2.34 KB
/
bochs-2.2.6-triple-fault.patch
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
diff -u bochs-2.2.6.orig/cpu/exception.cc bochs-2.2.6/cpu/exception.cc
--- bochs-2.2.6.orig/cpu/exception.cc
+++ bochs-2.2.6/cpu/exception.cc
@@ -841,6 +841,13 @@ void BX_CPU_C::exception(unsigned vector
BX_CPU_THIS_PTR errorno++;
if (BX_CPU_THIS_PTR errorno >= 3) {
+#if BX_GDBSTUB
+ if (bx_dbg.gdbstub_enabled) {
+ fprintf(stderr, "Triple fault: stopping for gdb\n");
+ BX_CPU_THIS_PTR ispanic = 1;
+ longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1);
+ }
+#endif
#if BX_RESET_ON_TRIPLE_FAULT
BX_ERROR(("exception(): 3rd (%d) exception with no resolution, shutdown status is %02xh, resetting", vector, DEV_cmos_get_reg(0x0f)));
debug(BX_CPU_THIS_PTR prev_eip);
@@ -860,6 +867,13 @@ void BX_CPU_C::exception(unsigned vector
/* if 1st was a double fault (software INT?), then shutdown */
if ( (BX_CPU_THIS_PTR errorno==2) && (BX_CPU_THIS_PTR curr_exception[0]==BX_ET_DOUBLE_FAULT) ) {
+#if BX_GDBSTUB
+ if (bx_dbg.gdbstub_enabled) {
+ fprintf(stderr, "Triple fault: stopping for gdb\n");
+ BX_CPU_THIS_PTR ispanic = 1;
+ longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1);
+ }
+#endif
#if BX_RESET_ON_TRIPLE_FAULT
BX_INFO(("exception(): triple fault encountered, shutdown status is %02xh, resetting", DEV_cmos_get_reg(0x0f)));
debug(BX_CPU_THIS_PTR prev_eip);
diff -u bochs-2.2.6.orig/gdbstub.cc bochs-2.2.6/gdbstub.cc
--- bochs-2.2.6.orig/gdbstub.cc
+++ bochs-2.2.6/gdbstub.cc
@@ -466,19 +466,19 @@ static void debug_loop(void)
BX_INFO (("stepping"));
stub_trace_flag = 1;
+ bx_cpu.ispanic = 0;
bx_cpu.cpu_loop(-1);
DEV_vga_refresh();
stub_trace_flag = 0;
BX_INFO (("stopped with %x", last_stop_reason));
buf[0] = 'S';
- if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT ||
- last_stop_reason == GDBSTUB_TRACE)
+ if (last_stop_reason == GDBSTUB_TRACE && !bx_cpu.ispanic)
{
write_signal(&buf[1], SIGTRAP);
}
else
{
- write_signal(&buf[1], SIGTRAP);
+ write_signal(&buf[1], SIGSEGV);
}
put_reply(buf);
break;