1 diff --git a/bochs.h b/bochs.h
2 index c2d6c6b..d37cf12 100644
5 @@ -392,6 +392,7 @@ BOCHSAPI extern logfunc_t *genlog;
6 void bx_gdbstub_init(void);
7 void bx_gdbstub_break(void);
8 int bx_gdbstub_check(unsigned int eip);
9 +void bx_gdbstub_exception(unsigned int nr);
10 #define GDBSTUB_STOP_NO_REASON (0xac0)
13 @@ -589,4 +590,6 @@ BX_CPP_INLINE Bit64u bx_bswap64(Bit64u val64)
14 #define CopyHostQWordLittleEndian(hostAddrDst, hostAddrSrc) \
15 (* (Bit64u *)(hostAddrDst)) = (* (Bit64u *)(hostAddrSrc));
19 #endif /* BX_BOCHS_H */
20 diff --git a/cpu/exception.cc b/cpu/exception.cc
21 index db38d1b..b2c5f29 100644
22 --- a/cpu/exception.cc
23 +++ b/cpu/exception.cc
24 @@ -914,6 +914,10 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code)
26 BX_CPU_THIS_PTR last_exception_type = exception_type;
29 + bx_gdbstub_exception(vector);
33 push_error = 0; // not INT, no error code pushed
35 diff --git a/gdbstub.cc b/gdbstub.cc
36 index da600b4..577938d 100644
39 @@ -49,6 +49,7 @@ static int last_stop_reason = GDBSTUB_STOP_NO_REASON;
40 #define GDBSTUB_EXECUTION_BREAKPOINT (0xac1)
41 #define GDBSTUB_TRACE (0xac2)
42 #define GDBSTUB_USER_BREAK (0xac3)
43 +#define GDBSTUB_EXCEPTION_0E (0xac4)
45 static bx_list_c *gdbstub_list;
46 static int listen_socket_fd;
47 @@ -317,6 +318,12 @@ int bx_gdbstub_check(unsigned int eip)
48 return GDBSTUB_STOP_NO_REASON;
51 +void bx_gdbstub_exception(unsigned int nr)
54 + last_stop_reason = GDBSTUB_EXCEPTION_0E;
57 static int remove_breakpoint(unsigned addr, int len)
60 @@ -487,6 +494,10 @@ static void debug_loop(void)
62 write_signal(&buf[1], SIGTRAP);
64 + else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
66 + write_signal(&buf[1], SIGSEGV);
70 write_signal(&buf[1], 0);
71 @@ -514,6 +525,10 @@ static void debug_loop(void)
73 write_signal(&buf[1], SIGTRAP);
75 + else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
77 + write_signal(&buf[1], SIGSEGV);
81 write_signal(&buf[1], SIGTRAP);
82 diff --git a/iodev/pit82c54.cc b/iodev/pit82c54.cc
83 index 09dcd8e..7e335d4 100644
84 --- a/iodev/pit82c54.cc
85 +++ b/iodev/pit82c54.cc
91 #define LOG_THIS this->
94 @@ -410,7 +411,14 @@ void BX_CPP_AttrRegparmN(1) pit_82C54::clock(Bit8u cnum)
96 if (thisctr.count_written) {
97 if (thisctr.triggerGATE || thisctr.first_pass) {
98 - set_count(thisctr, thisctr.inlatch);
99 + //set_count(thisctr, thisctr.inlatch);
100 + unsigned n = thisctr.inlatch;
101 + if (jitter && n > 5) {
102 + n *= (double) rand() / RAND_MAX;
106 + set_count(thisctr, n);
107 thisctr.next_change_time=(thisctr.count_binary-1) & 0xFFFF;
108 thisctr.null_count=0;
109 if (thisctr.inlatch==1) {
110 diff --git a/main.cc b/main.cc
111 index 0f11e31..008f05f 100644
114 @@ -101,6 +101,7 @@ BOCHSAPI BX_CPU_C bx_cpu;
115 BOCHSAPI BX_MEM_C bx_mem;
117 char *bochsrc_filename = NULL;
120 void bx_print_header()
122 @@ -639,6 +640,13 @@ int bx_init_main(int argc, char *argv[])
123 else SIM->get_param_string(BXPN_DEBUGGER_LOG_FILENAME)->set(argv[arg]);
126 + else if (!strcmp ("-j", argv[arg])) {
127 + if (++arg >= argc) BX_PANIC(("-j must be followed by a number"));
130 + srand (atoi (argv[arg]));
133 else if (!strcmp("-f", argv[arg])) {
134 if (++arg >= argc) BX_PANIC(("-f must be followed by a filename"));
135 else bochsrc_filename = argv[arg];