1#ifndef REPLAY_INTERNAL_H
2#define REPLAY_INTERNAL_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16enum ReplayEvents {
17
18 EVENT_INSTRUCTION,
19
20 EVENT_INTERRUPT,
21
22 EVENT_EXCEPTION,
23
24 EVENT_ASYNC,
25
26 EVENT_SHUTDOWN,
27
28 EVENT_CHAR_WRITE,
29
30 EVENT_CHAR_READ_ALL,
31 EVENT_CHAR_READ_ALL_ERROR,
32
33
34 EVENT_CLOCK,
35 EVENT_CLOCK_LAST = EVENT_CLOCK + REPLAY_CLOCK_COUNT - 1,
36
37
38 EVENT_CHECKPOINT,
39 EVENT_CHECKPOINT_LAST = EVENT_CHECKPOINT + CHECKPOINT_COUNT - 1,
40
41 EVENT_END,
42 EVENT_COUNT
43};
44
45
46
47enum ReplayAsyncEventKind {
48 REPLAY_ASYNC_EVENT_BH,
49 REPLAY_ASYNC_EVENT_INPUT,
50 REPLAY_ASYNC_EVENT_INPUT_SYNC,
51 REPLAY_ASYNC_EVENT_CHAR_READ,
52 REPLAY_ASYNC_EVENT_BLOCK,
53 REPLAY_ASYNC_COUNT
54};
55
56typedef enum ReplayAsyncEventKind ReplayAsyncEventKind;
57
58typedef struct ReplayState {
59
60 int64_t cached_clock[REPLAY_CLOCK_COUNT];
61
62 uint64_t current_step;
63
64 int instructions_count;
65} ReplayState;
66extern ReplayState replay_state;
67
68extern unsigned int replay_data_kind;
69
70
71extern FILE *replay_file;
72
73void replay_put_byte(uint8_t byte);
74void replay_put_event(uint8_t event);
75void replay_put_word(uint16_t word);
76void replay_put_dword(uint32_t dword);
77void replay_put_qword(int64_t qword);
78void replay_put_array(const uint8_t *buf, size_t size);
79
80uint8_t replay_get_byte(void);
81uint16_t replay_get_word(void);
82uint32_t replay_get_dword(void);
83int64_t replay_get_qword(void);
84void replay_get_array(uint8_t *buf, size_t *size);
85void replay_get_array_alloc(uint8_t **buf, size_t *size);
86
87
88
89void replay_mutex_init(void);
90void replay_mutex_destroy(void);
91void replay_mutex_lock(void);
92void replay_mutex_unlock(void);
93
94
95void replay_check_error(void);
96
97
98
99void replay_finish_event(void);
100
101
102void replay_fetch_data_kind(void);
103
104
105void replay_save_instructions(void);
106
107
108
109bool replay_next_event_is(int event);
110
111
112
113
114void replay_read_next_clock(unsigned int kind);
115
116
117
118
119void replay_init_events(void);
120
121void replay_finish_events(void);
122
123void replay_enable_events(void);
124
125void replay_flush_events(void);
126
127void replay_clear_events(void);
128
129bool replay_has_events(void);
130
131void replay_save_events(int checkpoint);
132
133void replay_read_events(int checkpoint);
134
135void replay_add_event(ReplayAsyncEventKind event_kind, void *opaque,
136 void *opaque2, uint64_t id);
137
138
139
140
141void replay_save_input_event(InputEvent *evt);
142
143InputEvent *replay_read_input_event(void);
144
145void replay_add_input_event(struct InputEvent *event);
146
147void replay_add_input_sync_event(void);
148
149
150
151
152void replay_event_char_read_run(void *opaque);
153
154void replay_event_char_read_save(void *opaque);
155
156void *replay_event_char_read_load(void);
157
158#endif
159