1 | /* |
---|
2 | * QEMU System Emulator |
---|
3 | * |
---|
4 | * Copyright (C) 2009-2011, AdaCore |
---|
5 | * |
---|
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
7 | * of this software and associated documentation files (the "Software"), to deal |
---|
8 | * in the Software without restriction, including without limitation the rights |
---|
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
10 | * copies of the Software, and to permit persons to whom the Software is |
---|
11 | * furnished to do so, subject to the following conditions: |
---|
12 | * |
---|
13 | * The above copyright notice and this permission notice shall be included in |
---|
14 | * all copies or substantial portions of the Software. |
---|
15 | * |
---|
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
---|
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
22 | * THE SOFTWARE. |
---|
23 | */ |
---|
24 | |
---|
25 | /* |
---|
26 | * QEMU trace file format. |
---|
27 | * It requires proper definition for uintXX_t where XX is 8, 16, 32 and 64 |
---|
28 | * and target_ulong (32 or 64 bits). |
---|
29 | */ |
---|
30 | |
---|
31 | #ifndef QEMU_TRACE_H |
---|
32 | #define QEMU_TRACE_H |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | /* File header definition. */ |
---|
37 | struct trace_header { |
---|
38 | char magic[12]; |
---|
39 | #define QEMU_TRACE_MAGIC "#QEMU-Traces" |
---|
40 | |
---|
41 | uint8_t version; |
---|
42 | #define QEMU_TRACE_VERSION 1 |
---|
43 | |
---|
44 | /* File kind. */ |
---|
45 | uint8_t kind; |
---|
46 | #define QEMU_TRACE_KIND_RAW 0 |
---|
47 | #define QEMU_TRACE_KIND_HISTORY 1 |
---|
48 | #define QEMU_TRACE_KIND_INFO 2 |
---|
49 | #define QEMU_TRACE_KIND_DECISION_MAP 3 |
---|
50 | #define QEMU_TRACE_KIND_CONSOLIDATED 248 |
---|
51 | |
---|
52 | /* Sizeof (target_pc). Indicates struct trace_entry length. */ |
---|
53 | uint8_t sizeof_target_pc; |
---|
54 | |
---|
55 | /* True if host was big endian. All the trace data used the host |
---|
56 | endianness. */ |
---|
57 | uint8_t big_endian; |
---|
58 | |
---|
59 | /* Target machine (use ELF number) - always in big endian. */ |
---|
60 | uint8_t machine[2]; |
---|
61 | |
---|
62 | uint16_t _pad; |
---|
63 | }; |
---|
64 | |
---|
65 | /* Header is followed by trace entries. */ |
---|
66 | struct trace_entry { |
---|
67 | /* FIXME: import target_ulong */ |
---|
68 | /* target_ulong pc; */ |
---|
69 | uint32_t pc; |
---|
70 | |
---|
71 | uint16_t size; |
---|
72 | uint8_t op; |
---|
73 | }; |
---|
74 | |
---|
75 | struct trace_entry32 { |
---|
76 | uint32_t pc; |
---|
77 | uint16_t size; |
---|
78 | uint8_t op; |
---|
79 | uint8_t _pad[1]; |
---|
80 | }; |
---|
81 | |
---|
82 | struct trace_entry64 { |
---|
83 | uint64_t pc; |
---|
84 | uint16_t size; |
---|
85 | uint8_t op; |
---|
86 | uint8_t _pad[5]; |
---|
87 | }; |
---|
88 | |
---|
89 | /* |
---|
90 | * Trace operations for RAW and HISTORY |
---|
91 | */ |
---|
92 | |
---|
93 | /* _BLOCK means pc .. pc+size-1 was executed. */ |
---|
94 | #define TRACE_OP_BLOCK 0x10 /* Block fully executed. */ |
---|
95 | #define TRACE_OP_FAULT 0x20 /* Fault at pc. */ |
---|
96 | #define TRACE_OP_BR0 0x01 /* Branch 0 taken at pc. */ |
---|
97 | #define TRACE_OP_BR1 0x02 |
---|
98 | |
---|
99 | #define TRACE_OP_SPECIAL 0x80 /* Special info in trace file. */ |
---|
100 | /* Special operations (in size). */ |
---|
101 | #define TRACE_SPECIAL_LOADADDR 0x1 /* Module loaded at PC. */ |
---|
102 | |
---|
103 | /* Only used internally in cpu-exec.c. */ |
---|
104 | #define TRACE_OP_HIST_SET 0x100 /* Set in the map file. */ |
---|
105 | #define TRACE_OP_HIST_CACHE 0x200 /* Has already been searched. */ |
---|
106 | |
---|
107 | /* |
---|
108 | * Decision map operations |
---|
109 | */ |
---|
110 | |
---|
111 | /* Trace conditional jump instruction at address */ |
---|
112 | #define TRACE_OP_TRACE_CONDITIONAL 1 |
---|
113 | |
---|
114 | extern struct trace_entry *trace_current; |
---|
115 | extern int tracefile_enabled; |
---|
116 | |
---|
117 | void trace_init(const char *optarg); |
---|
118 | void trace_cleanup(void); |
---|
119 | void trace_push_entry(void); |
---|
120 | void trace_special(uint16_t subop, uint32_t data); |
---|
121 | #endif /* QEMU_TRACE_H */ |
---|