Automatic Copyright Year update after running gdb/copyright.py
[binutils-gdb.git] / sim / common / cgen-trace.h
1 /* Simulator tracing support for Cpu tools GENerated simulators.
2 Copyright (C) 1996-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 #ifndef CGEN_TRACE_H
21 #define CGEN_TRACE_H
22
23 #include "ansidecl.h"
24
25 void cgen_trace_insn_init (SIM_CPU *, int);
26 void cgen_trace_insn_fini (SIM_CPU *, const struct argbuf *, int);
27 void cgen_trace_insn (SIM_CPU *, const struct cgen_insn *,
28 const struct argbuf *, IADDR);
29 void cgen_trace_extract (SIM_CPU *, IADDR, const char *, ...);
30 void cgen_trace_result (SIM_CPU *, const char *, int, ...);
31 void cgen_trace_printf (SIM_CPU *, const char *fmt, ...) ATTRIBUTE_PRINTF_2;
32
33 /* Trace instruction results. */
34 #define CGEN_TRACE_RESULT_P(cpu, abuf) \
35 (TRACE_INSN_P (cpu) && ARGBUF_TRACE_P (abuf))
36
37 #define CGEN_TRACE_INSN_INIT(cpu, abuf, first_p) \
38 do { \
39 if (TRACE_INSN_P (cpu)) \
40 cgen_trace_insn_init ((cpu), (first_p)); \
41 } while (0)
42 #define CGEN_TRACE_INSN_FINI(cpu, abuf, last_p) \
43 do { \
44 if (TRACE_INSN_P (cpu)) \
45 cgen_trace_insn_fini ((cpu), (abuf), (last_p)); \
46 } while (0)
47 #define CGEN_TRACE_PRINTF(cpu, what, args) \
48 do { \
49 if (TRACE_P ((cpu), (what))) \
50 cgen_trace_printf args ; \
51 } while (0)
52 #define CGEN_TRACE_INSN(cpu, insn, abuf, pc) \
53 do { \
54 if (TRACE_INSN_P (cpu) && ARGBUF_TRACE_P (abuf)) \
55 cgen_trace_insn ((cpu), (insn), (abuf), (pc)) ; \
56 } while (0)
57 #define CGEN_TRACE_EXTRACT(cpu, abuf, args) \
58 do { \
59 if (TRACE_EXTRACT_P (cpu)) \
60 cgen_trace_extract args ; \
61 } while (0)
62 #define CGEN_TRACE_RESULT(cpu, abuf, name, type, val) \
63 do { \
64 if (CGEN_TRACE_RESULT_P ((cpu), (abuf))) \
65 cgen_trace_result ((cpu), (name), (type), (val)) ; \
66 } while (0)
67 \f
68 /* Disassembly support. */
69
70 /* Function to use for cgen-based disassemblers. */
71 extern CGEN_DISASSEMBLER sim_cgen_disassemble_insn;
72
73 /* Pseudo FILE object for strings. */
74 typedef struct {
75 char *buffer;
76 char *current;
77 } SFILE;
78
79 /* String printer for the disassembler. */
80 extern int sim_disasm_sprintf (SFILE *, const char *, ...) ATTRIBUTE_PRINTF_2;
81
82 /* For opcodes based disassemblers. */
83 #ifdef __BFD_H_SEEN__
84 struct disassemble_info;
85 extern int
86 sim_disasm_read_memory (bfd_vma memaddr_, bfd_byte *myaddr_, unsigned int length_,
87 struct disassemble_info *info_);
88 extern void
89 sim_disasm_perror_memory (int status_, bfd_vma memaddr_,
90 struct disassemble_info *info_);
91 #endif
92
93 #endif /* CGEN_TRACE_H */