Commit | Line | Data |
---|---|---|
0f2811d1 DE |
1 | /* Simulator tracing/debugging support. |
2 | Copyright (C) 1997 Free Software Foundation, Inc. | |
3 | Contributed by Cygnus Support. | |
4 | ||
5 | This file is part of GDB, the GNU debugger. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License along | |
18 | with this program; if not, write to the Free Software Foundation, Inc., | |
19 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | /* This file is meant to be included by sim-basics.h. */ | |
22 | ||
23 | #ifndef SIM_TRACE_H | |
24 | #define SIM_TRACE_H | |
25 | ||
23b04e79 MM |
26 | #ifndef __attribute__ |
27 | #if !defined(__GNUC__) || (__GNUC__ < 2) || (__GNUC__ == 2 && __GNU_MINOR__ < 7) | |
28 | #define __attribute__(attr) | |
29 | #endif | |
30 | #endif | |
31 | ||
3971886a AC |
32 | /* Maximum number of traceable entities. */ |
33 | #ifndef MAX_TRACE_VALUES | |
34 | #define MAX_TRACE_VALUES 12 | |
35 | #endif | |
36 | ||
37 | /* Standard traceable entities. */ | |
38 | #define TRACE_INSN_IDX 0 | |
39 | #define TRACE_DECODE_IDX 1 | |
40 | #define TRACE_EXTRACT_IDX 2 | |
41 | #define TRACE_LINENUM_IDX 3 | |
42 | #define TRACE_MEMORY_IDX 4 | |
43 | #define TRACE_MODEL_IDX 5 | |
44 | #define TRACE_ALU_IDX 6 | |
45 | #define TRACE_CORE_IDX 7 | |
46 | #define TRACE_EVENTS_IDX 8 | |
47 | #define TRACE_FPU_IDX 9 | |
48 | #define TRACE_NEXT_IDX 16 /* simulator specific trace bits begin here */ | |
49 | ||
50 | /* Masks so WITH_TRACE can have symbolic values. */ | |
51 | #define TRACE_insn 1 | |
52 | #define TRACE_decode 2 | |
53 | #define TRACE_extract 4 | |
54 | #define TRACE_linenum 8 | |
55 | #define TRACE_memory 16 | |
56 | #define TRACE_model 32 | |
57 | #define TRACE_alu 64 | |
58 | #define TRACE_core 128 | |
59 | #define TRACE_events 256 | |
60 | #define TRACE_fpu 512 | |
61 | ||
62 | /* Preprocessor macros to simplify tests of WITH_TRACE. */ | |
63 | #define WITH_TRACE_INSN_P (WITH_TRACE & TRACE_insn) | |
64 | #define WITH_TRACE_DECODE_P (WITH_TRACE & TRACE_decode) | |
65 | #define WITH_TRACE_EXTRACT_P (WITH_TRACE & TRACE_extract) | |
66 | #define WITH_TRACE_LINENUM_P (WITH_TRACE & TRACE_linenum) | |
67 | #define WITH_TRACE_MEMORY_P (WITH_TRACE & TRACE_memory) | |
68 | #define WITH_TRACE_MODEL_P (WITH_TRACE & TRACE_model) | |
69 | #define WITH_TRACE_ALU_P (WITH_TRACE & TRACE_alu) | |
70 | #define WITH_TRACE_CORE_P (WITH_TRACE & TRACE_core) | |
71 | #define WITH_TRACE_EVENTS_P (WITH_TRACE & TRACE_events) | |
72 | #define WITH_TRACE_FPU_P (WITH_TRACE & TRACE_fpu) | |
73 | ||
74 | /* Tracing install handler. */ | |
75 | MODULE_INSTALL_FN trace_install; | |
76 | \f | |
77 | /* Struct containing all trace data. */ | |
78 | ||
79 | typedef struct { | |
80 | /* Boolean array of specified tracing flags. */ | |
81 | /* ??? It's not clear that using an array vs a bit mask is faster. | |
82 | Consider the case where one wants to test whether any of several bits | |
83 | are set. */ | |
84 | char trace_flags[MAX_TRACE_VALUES]; | |
85 | #define TRACE_FLAGS(t) ((t)->trace_flags) | |
86 | ||
87 | /* Tracing output goes to this or stderr if NULL. | |
88 | We can't store `stderr' here as stderr goes through a callback. */ | |
89 | FILE *trace_file; | |
90 | #define TRACE_FILE(t) ((t)->trace_file) | |
91 | } TRACE_DATA; | |
d0adfefd MM |
92 | |
93 | /* Structure containing constant stuff to pass to trace_one_insn */ | |
94 | ||
95 | typedef struct { | |
96 | const char *phase; /* which phase this in (decode,insn) */ | |
97 | char **p_filename; /* ptr to filename insns where defined in */ | |
98 | char **p_name; /* ptr to instruction name */ | |
99 | int linenum; /* line number of line where insn is defined */ | |
100 | } TRACE_INSN_DATA; | |
3971886a AC |
101 | \f |
102 | /* Usage macros. */ | |
103 | ||
104 | #define CPU_TRACE_FLAGS(cpu) TRACE_FLAGS (CPU_TRACE_DATA (cpu)) | |
105 | ||
15d8adf5 DE |
106 | /* forward reference */ |
107 | struct _sim_cpu; | |
0f2811d1 | 108 | |
15d8adf5 | 109 | /* Tracing support. */ |
0f2811d1 DE |
110 | |
111 | /* Return non-zero if tracing of IDX is enabled for CPU. */ | |
112 | #define TRACE_P(cpu,idx) \ | |
113 | ((WITH_TRACE & (1 << (idx))) != 0 \ | |
114 | && CPU_TRACE_FLAGS (cpu)[idx] != 0) | |
115 | ||
116 | /* Non-zero if "--trace-insn" specified for CPU. */ | |
117 | #define TRACE_INSN_P(cpu) TRACE_P (cpu, TRACE_INSN_IDX) | |
a7724171 MM |
118 | /* Non-zero if "--trace-linenum" specified for CPU. */ |
119 | #define TRACE_LINENUM_P(cpu) TRACE_P (cpu, TRACE_LINENUM_IDX) | |
15d8adf5 DE |
120 | /* Non-zero if "--trace-decode" specified for CPU. */ |
121 | #define TRACE_DECODE_P(cpu) TRACE_P (cpu, TRACE_DECODE_IDX) | |
3971886a AC |
122 | /* Non-zero if "--trace-fpu" specified for CPU. */ |
123 | #define TRACE_FPU_P(cpu) TRACE_P (cpu, TRACE_FPU_IDX) | |
0f2811d1 | 124 | |
d0adfefd MM |
125 | extern void trace_one_insn PARAMS ((SIM_DESC, sim_cpu *, |
126 | address_word, int, | |
127 | const TRACE_INSN_DATA *)); | |
a7724171 | 128 | |
23b04e79 MM |
129 | extern void trace_printf PARAMS ((SIM_DESC, sim_cpu *, const char *, ...)) |
130 | __attribute__((format (printf, 3, 4))); | |
0f2811d1 | 131 | |
3971886a AC |
132 | /* Debug support. |
133 | This is included here because there isn't enough of it to justify | |
134 | a sim-debug.h. */ | |
0f2811d1 | 135 | |
0f2811d1 DE |
136 | /* Return non-zero if debugging of IDX for CPU is enabled. */ |
137 | #define DEBUG_P(cpu, idx) \ | |
138 | ((WITH_DEBUG & (1 << (idx))) != 0 \ | |
139 | && CPU_DEBUG_FLAGS (cpu)[idx] != 0) | |
140 | ||
141 | /* Non-zero if "--debug-insn" specified. */ | |
142 | #define DEBUG_INSN_P(cpu) DEBUG_P (cpu, DEBUG_INSN_IDX) | |
143 | ||
23b04e79 MM |
144 | extern void debug_printf PARAMS ((struct _sim_cpu *, const char *, ...)) |
145 | __attribute__((format (printf, 2, 3))); | |
0f2811d1 DE |
146 | |
147 | #endif /* SIM_TRACE_H */ |