MAX_CPUS -> WITH_SMP.
[external/binutils.git] / sim / common / sim-trace.h
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
26 /* Tracing support.  */
27
28 #if WITH_SMP
29
30 /* Return non-zero if tracing of IDX is enabled for CPU.  */
31 #define TRACE_P(cpu,idx) \
32 ((WITH_TRACE & (1 << (idx))) != 0 \
33  && CPU_TRACE_FLAGS (cpu)[idx] != 0)
34
35 /* Non-zero if "--trace-insn" specified for CPU.  */
36 #define TRACE_INSN_P(cpu) TRACE_P (cpu, TRACE_INSN_IDX)
37
38 #define TRACE_PRINTF(cpu, idx, args) \
39 do { \
40   if ((WITH_TRACE & (1 << (idx))) != 0 \
41       && CPU_TRACE_FLAGS (cpu)[idx] != 0) \
42     trace_printf args; \
43 } while (0)
44
45 #else
46
47 /* Fetch current tracing flags.  */
48 #define CURRENT_TRACE_FLAGS CPU_TRACE_FLAGS (& CURRENT_STATE->cpu)
49
50 /* Return non-zero if tracing of IDX is enabled.  */
51 #define TRACE_P(idx) \
52 ((WITH_TRACE & (1 << (idx))) != 0 \
53  && CURRENT_TRACE_FLAGS[idx] != 0)
54
55 /* Non-zero if "--trace-insn" specified.  */
56 #define TRACE_INSN_P TRACE_P (TRACE_INSN_IDX)
57
58 #define TRACE_PRINTF(idx, args) \
59 do { \
60   if ((WITH_TRACE & (1 << (idx))) != 0 \
61       && CURRENT_TRACE_FLAGS[idx] != 0) \
62     trace_printf args; \
63 } while (0)
64
65 #endif /* WITH_SMP */
66
67 extern void trace_printf PARAMS ((char *, ...));
68
69 /* Debug support.  */
70
71 #if WITH_SMP
72
73 /* Return non-zero if debugging of IDX for CPU is enabled.  */
74 #define DEBUG_P(cpu, idx) \
75 ((WITH_DEBUG & (1 << (idx))) != 0 \
76  && CPU_DEBUG_FLAGS (cpu)[idx] != 0)
77
78 /* Non-zero if "--debug-insn" specified.  */
79 #define DEBUG_INSN_P(cpu) DEBUG_P (cpu, DEBUG_INSN_IDX)
80
81 #define DEBUG_PRINTF(cpu, idx, args) \
82 do { \
83   if ((WITH_DEBUG & (1 << (idx))) != 0 \
84       && CPU_DEBUG_FLAGS (cpu)[idx] != 0) \
85     debug_printf args; \
86 } while (0)
87
88 #else
89
90 /* Fetch current debugging flags.  */
91 #define CURRENT_DEBUG_FLAGS CPU_DEBUG_FLAGS (& CURRENT_STATE->cpu)
92
93 /* Return non-zero if debugging of IDX is enabled.  */
94 #define DEBUG_P(idx) \
95 ((WITH_DEBUG & (1 << (idx))) != 0 \
96  && CURRENT_DEBUG_FLAGS[idx] != 0)
97
98 /* Non-zero if "--debug-insn" specified.  */
99 #define DEBUG_INSN_P DEBUG_P (DEBUG_INSN_IDX)
100
101 #define DEBUG_PRINTF(idx, args) \
102 do { \
103   if ((WITH_DEBUG & (1 << (idx))) != 0 \
104       && CURRENT_DEBUG_FLAGS[idx] != 0) \
105     debug_printf args; \
106 } while (0)
107
108 #endif /* WITH_SMP */
109
110 extern void debug_printf PARAMS ((char *, ...));
111
112 #endif /* SIM_TRACE_H */