Commit | Line | Data |
---|---|---|
c143ef62 MM |
1 | /* This file is part of the program psim. |
2 | ||
3 | Copyright (C) 1994-1995, 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 | |
7 | the Free Software Foundation; either version 2 of the License, or | |
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 | |
16 | along with this program; if not, write to the Free Software | |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | ||
19 | */ | |
20 | ||
21 | ||
22 | #ifndef _DEBUG_H_ | |
23 | #define _DEBUG_H_ | |
24 | ||
25 | #include "filter_filename.h" | |
26 | ||
27 | typedef enum { | |
28 | trace_invalid, | |
29 | trace_tbd, | |
30 | /**/ | |
31 | trace_gdb, | |
32 | trace_os_emul, | |
33 | /**/ | |
34 | trace_device_tree, | |
35 | trace_devices, | |
36 | trace_pass_device, | |
37 | trace_console_device, | |
38 | trace_icu_device, | |
39 | trace_halt_device, | |
40 | trace_register_device, | |
41 | trace_vm_device, | |
42 | trace_memory_device, | |
43 | trace_htab_device, | |
44 | trace_pte_device, | |
45 | trace_binary_device, | |
46 | trace_file_device, | |
47 | trace_core_device, | |
48 | trace_stack_device, | |
49 | /**/ | |
50 | trace_semantics, | |
51 | trace_idecode, | |
52 | trace_alu, | |
a983c8f0 | 53 | trace_load_store, |
45525d8d | 54 | trace_model, |
c143ef62 MM |
55 | /**/ |
56 | trace_vm, | |
57 | trace_core, | |
58 | trace_psim, | |
59 | trace_device_init, | |
60 | trace_cpu, | |
61 | trace_breakpoint, | |
45525d8d | 62 | trace_opts, |
c143ef62 MM |
63 | nr_trace_options |
64 | } trace_options; | |
65 | ||
66 | ||
67 | ||
68 | extern int ppc_trace[nr_trace_options]; | |
69 | ||
70 | #if WITH_TRACE | |
71 | #define TRACE(OBJECT, ARGS) \ | |
72 | do { \ | |
73 | if (ppc_trace[OBJECT]) { \ | |
74 | printf_filtered("%s:%d:%s: ", filter_filename(__FILE__), __LINE__, #OBJECT); \ | |
75 | printf_filtered ARGS; \ | |
76 | } \ | |
77 | } while (0) | |
78 | /* issue */ | |
79 | #define ITRACE(OBJECT, ARGS) \ | |
80 | do { \ | |
81 | if (ppc_trace[OBJECT]) { \ | |
45525d8d | 82 | printf_filtered("%s:%d:0x%lx", my_prefix, (int)(cpu_nr(processor) + 1), (unsigned long)cia); \ |
c143ef62 MM |
83 | printf_filtered ARGS; \ |
84 | } \ | |
85 | } while (0) | |
86 | /* device */ | |
87 | #define DTRACE(OBJECT, ARGS) \ | |
88 | do { \ | |
89 | if (ppc_trace[trace_devices] || ppc_trace[trace_##OBJECT##_device]) { \ | |
90 | printf_filtered("%s:%d:%s: ", filter_filename(__FILE__), __LINE__, #OBJECT); \ | |
91 | printf_filtered ARGS; \ | |
92 | } \ | |
93 | } while (0) | |
94 | #else | |
95 | #define TRACE(OBJECT, ARGS) | |
96 | #define ITRACE(OBJECT, ARGS) | |
97 | #define DTRACE(OBJECT, ARGS) | |
98 | #endif | |
99 | ||
100 | #if WITH_ASSERT | |
101 | #define ASSERT(EXPRESSION) \ | |
102 | do { \ | |
103 | if (!(EXPRESSION)) { \ | |
104 | error("%s:%d: assertion failed - %s\n", \ | |
105 | filter_filename(__FILE__), __LINE__, #EXPRESSION); \ | |
106 | } \ | |
107 | } while (0) | |
108 | #else | |
109 | #define ASSERT(EXPRESSION) | |
110 | #endif | |
111 | ||
112 | /* Parse OPTION updating the trace array */ | |
113 | extern void | |
114 | trace_option(const char *option); | |
115 | ||
116 | /* Output the list of trace options */ | |
117 | extern void | |
118 | trace_usage(void); | |
119 | ||
120 | ||
121 | #endif /* _DEBUG_H_ */ |