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