Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au> | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License as published by | |
3fd725ef | 7 | the Free Software Foundation; either version 3 of the License, or |
c906108c SS |
8 | (at your option) any later version. |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU General Public License | |
51b318de | 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
17 | |
18 | */ | |
19 | ||
20 | ||
21 | #ifndef _DEBUG_H_ | |
22 | #define _DEBUG_H_ | |
23 | ||
24 | #include "filter_filename.h" | |
25 | ||
26 | typedef enum { | |
27 | trace_invalid, | |
28 | trace_tbd, | |
29 | /**/ | |
30 | trace_gdb, | |
31 | trace_os_emul, | |
32 | /**/ | |
33 | trace_events, | |
34 | trace_device_tree, | |
35 | trace_devices, | |
36 | trace_binary_device, | |
37 | trace_com_device, | |
38 | trace_console_device, | |
39 | trace_core_device, | |
40 | trace_disk_device, | |
41 | trace_eeprom_device, | |
42 | trace_file_device, | |
43 | trace_glue_device, | |
44 | trace_halt_device, | |
45 | trace_htab_device, | |
46 | trace_icu_device, | |
47 | trace_ide_device, | |
48 | trace_memory_device, | |
49 | trace_opic_device, | |
50 | trace_pal_device, | |
51 | trace_pass_device, | |
52 | trace_phb_device, | |
00a0b122 JS |
53 | trace_sem_device, |
54 | trace_shm_device, | |
c906108c SS |
55 | trace_stack_device, |
56 | trace_register_device, | |
57 | trace_vm_device, | |
58 | /**/ | |
59 | trace_disklabel_package, | |
60 | /**/ | |
61 | trace_semantics, | |
62 | trace_idecode, | |
63 | trace_alu, | |
64 | trace_load_store, | |
65 | trace_model, | |
66 | /**/ | |
67 | trace_vm, | |
68 | trace_core, | |
69 | trace_interrupts, | |
70 | trace_psim, | |
71 | trace_device_init, | |
72 | trace_cpu, | |
73 | trace_breakpoint, | |
74 | trace_opts, | |
75 | trace_print_info, | |
76 | trace_print_device_tree, | |
77 | trace_dump_device_tree, | |
78 | nr_trace_options | |
79 | } trace_options; | |
80 | ||
81 | ||
82 | ||
83 | extern int ppc_trace[nr_trace_options]; | |
84 | ||
85 | /* simple */ | |
86 | #define TRACE(OBJECT, ARGS) \ | |
87 | do { \ | |
88 | if (WITH_TRACE) { \ | |
89 | if (ppc_trace[OBJECT]) { \ | |
a6760b61 PA |
90 | sim_io_printf_filtered("%s:%d: ", filter_filename(__FILE__), __LINE__); \ |
91 | sim_io_printf_filtered ARGS; \ | |
c906108c SS |
92 | } \ |
93 | } \ | |
94 | } while (0) | |
95 | ||
96 | /* issue */ | |
97 | #define ITRACE(OBJECT, ARGS) \ | |
98 | do { \ | |
99 | if (WITH_TRACE) { \ | |
100 | if (ppc_trace[OBJECT]) { \ | |
a6760b61 PA |
101 | sim_io_printf_filtered("%s:%d:0x%08lx:%s ", itable[MY_INDEX].file, itable[MY_INDEX].line_nr, (long)cia, itable[MY_INDEX].name); \ |
102 | sim_io_printf_filtered ARGS; \ | |
c906108c SS |
103 | } \ |
104 | } \ | |
105 | } while (0) | |
106 | ||
107 | /* device */ | |
108 | #define DTRACE(OBJECT, ARGS) \ | |
109 | do { \ | |
110 | if (WITH_TRACE) { \ | |
111 | int trace_device = device_trace(me); \ | |
112 | if (ppc_trace[trace_devices] \ | |
113 | || ppc_trace[trace_##OBJECT##_device] \ | |
114 | || trace_device) { \ | |
a6760b61 PA |
115 | sim_io_printf_filtered("%s:%d:%s:%s%s ", \ |
116 | filter_filename(__FILE__), __LINE__, #OBJECT, \ | |
117 | trace_device ? device_path(me) : "", \ | |
118 | trace_device ? ":" : ""); \ | |
119 | sim_io_printf_filtered ARGS; \ | |
c906108c SS |
120 | } \ |
121 | } \ | |
122 | } while (0) | |
123 | ||
124 | /* device instance */ | |
125 | #define DITRACE(OBJECT, ARGS) \ | |
126 | do { \ | |
127 | if (WITH_TRACE) { \ | |
128 | device *me = device_instance_device(instance); \ | |
129 | int trace_device = device_trace(me); \ | |
130 | if (ppc_trace[trace_devices] \ | |
131 | || ppc_trace[trace_##OBJECT##_device] \ | |
132 | || trace_device) { \ | |
a6760b61 PA |
133 | sim_io_printf_filtered("%s:%d:%s:%s%s ", \ |
134 | filter_filename(__FILE__), __LINE__, #OBJECT, \ | |
135 | trace_device ? device_path(me) : "", \ | |
136 | trace_device ? ":" : ""); \ | |
137 | sim_io_printf_filtered ARGS; \ | |
c906108c SS |
138 | } \ |
139 | } \ | |
140 | } while (0) | |
141 | ||
142 | /* package */ | |
143 | #define PTRACE(OBJECT, ARGS) \ | |
144 | do { \ | |
145 | if (WITH_TRACE) { \ | |
146 | if (ppc_trace[trace_##OBJECT##_package]) { \ | |
a6760b61 PA |
147 | sim_io_printf_filtered("%s:%d:%s: ", filter_filename(__FILE__), __LINE__, #OBJECT); \ |
148 | sim_io_printf_filtered ARGS; \ | |
c906108c SS |
149 | } \ |
150 | } \ | |
151 | } while (0) | |
152 | ||
153 | ||
154 | #define ASSERT(EXPRESSION) \ | |
155 | do { \ | |
156 | if (WITH_ASSERT) { \ | |
157 | if (!(EXPRESSION)) { \ | |
158 | error("%s:%d: assertion failed - %s\n", \ | |
159 | filter_filename(__FILE__), __LINE__, #EXPRESSION); \ | |
160 | } \ | |
161 | } \ | |
162 | } while (0) | |
163 | ||
164 | /* Parse OPTION updating the trace array */ | |
165 | extern void | |
166 | trace_option(const char *option, int setting); | |
167 | ||
168 | /* Output the list of trace options */ | |
169 | extern void trace_usage | |
170 | (int verbose); | |
171 | ||
172 | ||
173 | #endif /* _DEBUG_H_ */ |