o Clean-up tic80 fp tracing
[deliverable/binutils-gdb.git] / sim / common / sim-trace.h
CommitLineData
0f2811d1
DE
1/* Simulator tracing/debugging support.
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
4
5This file is part of GDB, the GNU debugger.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License along
18with this program; if not, write to the Free Software Foundation, Inc.,
1959 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 32/* Standard traceable entities. */
7b167b09 33#define TRACE_SEMANTICS_IDX -1 /* set ALU, FPU, MEMORY tracing */
3971886a
AC
34#define TRACE_INSN_IDX 0
35#define TRACE_DECODE_IDX 1
36#define TRACE_EXTRACT_IDX 2
37#define TRACE_LINENUM_IDX 3
38#define TRACE_MEMORY_IDX 4
39#define TRACE_MODEL_IDX 5
40#define TRACE_ALU_IDX 6
41#define TRACE_CORE_IDX 7
42#define TRACE_EVENTS_IDX 8
43#define TRACE_FPU_IDX 9
7b167b09 44#define TRACE_BRANCH_IDX 10
3971886a
AC
45#define TRACE_NEXT_IDX 16 /* simulator specific trace bits begin here */
46
7b167b09
MM
47/* Maximum number of traceable entities. */
48#ifndef MAX_TRACE_VALUES
49#define MAX_TRACE_VALUES 32
50#endif
51
3971886a
AC
52/* Masks so WITH_TRACE can have symbolic values. */
53#define TRACE_insn 1
54#define TRACE_decode 2
55#define TRACE_extract 4
56#define TRACE_linenum 8
57#define TRACE_memory 16
58#define TRACE_model 32
59#define TRACE_alu 64
60#define TRACE_core 128
61#define TRACE_events 256
62#define TRACE_fpu 512
7b167b09 63#define TRACE_branch 1024
3971886a
AC
64
65/* Preprocessor macros to simplify tests of WITH_TRACE. */
7b167b09
MM
66#define WITH_TRACE_INSN_P (WITH_TRACE & TRACE_insn)
67#define WITH_TRACE_DECODE_P (WITH_TRACE & TRACE_decode)
68#define WITH_TRACE_EXTRACT_P (WITH_TRACE & TRACE_extract)
69#define WITH_TRACE_LINENUM_P (WITH_TRACE & TRACE_linenum)
70#define WITH_TRACE_MEMORY_P (WITH_TRACE & TRACE_memory)
71#define WITH_TRACE_MODEL_P (WITH_TRACE & TRACE_model)
72#define WITH_TRACE_ALU_P (WITH_TRACE & TRACE_alu)
73#define WITH_TRACE_CORE_P (WITH_TRACE & TRACE_core)
74#define WITH_TRACE_EVENTS_P (WITH_TRACE & TRACE_events)
75#define WITH_TRACE_FPU_P (WITH_TRACE & TRACE_fpu)
76#define WITH_TRACE_BRANCH_P (WITH_TRACE & TRACE_branch)
3971886a
AC
77
78/* Tracing install handler. */
79MODULE_INSTALL_FN trace_install;
80\f
81/* Struct containing all trace data. */
82
83typedef struct {
84 /* Boolean array of specified tracing flags. */
85 /* ??? It's not clear that using an array vs a bit mask is faster.
86 Consider the case where one wants to test whether any of several bits
87 are set. */
88 char trace_flags[MAX_TRACE_VALUES];
89#define TRACE_FLAGS(t) ((t)->trace_flags)
90
91 /* Tracing output goes to this or stderr if NULL.
92 We can't store `stderr' here as stderr goes through a callback. */
93 FILE *trace_file;
94#define TRACE_FILE(t) ((t)->trace_file)
95} TRACE_DATA;
96\f
97/* Usage macros. */
98
99#define CPU_TRACE_FLAGS(cpu) TRACE_FLAGS (CPU_TRACE_DATA (cpu))
100
15d8adf5
DE
101/* forward reference */
102struct _sim_cpu;
0f2811d1 103
15d8adf5 104/* Tracing support. */
0f2811d1
DE
105
106/* Return non-zero if tracing of IDX is enabled for CPU. */
107#define TRACE_P(cpu,idx) \
108((WITH_TRACE & (1 << (idx))) != 0 \
109 && CPU_TRACE_FLAGS (cpu)[idx] != 0)
110
7b167b09
MM
111/* Non-zero if a certain --trace-<xxxx> was specified for CPU. */
112#define TRACE_INSN_P(cpu) TRACE_P (cpu, TRACE_INSN_IDX)
113#define TRACE_DECODE_P(cpu) TRACE_P (cpu, TRACE_DECODE_IDX)
114#define TRACE_EXTRACT_P(cpu) TRACE_P (cpu, TRACE_EXTRACT_IDX)
115#define TRACE_LINENUM_P(cpu) TRACE_P (cpu, TRACE_LINENUM_IDX)
116#define TRACE_MEMORY_P(cpu) TRACE_P (cpu, TRACE_MEMORY_IDX)
117#define TRACE_MODEL_P(cpu) TRACE_P (cpu, TRACE_MODEL_IDX)
118#define TRACE_ALU_P(cpu) TRACE_P (cpu, TRACE_ALU_IDX)
119#define TRACE_CORE_P(cpu) TRACE_P (cpu, TRACE_CORE_IDX)
120#define TRACE_EVENTS_P(cpu) TRACE_P (cpu, TRACE_EVENTS_IDX)
121#define TRACE_FPU_P(cpu) TRACE_P (cpu, TRACE_FPU_IDX)
122#define TRACE_BRANCH_P(cpu) TRACE_P (cpu, TRACE_BRANCH_IDX)
0f2811d1 123
381f42ef
AC
124extern void trace_one_insn PARAMS ((SIM_DESC sd,
125 sim_cpu * cpu,
126 address_word cia,
127 int print_linenum_p,
128 const char *file_name,
129 int line_nr,
130 const char *unit,
131 const char *fmt,
132 ...))
133 __attribute__((format (printf, 8, 9)));
a7724171 134
23b04e79
MM
135extern void trace_printf PARAMS ((SIM_DESC, sim_cpu *, const char *, ...))
136 __attribute__((format (printf, 3, 4)));
0f2811d1 137
381f42ef
AC
138extern void trace_vprintf PARAMS ((SIM_DESC, sim_cpu *, const char *, va_list));
139
3971886a
AC
140/* Debug support.
141 This is included here because there isn't enough of it to justify
142 a sim-debug.h. */
0f2811d1 143
0f2811d1
DE
144/* Return non-zero if debugging of IDX for CPU is enabled. */
145#define DEBUG_P(cpu, idx) \
146((WITH_DEBUG & (1 << (idx))) != 0 \
147 && CPU_DEBUG_FLAGS (cpu)[idx] != 0)
148
149/* Non-zero if "--debug-insn" specified. */
150#define DEBUG_INSN_P(cpu) DEBUG_P (cpu, DEBUG_INSN_IDX)
151
23b04e79
MM
152extern void debug_printf PARAMS ((struct _sim_cpu *, const char *, ...))
153 __attribute__((format (printf, 2, 3)));
0f2811d1
DE
154
155#endif /* SIM_TRACE_H */
This page took 0.030425 seconds and 4 git commands to generate.