1 /* Simulator tracing/debugging support.
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
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)
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.
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. */
21 /* This file is meant to be included by sim-basics.h. */
26 /* Maximum number of traceable entities. */
27 #ifndef MAX_TRACE_VALUES
28 #define MAX_TRACE_VALUES 12
31 /* Standard traceable entities. */
32 #define TRACE_INSN_IDX 0
33 #define TRACE_DECODE_IDX 1
34 #define TRACE_EXTRACT_IDX 2
35 #define TRACE_LINENUM_IDX 3
36 #define TRACE_MEMORY_IDX 4
37 #define TRACE_MODEL_IDX 5
38 #define TRACE_ALU_IDX 6
39 #define TRACE_CORE_IDX 7
40 #define TRACE_EVENTS_IDX 8
41 #define TRACE_FPU_IDX 9
42 #define TRACE_NEXT_IDX 16 /* simulator specific trace bits begin here */
44 /* Masks so WITH_TRACE can have symbolic values. */
46 #define TRACE_decode 2
47 #define TRACE_extract 4
48 #define TRACE_linenum 8
49 #define TRACE_memory 16
50 #define TRACE_model 32
52 #define TRACE_core 128
53 #define TRACE_events 256
56 /* Preprocessor macros to simplify tests of WITH_TRACE. */
57 #define WITH_TRACE_INSN_P (WITH_TRACE & TRACE_insn)
58 #define WITH_TRACE_DECODE_P (WITH_TRACE & TRACE_decode)
59 #define WITH_TRACE_EXTRACT_P (WITH_TRACE & TRACE_extract)
60 #define WITH_TRACE_LINENUM_P (WITH_TRACE & TRACE_linenum)
61 #define WITH_TRACE_MEMORY_P (WITH_TRACE & TRACE_memory)
62 #define WITH_TRACE_MODEL_P (WITH_TRACE & TRACE_model)
63 #define WITH_TRACE_ALU_P (WITH_TRACE & TRACE_alu)
64 #define WITH_TRACE_CORE_P (WITH_TRACE & TRACE_core)
65 #define WITH_TRACE_EVENTS_P (WITH_TRACE & TRACE_events)
66 #define WITH_TRACE_FPU_P (WITH_TRACE & TRACE_fpu)
68 /* Tracing install handler. */
69 MODULE_INSTALL_FN trace_install;
71 /* Struct containing all trace data. */
74 /* Boolean array of specified tracing flags. */
75 /* ??? It's not clear that using an array vs a bit mask is faster.
76 Consider the case where one wants to test whether any of several bits
78 char trace_flags[MAX_TRACE_VALUES];
79 #define TRACE_FLAGS(t) ((t)->trace_flags)
81 /* Tracing output goes to this or stderr if NULL.
82 We can't store `stderr' here as stderr goes through a callback. */
84 #define TRACE_FILE(t) ((t)->trace_file)
89 #define CPU_TRACE_FLAGS(cpu) TRACE_FLAGS (CPU_TRACE_DATA (cpu))
91 /* forward reference */
94 /* Tracing support. */
96 /* Return non-zero if tracing of IDX is enabled for CPU. */
97 #define TRACE_P(cpu,idx) \
98 ((WITH_TRACE & (1 << (idx))) != 0 \
99 && CPU_TRACE_FLAGS (cpu)[idx] != 0)
101 /* Non-zero if "--trace-insn" specified for CPU. */
102 #define TRACE_INSN_P(cpu) TRACE_P (cpu, TRACE_INSN_IDX)
103 /* Non-zero if "--trace-decode" specified for CPU. */
104 #define TRACE_DECODE_P(cpu) TRACE_P (cpu, TRACE_DECODE_IDX)
105 /* Non-zero if "--trace-fpu" specified for CPU. */
106 #define TRACE_FPU_P(cpu) TRACE_P (cpu, TRACE_FPU_IDX)
108 extern void trace_printf PARAMS ((SIM_DESC, sim_cpu *, const char *, ...));
111 This is included here because there isn't enough of it to justify
114 /* Return non-zero if debugging of IDX for CPU is enabled. */
115 #define DEBUG_P(cpu, idx) \
116 ((WITH_DEBUG & (1 << (idx))) != 0 \
117 && CPU_DEBUG_FLAGS (cpu)[idx] != 0)
119 /* Non-zero if "--debug-insn" specified. */
120 #define DEBUG_INSN_P(cpu) DEBUG_P (cpu, DEBUG_INSN_IDX)
122 extern void debug_printf PARAMS ((struct _sim_cpu *, const char *, ...));
124 #endif /* SIM_TRACE_H */