1 | /* |
---|
2 | * QEMU System Emulator |
---|
3 | * |
---|
4 | * Copyright (C) 2009, 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 | /* XXX really not always right */ |
---|
35 | /* XXX Added for covoar so this compiles */ |
---|
36 | typedef uint32_t target_ulong; |
---|
37 | |
---|
38 | /* File header definition. */ |
---|
39 | struct trace_header |
---|
40 | { |
---|
41 | char magic[12]; |
---|
42 | #define QEMU_TRACE_MAGIC "#QEMU-Traces" |
---|
43 | |
---|
44 | uint8_t version; |
---|
45 | #define QEMU_TRACE_VERSION 1 |
---|
46 | |
---|
47 | /* File kind. */ |
---|
48 | uint8_t kind; |
---|
49 | #define QEMU_TRACE_KIND_RAW 0 |
---|
50 | #define QEMU_TRACE_KIND_HISTORY 1 |
---|
51 | #define QEMU_TRACE_KIND_INFO 2 |
---|
52 | #define QEMU_TRACE_KIND_DECISION_MAP 3 |
---|
53 | #define QEMU_TRACE_KIND_CONSOLIDATED 248 |
---|
54 | |
---|
55 | /* Sizeof (target_pc). Indicates struct trace_entry length. */ |
---|
56 | uint8_t sizeof_target_pc; |
---|
57 | |
---|
58 | /* True if host was big endian. All the trace data used the host |
---|
59 | endianness. */ |
---|
60 | uint8_t big_endian; |
---|
61 | |
---|
62 | /* Target machine (use ELF number) - always in big endian. */ |
---|
63 | uint8_t machine[2]; |
---|
64 | |
---|
65 | uint16_t _pad; |
---|
66 | }; |
---|
67 | |
---|
68 | /* Header is followed by trace entries. */ |
---|
69 | struct trace_entry |
---|
70 | { |
---|
71 | target_ulong pc; |
---|
72 | uint16_t size; |
---|
73 | uint8_t op; |
---|
74 | }; |
---|
75 | |
---|
76 | struct trace_entry32 |
---|
77 | { |
---|
78 | uint32_t pc; |
---|
79 | uint16_t size; |
---|
80 | uint8_t op; |
---|
81 | uint8_t _pad[1]; |
---|
82 | }; |
---|
83 | |
---|
84 | struct trace_entry64 |
---|
85 | { |
---|
86 | uint64_t pc; |
---|
87 | uint16_t size; |
---|
88 | uint8_t op; |
---|
89 | uint8_t _pad[5]; |
---|
90 | }; |
---|
91 | |
---|
92 | /* |
---|
93 | * Trace operations for RAW and HISTORY |
---|
94 | */ |
---|
95 | |
---|
96 | /* _BLOCK means pc .. pc+size-1 was executed. */ |
---|
97 | #define TRACE_OP_BLOCK 0x10 /* Block fully executed. */ |
---|
98 | #define TRACE_OP_FAULT 0x20 /* Fault at pc. */ |
---|
99 | #define TRACE_OP_DYN 0x40 /* Dynamic branch. */ |
---|
100 | #define TRACE_OP_BR0 0x01 /* Branch taken "in direction 0". */ |
---|
101 | #define TRACE_OP_BR1 0x02 /* Branch taken "in direction 1". */ |
---|
102 | #define TRACE_OP_BR2 0x04 |
---|
103 | #define TRACE_OP_BR3 0x08 |
---|
104 | |
---|
105 | /* |
---|
106 | * Decision map operations |
---|
107 | */ |
---|
108 | #define TRACE_OP_TRACE_CONDITIONAL 1 |
---|
109 | /* Trace conditional jump instruction at address */ |
---|
110 | |
---|
111 | extern struct trace_entry *trace_current; |
---|
112 | extern int tracefile_enabled; |
---|
113 | extern int tracefile_nobuf; |
---|
114 | extern int tracefile_history; |
---|
115 | |
---|
116 | void trace_init (const char *optarg); |
---|
117 | void trace_push_entry (void); |
---|
118 | |
---|
119 | #endif /* QEMU_TRACE_H */ |
---|