]>
Commit | Line | Data |
---|---|---|
8eda206e PD |
1 | /* |
2 | * replay-time.c | |
3 | * | |
4 | * Copyright (c) 2010-2015 Institute for System Programming | |
5 | * of the Russian Academy of Sciences. | |
6 | * | |
7 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
8 | * See the COPYING file in the top-level directory. | |
9 | * | |
10 | */ | |
11 | ||
d38ea87a | 12 | #include "qemu/osdep.h" |
8eda206e PD |
13 | #include "sysemu/replay.h" |
14 | #include "replay-internal.h" | |
15 | #include "qemu/error-report.h" | |
16 | ||
74c0b816 | 17 | int64_t replay_save_clock(ReplayClockKind kind, int64_t clock, int64_t raw_icount) |
8eda206e | 18 | { |
8eda206e | 19 | if (replay_file) { |
d759c951 AB |
20 | g_assert(replay_mutex_locked()); |
21 | ||
74c0b816 PB |
22 | /* Due to the caller's locking requirements we get the icount from it |
23 | * instead of using replay_save_instructions(). | |
24 | */ | |
25 | replay_advance_current_step(raw_icount); | |
8eda206e PD |
26 | replay_put_event(EVENT_CLOCK + kind); |
27 | replay_put_qword(clock); | |
8eda206e PD |
28 | } |
29 | ||
30 | return clock; | |
31 | } | |
32 | ||
33 | void replay_read_next_clock(ReplayClockKind kind) | |
34 | { | |
f186d64d | 35 | unsigned int read_kind = replay_state.data_kind - EVENT_CLOCK; |
8eda206e PD |
36 | |
37 | assert(read_kind == kind); | |
38 | ||
39 | int64_t clock = replay_get_qword(); | |
40 | ||
41 | replay_check_error(); | |
42 | replay_finish_event(); | |
43 | ||
44 | replay_state.cached_clock[read_kind] = clock; | |
45 | } | |
46 | ||
47 | /*! Reads next clock event from the input. */ | |
48 | int64_t replay_read_clock(ReplayClockKind kind) | |
49 | { | |
d759c951 AB |
50 | g_assert(replay_file && replay_mutex_locked()); |
51 | ||
8eda206e PD |
52 | replay_account_executed_instructions(); |
53 | ||
54 | if (replay_file) { | |
55 | int64_t ret; | |
8eda206e PD |
56 | if (replay_next_event_is(EVENT_CLOCK + kind)) { |
57 | replay_read_next_clock(kind); | |
58 | } | |
59 | ret = replay_state.cached_clock[kind]; | |
8eda206e PD |
60 | |
61 | return ret; | |
62 | } | |
63 | ||
64 | error_report("REPLAY INTERNAL ERROR %d", __LINE__); | |
65 | exit(1); | |
66 | } |