/src/qemu/replay/replay-time.c
Line | Count | Source |
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 | | |
12 | | #include "qemu/osdep.h" |
13 | | #include "system/replay.h" |
14 | | #include "replay-internal.h" |
15 | | #include "qemu/error-report.h" |
16 | | |
17 | | int64_t replay_save_clock(ReplayClockKind kind, int64_t clock, |
18 | | int64_t raw_icount) |
19 | 0 | { |
20 | 0 | g_assert(replay_file); |
21 | 0 | g_assert(replay_mutex_locked()); |
22 | | |
23 | | /* |
24 | | * Due to the caller's locking requirements we get the icount from it |
25 | | * instead of using replay_save_instructions(). |
26 | | */ |
27 | 0 | replay_advance_current_icount(raw_icount); |
28 | 0 | replay_put_event(EVENT_CLOCK + kind); |
29 | 0 | replay_put_qword(clock); |
30 | |
|
31 | 0 | return clock; |
32 | 0 | } |
33 | | |
34 | | void replay_read_next_clock(ReplayClockKind kind) |
35 | 0 | { |
36 | 0 | unsigned int read_kind = replay_state.data_kind - EVENT_CLOCK; |
37 | |
|
38 | 0 | assert(read_kind == kind); |
39 | |
|
40 | 0 | int64_t clock = replay_get_qword(); |
41 | |
|
42 | 0 | replay_check_error(); |
43 | 0 | replay_finish_event(); |
44 | |
|
45 | 0 | replay_state.cached_clock[read_kind] = clock; |
46 | 0 | } |
47 | | |
48 | | /*! Reads next clock event from the input. */ |
49 | | int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount) |
50 | 0 | { |
51 | 0 | g_assert(replay_file && replay_mutex_locked()); |
52 | | |
53 | 0 | replay_advance_current_icount(raw_icount); |
54 | |
|
55 | 0 | if (replay_next_event_is(EVENT_CLOCK + kind)) { |
56 | 0 | replay_read_next_clock(kind); |
57 | 0 | } |
58 | 0 | return replay_state.cached_clock[kind]; |
59 | 0 | } |