sim: mips: delete TARGET_TX3904 define
[deliverable/binutils-gdb.git] / sim / common / sim-trace.h
CommitLineData
c906108c 1/* Simulator tracing/debugging support.
32d0add0 2 Copyright (C) 1997-2015 Free Software Foundation, Inc.
c906108c
SS
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
4744ac1b
JB
9the Free Software Foundation; either version 3 of the License, or
10(at your option) any later version.
c906108c
SS
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
4744ac1b
JB
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
19
20/* This file is meant to be included by sim-basics.h. */
21
22#ifndef SIM_TRACE_H
23#define SIM_TRACE_H
24
25/* Standard traceable entities. */
26
27enum {
28 /* Trace insn execution. */
29 TRACE_INSN_IDX = 1,
30
31 /* Trace insn decoding.
32 ??? This is more of a simulator debugging operation and might best be
33 moved to --debug-decode. */
34 TRACE_DECODE_IDX,
35
36 /* Trace insn extraction.
37 ??? This is more of a simulator debugging operation and might best be
38 moved to --debug-extract. */
39 TRACE_EXTRACT_IDX,
40
41 /* Trace insn execution but include line numbers. */
42 TRACE_LINENUM_IDX,
43
44 /* Trace memory operations.
45 The difference between this and TRACE_CORE_IDX is (I think) that this
46 is intended to apply to a higher level. TRACE_CORE_IDX applies to the
47 low level core operations. */
48 TRACE_MEMORY_IDX,
49
50 /* Include model performance data in tracing output. */
51 TRACE_MODEL_IDX,
52
8371bf0c 53 /* Trace ALU (Arithmetic Logic Unit) operations. */
c906108c
SS
54 TRACE_ALU_IDX,
55
56 /* Trace memory core operations. */
57 TRACE_CORE_IDX,
58
59 /* Trace events. */
60 TRACE_EVENTS_IDX,
61
8371bf0c 62 /* Trace FPU (Floating Point Unit) operations. */
c906108c
SS
63 TRACE_FPU_IDX,
64
8371bf0c 65 /* Trace VPU (Vector Processing Unit) operations. */
01816cd8
BE
66 TRACE_VPU_IDX,
67
c906108c
SS
68 /* Trace branching. */
69 TRACE_BRANCH_IDX,
70
3a49ea9f
MF
71 /* Trace syscalls. */
72 TRACE_SYSCALL_IDX,
73
fa8f87e5
MF
74 /* Trace cpu register accesses. Registers that are part of hardware devices
75 should use the HW_TRACE macros instead. */
76 TRACE_REGISTER_IDX,
77
c906108c
SS
78 /* Add information useful for debugging the simulator to trace output. */
79 TRACE_DEBUG_IDX,
80
81 /* Simulator specific trace bits begin here. */
82 TRACE_NEXT_IDX,
83
84};
85/* Maximum number of traceable entities. */
86#ifndef MAX_TRACE_VALUES
87#define MAX_TRACE_VALUES 32
88#endif
89
90/* The -t option only prints useful values. It's easy to type and shouldn't
91 splat on the screen everything under the sun making nothing easy to
92 find. */
93#define TRACE_USEFUL_MASK \
a6c2a374 94 (TRACE_insn | TRACE_linenum | TRACE_memory | TRACE_model)
c906108c
SS
95\f
96/* Masks so WITH_TRACE can have symbolic values.
97 The case choice here is on purpose. The lowercase parts are args to
98 --with-trace. */
99#define TRACE_insn (1 << TRACE_INSN_IDX)
100#define TRACE_decode (1 << TRACE_DECODE_IDX)
101#define TRACE_extract (1 << TRACE_EXTRACT_IDX)
102#define TRACE_linenum (1 << TRACE_LINENUM_IDX)
103#define TRACE_memory (1 << TRACE_MEMORY_IDX)
104#define TRACE_model (1 << TRACE_MODEL_IDX)
105#define TRACE_alu (1 << TRACE_ALU_IDX)
106#define TRACE_core (1 << TRACE_CORE_IDX)
107#define TRACE_events (1 << TRACE_EVENTS_IDX)
108#define TRACE_fpu (1 << TRACE_FPU_IDX)
01816cd8 109#define TRACE_vpu (1 << TRACE_VPU_IDX)
c906108c 110#define TRACE_branch (1 << TRACE_BRANCH_IDX)
3a49ea9f 111#define TRACE_syscall (1 << TRACE_SYSCALL_IDX)
fa8f87e5 112#define TRACE_register (1 << TRACE_REGISTER_IDX)
c906108c
SS
113#define TRACE_debug (1 << TRACE_DEBUG_IDX)
114
bffcfec8 115/* Return non-zero if tracing of idx is enabled (compiled in). */
9b9c712c 116#define WITH_TRACE_P(idx) (WITH_TRACE & (1 << idx))
bffcfec8
MF
117
118/* Preprocessor macros to simplify tests of WITH_TRACE. */
119#define WITH_TRACE_ANY_P (WITH_TRACE)
9b9c712c
MF
120#define WITH_TRACE_INSN_P WITH_TRACE_P (TRACE_INSN_IDX)
121#define WITH_TRACE_DECODE_P WITH_TRACE_P (TRACE_DECODE_IDX)
122#define WITH_TRACE_EXTRACT_P WITH_TRACE_P (TRACE_EXTRACT_IDX)
123#define WITH_TRACE_LINENUM_P WITH_TRACE_P (TRACE_LINENUM_IDX)
124#define WITH_TRACE_MEMORY_P WITH_TRACE_P (TRACE_MEMORY_IDX)
125#define WITH_TRACE_MODEL_P WITH_TRACE_P (TRACE_MODEL_IDX)
126#define WITH_TRACE_ALU_P WITH_TRACE_P (TRACE_ALU_IDX)
127#define WITH_TRACE_CORE_P WITH_TRACE_P (TRACE_CORE_IDX)
128#define WITH_TRACE_EVENTS_P WITH_TRACE_P (TRACE_EVENTS_IDX)
129#define WITH_TRACE_FPU_P WITH_TRACE_P (TRACE_FPU_IDX)
130#define WITH_TRACE_VPU_P WITH_TRACE_P (TRACE_VPU_IDX)
131#define WITH_TRACE_BRANCH_P WITH_TRACE_P (TRACE_BRANCH_IDX)
132#define WITH_TRACE_SYSCALL_P WITH_TRACE_P (TRACE_SYSCALL_IDX)
fa8f87e5 133#define WITH_TRACE_REGISTER_P WITH_TRACE_P (TRACE_REGISTER_IDX)
9b9c712c 134#define WITH_TRACE_DEBUG_P WITH_TRACE_P (TRACE_DEBUG_IDX)
c906108c
SS
135
136/* Tracing install handler. */
137MODULE_INSTALL_FN trace_install;
138\f
139/* Struct containing all system and cpu trace data.
140
141 System trace data is stored with the associated module.
142 System and cpu tracing must share the same space of bitmasks as they
143 are arguments to --with-trace. One could have --with-trace and
144 --with-cpu-trace or some such but that's an over-complication at this point
145 in time. Also, there may be occasions where system and cpu tracing may
146 wish to share a name. */
147
148typedef struct _trace_data {
149
150 /* Global summary of all the current trace options */
151 char trace_any_p;
152
153 /* Boolean array of specified tracing flags. */
154 /* ??? It's not clear that using an array vs a bit mask is faster.
155 Consider the case where one wants to test whether any of several bits
156 are set. */
157 char trace_flags[MAX_TRACE_VALUES];
158#define TRACE_FLAGS(t) ((t)->trace_flags)
159
160 /* Tracing output goes to this or stderr if NULL.
161 We can't store `stderr' here as stderr goes through a callback. */
162 FILE *trace_file;
163#define TRACE_FILE(t) ((t)->trace_file)
164
165 /* Buffer to store the prefix to be printed before any trace line. */
166 char trace_prefix[256];
167#define TRACE_PREFIX(t) ((t)->trace_prefix)
168
169 /* Buffer to save the inputs for the current instruction. Use a
170 union to force the buffer into correct alignment */
171 union {
172 unsigned8 i8;
173 unsigned16 i16;
174 unsigned32 i32;
175 unsigned64 i64;
176 } trace_input_data[16];
177 unsigned8 trace_input_fmt[16];
178 unsigned8 trace_input_size[16];
179 int trace_input_idx;
180#define TRACE_INPUT_DATA(t) ((t)->trace_input_data)
181#define TRACE_INPUT_FMT(t) ((t)->trace_input_fmt)
182#define TRACE_INPUT_SIZE(t) ((t)->trace_input_size)
183#define TRACE_INPUT_IDX(t) ((t)->trace_input_idx)
184
185 /* Category of trace being performed */
186 int trace_idx;
187#define TRACE_IDX(t) ((t)->trace_idx)
188
189 /* Trace range.
190 ??? Not all cpu's support this. */
191 ADDR_RANGE range;
192#define TRACE_RANGE(t) (& (t)->range)
193} TRACE_DATA;
194\f
195/* System tracing support. */
196
197#define STATE_TRACE_FLAGS(sd) TRACE_FLAGS (STATE_TRACE_DATA (sd))
198
199/* Return non-zero if tracing of IDX is enabled for non-cpu specific
200 components. The "S" in "STRACE" refers to "System". */
201#define STRACE_P(sd,idx) \
9b9c712c 202 (WITH_TRACE_P (idx) && STATE_TRACE_FLAGS (sd)[idx] != 0)
c906108c
SS
203
204/* Non-zero if --trace-<xxxx> was specified for SD. */
bffcfec8 205#define STRACE_ANY_P(sd) (WITH_TRACE_ANY_P && (STATE_TRACE_DATA (sd)->trace_any_p))
ce4eda4a
MF
206#define STRACE_INSN_P(sd) STRACE_P (sd, TRACE_INSN_IDX)
207#define STRACE_DECODE_P(sd) STRACE_P (sd, TRACE_DECODE_IDX)
208#define STRACE_EXTRACT_P(sd) STRACE_P (sd, TRACE_EXTRACT_IDX)
209#define STRACE_LINENUM_P(sd) STRACE_P (sd, TRACE_LINENUM_IDX)
210#define STRACE_MEMORY_P(sd) STRACE_P (sd, TRACE_MEMORY_IDX)
211#define STRACE_MODEL_P(sd) STRACE_P (sd, TRACE_MODEL_IDX)
212#define STRACE_ALU_P(sd) STRACE_P (sd, TRACE_ALU_IDX)
213#define STRACE_CORE_P(sd) STRACE_P (sd, TRACE_CORE_IDX)
214#define STRACE_EVENTS_P(sd) STRACE_P (sd, TRACE_EVENTS_IDX)
215#define STRACE_FPU_P(sd) STRACE_P (sd, TRACE_FPU_IDX)
216#define STRACE_VPU_P(sd) STRACE_P (sd, TRACE_VPU_IDX)
217#define STRACE_BRANCH_P(sd) STRACE_P (sd, TRACE_BRANCH_IDX)
218#define STRACE_SYSCALL_P(sd) STRACE_P (sd, TRACE_SYSCALL_IDX)
fa8f87e5 219#define STRACE_REGISTER_P(sd) STRACE_P (sd, TRACE_REGISTER_IDX)
c906108c 220#define STRACE_DEBUG_P(sd) STRACE_P (sd, TRACE_DEBUG_IDX)
cf304b56
MF
221
222/* Helper functions for printing messages. */
223#define STRACE(sd, idx, fmt, args...) \
224 do { \
225 if (STRACE_P (sd, idx)) \
226 trace_generic (sd, NULL, idx, fmt, ## args); \
227 } while (0)
228#define STRACE_INSN(sd, fmt, args...) STRACE (sd, TRACE_INSN_IDX, fmt, ## args)
229#define STRACE_DECODE(sd, fmt, args...) STRACE (sd, TRACE_DECODE_IDX, fmt, ## args)
230#define STRACE_EXTRACT(sd, fmt, args...) STRACE (sd, TRACE_EXTRACT_IDX, fmt, ## args)
231#define STRACE_LINENUM(sd, fmt, args...) STRACE (sd, TRACE_LINENUM_IDX, fmt, ## args)
232#define STRACE_MEMORY(sd, fmt, args...) STRACE (sd, TRACE_MEMORY_IDX, fmt, ## args)
233#define STRACE_MODEL(sd, fmt, args...) STRACE (sd, TRACE_MODEL_IDX, fmt, ## args)
234#define STRACE_ALU(sd, fmt, args...) STRACE (sd, TRACE_ALU_IDX, fmt, ## args)
235#define STRACE_CORE(sd, fmt, args...) STRACE (sd, TRACE_CORE_IDX, fmt, ## args)
236#define STRACE_EVENTS(sd, fmt, args...) STRACE (sd, TRACE_EVENTS_IDX, fmt, ## args)
237#define STRACE_FPU(sd, fmt, args...) STRACE (sd, TRACE_FPU_IDX, fmt, ## args)
238#define STRACE_VPU(sd, fmt, args...) STRACE (sd, TRACE_VPU_IDX, fmt, ## args)
239#define STRACE_BRANCH(sd, fmt, args...) STRACE (sd, TRACE_BRANCH_IDX, fmt, ## args)
240#define STRACE_SYSCALL(sd, fmt, args...) STRACE (sd, TRACE_SYSCALL_IDX, fmt, ## args)
fa8f87e5 241#define STRACE_REGISTER(sd, fmt, args...) STRACE (sd, TRACE_REGISTER_IDX, fmt, ## args)
cf304b56 242#define STRACE_DEBUG(sd, fmt, args...) STRACE (sd, TRACE_DEBUG_IDX, fmt, ## args)
c906108c
SS
243\f
244/* CPU tracing support. */
245
246#define CPU_TRACE_FLAGS(cpu) TRACE_FLAGS (CPU_TRACE_DATA (cpu))
247
248/* Return non-zero if tracing of IDX is enabled for CPU. */
249#define TRACE_P(cpu,idx) \
9b9c712c 250 (WITH_TRACE_P (idx) && CPU_TRACE_FLAGS (cpu)[idx] != 0)
c906108c
SS
251
252/* Non-zero if --trace-<xxxx> was specified for CPU. */
bffcfec8 253#define TRACE_ANY_P(cpu) (WITH_TRACE_ANY_P && (CPU_TRACE_DATA (cpu)->trace_any_p))
c906108c
SS
254#define TRACE_INSN_P(cpu) TRACE_P (cpu, TRACE_INSN_IDX)
255#define TRACE_DECODE_P(cpu) TRACE_P (cpu, TRACE_DECODE_IDX)
256#define TRACE_EXTRACT_P(cpu) TRACE_P (cpu, TRACE_EXTRACT_IDX)
257#define TRACE_LINENUM_P(cpu) TRACE_P (cpu, TRACE_LINENUM_IDX)
258#define TRACE_MEMORY_P(cpu) TRACE_P (cpu, TRACE_MEMORY_IDX)
259#define TRACE_MODEL_P(cpu) TRACE_P (cpu, TRACE_MODEL_IDX)
260#define TRACE_ALU_P(cpu) TRACE_P (cpu, TRACE_ALU_IDX)
261#define TRACE_CORE_P(cpu) TRACE_P (cpu, TRACE_CORE_IDX)
262#define TRACE_EVENTS_P(cpu) TRACE_P (cpu, TRACE_EVENTS_IDX)
263#define TRACE_FPU_P(cpu) TRACE_P (cpu, TRACE_FPU_IDX)
01816cd8 264#define TRACE_VPU_P(cpu) TRACE_P (cpu, TRACE_VPU_IDX)
c906108c 265#define TRACE_BRANCH_P(cpu) TRACE_P (cpu, TRACE_BRANCH_IDX)
3a49ea9f 266#define TRACE_SYSCALL_P(cpu) TRACE_P (cpu, TRACE_SYSCALL_IDX)
fa8f87e5 267#define TRACE_REGISTER_P(cpu) TRACE_P (cpu, TRACE_REGISTER_IDX)
c906108c 268#define TRACE_DEBUG_P(cpu) TRACE_P (cpu, TRACE_DEBUG_IDX)
bb11f3ed
MF
269
270/* Helper functions for printing messages. */
271#define TRACE(cpu, idx, fmt, args...) \
272 do { \
273 if (TRACE_P (cpu, idx)) \
274 trace_generic (CPU_STATE (cpu), cpu, idx, fmt, ## args); \
275 } while (0)
276#define TRACE_INSN(cpu, fmt, args...) TRACE (cpu, TRACE_INSN_IDX, fmt, ## args)
277#define TRACE_DECODE(cpu, fmt, args...) TRACE (cpu, TRACE_DECODE_IDX, fmt, ## args)
278#define TRACE_EXTRACT(cpu, fmt, args...) TRACE (cpu, TRACE_EXTRACT_IDX, fmt, ## args)
279#define TRACE_LINENUM(cpu, fmt, args...) TRACE (cpu, TRACE_LINENUM_IDX, fmt, ## args)
280#define TRACE_MEMORY(cpu, fmt, args...) TRACE (cpu, TRACE_MEMORY_IDX, fmt, ## args)
281#define TRACE_MODEL(cpu, fmt, args...) TRACE (cpu, TRACE_MODEL_IDX, fmt, ## args)
282#define TRACE_ALU(cpu, fmt, args...) TRACE (cpu, TRACE_ALU_IDX, fmt, ## args)
283#define TRACE_CORE(cpu, fmt, args...) TRACE (cpu, TRACE_CORE_IDX, fmt, ## args)
284#define TRACE_EVENTS(cpu, fmt, args...) TRACE (cpu, TRACE_EVENTS_IDX, fmt, ## args)
285#define TRACE_FPU(cpu, fmt, args...) TRACE (cpu, TRACE_FPU_IDX, fmt, ## args)
286#define TRACE_VPU(cpu, fmt, args...) TRACE (cpu, TRACE_VPU_IDX, fmt, ## args)
287#define TRACE_BRANCH(cpu, fmt, args...) TRACE (cpu, TRACE_BRANCH_IDX, fmt, ## args)
288#define TRACE_SYSCALL(cpu, fmt, args...) TRACE (cpu, TRACE_SYSCALL_IDX, fmt, ## args)
fa8f87e5 289#define TRACE_REGISTER(cpu, fmt, args...) TRACE (cpu, TRACE_REGISTER_IDX, fmt, ## args)
bb11f3ed 290#define TRACE_DEBUG(cpu, fmt, args...) TRACE (cpu, TRACE_DEBUG_IDX, fmt, ## args)
c906108c 291\f
01816cd8 292/* Tracing functions. */
c906108c
SS
293
294/* Prime the trace buffers ready for any trace output.
295 Must be called prior to any other trace operation */
bdca5ee4
TT
296extern void trace_prefix (SIM_DESC sd,
297 sim_cpu *cpu,
298 sim_cia cia,
299 address_word pc,
300 int print_linenum_p,
301 const char *file_name,
302 int line_nr,
303 const char *fmt,
304 ...)
c906108c
SS
305 __attribute__((format (printf, 8, 9)));
306
307/* Generic trace print, assumes trace_prefix() has been called */
308
bdca5ee4
TT
309extern void trace_generic (SIM_DESC sd,
310 sim_cpu *cpu,
311 int trace_idx,
312 const char *fmt,
313 ...)
c906108c
SS
314 __attribute__((format (printf, 4, 5)));
315
2aaed979
KB
316typedef enum {
317 trace_fmt_invalid,
318 trace_fmt_word,
319 trace_fmt_fp,
320 trace_fmt_fpu,
321 trace_fmt_string,
322 trace_fmt_bool,
323 trace_fmt_addr,
324 trace_fmt_instruction_incomplete,
325} data_fmt;
326
c906108c
SS
327/* Trace a varying number of word sized inputs/outputs. trace_result*
328 must be called to close the trace operation. */
329
bdca5ee4
TT
330extern void save_data (SIM_DESC sd,
331 TRACE_DATA *data,
332 data_fmt fmt,
333 long size,
334 const void *buf);
c906108c 335
bdca5ee4
TT
336extern void trace_input0 (SIM_DESC sd,
337 sim_cpu *cpu,
338 int trace_idx);
c906108c 339
bdca5ee4
TT
340extern void trace_input_word1 (SIM_DESC sd,
341 sim_cpu *cpu,
342 int trace_idx,
343 unsigned_word d0);
c906108c 344
bdca5ee4
TT
345extern void trace_input_word2 (SIM_DESC sd,
346 sim_cpu *cpu,
347 int trace_idx,
348 unsigned_word d0,
349 unsigned_word d1);
c906108c 350
bdca5ee4 351extern void trace_input_word3 (SIM_DESC sd,
c906108c
SS
352 sim_cpu *cpu,
353 int trace_idx,
354 unsigned_word d0,
355 unsigned_word d1,
bdca5ee4
TT
356 unsigned_word d2);
357
358extern void trace_input_word4 (SIM_DESC sd,
359 sim_cpu *cpu,
360 int trace_idx,
361 unsigned_word d0,
362 unsigned_word d1,
363 unsigned_word d2,
364 unsigned_word d3);
365
366extern void trace_input_addr1 (SIM_DESC sd,
367 sim_cpu *cpu,
368 int trace_idx,
369 address_word d0);
370
371extern void trace_input_bool1 (SIM_DESC sd,
372 sim_cpu *cpu,
373 int trace_idx,
374 int d0);
375
376extern void trace_input_fp1 (SIM_DESC sd,
377 sim_cpu *cpu,
378 int trace_idx,
379 fp_word f0);
380
381extern void trace_input_fp2 (SIM_DESC sd,
382 sim_cpu *cpu,
383 int trace_idx,
384 fp_word f0,
385 fp_word f1);
386
387extern void trace_input_fp3 (SIM_DESC sd,
388 sim_cpu *cpu,
389 int trace_idx,
390 fp_word f0,
391 fp_word f1,
392 fp_word f2);
393
394extern void trace_input_fpu1 (SIM_DESC sd,
395 sim_cpu *cpu,
396 int trace_idx,
397 struct _sim_fpu *f0);
398
399extern void trace_input_fpu2 (SIM_DESC sd,
400 sim_cpu *cpu,
401 int trace_idx,
402 struct _sim_fpu *f0,
403 struct _sim_fpu *f1);
404
405extern void trace_input_fpu3 (SIM_DESC sd,
406 sim_cpu *cpu,
407 int trace_idx,
408 struct _sim_fpu *f0,
409 struct _sim_fpu *f1,
410 struct _sim_fpu *f2);
c906108c
SS
411
412/* Other trace_input{_<fmt><nr-inputs>} functions can go here */
413
bdca5ee4
TT
414extern void trace_result0 (SIM_DESC sd,
415 sim_cpu *cpu,
416 int trace_idx);
417
418extern void trace_result_word1 (SIM_DESC sd,
419 sim_cpu *cpu,
420 int trace_idx,
421 unsigned_word r0);
422
423extern void trace_result_word2 (SIM_DESC sd,
424 sim_cpu *cpu,
425 int trace_idx,
426 unsigned_word r0,
427 unsigned_word r1);
428
429extern void trace_result_word4 (SIM_DESC sd,
430 sim_cpu *cpu,
431 int trace_idx,
432 unsigned_word r0,
433 unsigned_word r1,
434 unsigned_word r2,
435 unsigned_word r3);
436
437extern void trace_result_bool1 (SIM_DESC sd,
438 sim_cpu *cpu,
439 int trace_idx,
440 int r0);
441
442extern void trace_result_addr1 (SIM_DESC sd,
443 sim_cpu *cpu,
444 int trace_idx,
445 address_word r0);
446
447extern void trace_result_fp1 (SIM_DESC sd,
448 sim_cpu *cpu,
449 int trace_idx,
450 fp_word f0);
451
452extern void trace_result_fp2 (SIM_DESC sd,
453 sim_cpu *cpu,
454 int trace_idx,
455 fp_word f0,
456 fp_word f1);
457
458extern void trace_result_fpu1 (SIM_DESC sd,
459 sim_cpu *cpu,
460 int trace_idx,
461 struct _sim_fpu *f0);
462
463extern void trace_result_string1 (SIM_DESC sd,
464 sim_cpu *cpu,
465 int trace_idx,
466 char *str0);
c906108c 467
bdca5ee4 468extern void trace_result_word1_string1 (SIM_DESC sd,
c906108c
SS
469 sim_cpu *cpu,
470 int trace_idx,
471 unsigned_word r0,
bdca5ee4 472 char *s0);
c906108c
SS
473
474/* Other trace_result{_<type><nr-results>} */
475
476
44a9331c 477/* Macros for tracing ALU instructions */
c906108c
SS
478
479#define TRACE_ALU_INPUT0() \
480do { \
481 if (TRACE_ALU_P (CPU)) \
482 trace_input0 (SD, CPU, TRACE_ALU_IDX); \
483} while (0)
028f6515 484
c906108c
SS
485#define TRACE_ALU_INPUT1(V0) \
486do { \
487 if (TRACE_ALU_P (CPU)) \
488 trace_input_word1 (SD, CPU, TRACE_ALU_IDX, (V0)); \
489} while (0)
490
491#define TRACE_ALU_INPUT2(V0,V1) \
492do { \
493 if (TRACE_ALU_P (CPU)) \
494 trace_input_word2 (SD, CPU, TRACE_ALU_IDX, (V0), (V1)); \
495} while (0)
496
497#define TRACE_ALU_INPUT3(V0,V1,V2) \
498do { \
499 if (TRACE_ALU_P (CPU)) \
500 trace_input_word3 (SD, CPU, TRACE_ALU_IDX, (V0), (V1), (V2)); \
501} while (0)
502
503#define TRACE_ALU_INPUT4(V0,V1,V2,V3) \
504do { \
505 if (TRACE_ALU_P (CPU)) \
506 trace_input_word4 (SD, CPU, TRACE_ALU_IDX, (V0), (V1), (V2), (V3)); \
507} while (0)
508
509#define TRACE_ALU_RESULT(R0) TRACE_ALU_RESULT1(R0)
510
511#define TRACE_ALU_RESULT0() \
512do { \
513 if (TRACE_ALU_P (CPU)) \
514 trace_result0 (SD, CPU, TRACE_ALU_IDX); \
515} while (0)
516
517#define TRACE_ALU_RESULT1(R0) \
518do { \
519 if (TRACE_ALU_P (CPU)) \
520 trace_result_word1 (SD, CPU, TRACE_ALU_IDX, (R0)); \
521} while (0)
522
523#define TRACE_ALU_RESULT2(R0,R1) \
524do { \
525 if (TRACE_ALU_P (CPU)) \
526 trace_result_word2 (SD, CPU, TRACE_ALU_IDX, (R0), (R1)); \
527} while (0)
528
529#define TRACE_ALU_RESULT4(R0,R1,R2,R3) \
530do { \
531 if (TRACE_ALU_P (CPU)) \
532 trace_result_word4 (SD, CPU, TRACE_ALU_IDX, (R0), (R1), (R2), (R3)); \
533} while (0)
534
44a9331c 535/* Macros for tracing inputs to comparative branch instructions. */
c906108c 536
44a9331c
BE
537#define TRACE_BRANCH_INPUT1(V0) \
538do { \
539 if (TRACE_BRANCH_P (CPU)) \
540 trace_input_word1 (SD, CPU, TRACE_BRANCH_IDX, (V0)); \
541} while (0)
542
543#define TRACE_BRANCH_INPUT2(V0,V1) \
544do { \
545 if (TRACE_BRANCH_P (CPU)) \
546 trace_input_word2 (SD, CPU, TRACE_BRANCH_IDX, (V0), (V1)); \
547} while (0)
548
549/* Macros for tracing FPU instructions */
c906108c
SS
550
551#define TRACE_FP_INPUT0() \
552do { \
553 if (TRACE_FPU_P (CPU)) \
554 trace_input0 (SD, CPU, TRACE_FPU_IDX); \
555} while (0)
028f6515 556
c906108c
SS
557#define TRACE_FP_INPUT1(V0) \
558do { \
559 if (TRACE_FPU_P (CPU)) \
560 trace_input_fp1 (SD, CPU, TRACE_FPU_IDX, (V0)); \
561} while (0)
562
563#define TRACE_FP_INPUT2(V0,V1) \
564do { \
565 if (TRACE_FPU_P (CPU)) \
566 trace_input_fp2 (SD, CPU, TRACE_FPU_IDX, (V0), (V1)); \
567} while (0)
568
569#define TRACE_FP_INPUT3(V0,V1,V2) \
570do { \
571 if (TRACE_FPU_P (CPU)) \
572 trace_input_fp3 (SD, CPU, TRACE_FPU_IDX, (V0), (V1), (V2)); \
573} while (0)
574
575#define TRACE_FP_INPUT_WORD1(V0) \
576do { \
577 if (TRACE_FPU_P (CPU)) \
578 trace_input_word1 (SD, CPU, TRACE_FPU_IDX, (V0)); \
579} while (0)
028f6515 580
c906108c
SS
581#define TRACE_FP_RESULT(R0) \
582do { \
583 if (TRACE_FPU_P (CPU)) \
584 trace_result_fp1 (SD, CPU, TRACE_FPU_IDX, (R0)); \
585} while (0)
586
587#define TRACE_FP_RESULT2(R0,R1) \
588do { \
589 if (TRACE_FPU_P (CPU)) \
590 trace_result_fp2 (SD, CPU, TRACE_FPU_IDX, (R0), (R1)); \
591} while (0)
592
593#define TRACE_FP_RESULT_BOOL(R0) \
594do { \
595 if (TRACE_FPU_P (CPU)) \
596 trace_result_bool1 (SD, CPU, TRACE_FPU_IDX, (R0)); \
597} while (0)
598
599#define TRACE_FP_RESULT_WORD(R0) \
600do { \
601 if (TRACE_FPU_P (CPU)) \
602 trace_result_word1 (SD, CPU, TRACE_FPU_IDX, (R0)); \
603} while (0)
604
605
606/* Macros for tracing branches */
607
608#define TRACE_BRANCH_INPUT(COND) \
609do { \
610 if (TRACE_BRANCH_P (CPU)) \
611 trace_input_bool1 (SD, CPU, TRACE_BRANCH_IDX, (COND)); \
612} while (0)
613
614#define TRACE_BRANCH_RESULT(DEST) \
615do { \
616 if (TRACE_BRANCH_P (CPU)) \
617 trace_result_addr1 (SD, CPU, TRACE_BRANCH_IDX, (DEST)); \
618} while (0)
619
620\f
bdca5ee4 621extern void trace_printf (SIM_DESC, sim_cpu *, const char *, ...)
c906108c
SS
622 __attribute__((format (printf, 3, 4)));
623
bdca5ee4 624extern void trace_vprintf (SIM_DESC, sim_cpu *, const char *, va_list);
c906108c
SS
625
626/* Debug support.
627 This is included here because there isn't enough of it to justify
628 a sim-debug.h. */
629
630/* Return non-zero if debugging of IDX for CPU is enabled. */
631#define DEBUG_P(cpu, idx) \
632((WITH_DEBUG & (1 << (idx))) != 0 \
633 && CPU_DEBUG_FLAGS (cpu)[idx] != 0)
634
635/* Non-zero if "--debug-insn" specified. */
636#define DEBUG_INSN_P(cpu) DEBUG_P (cpu, DEBUG_INSN_IDX)
637
9b6025d1 638extern void sim_debug_printf (sim_cpu *, const char *, ...)
c906108c
SS
639 __attribute__((format (printf, 2, 3)));
640
641#endif /* SIM_TRACE_H */
This page took 0.719118 seconds and 4 git commands to generate.