1 1.1 christos /* Simulator tracing support for Cpu tools GENerated simulators. 2 1.1.1.11 christos Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 1.1 christos Contributed by Cygnus Support. 4 1.1 christos 5 1.1 christos This file is part of GDB, the GNU debugger. 6 1.1 christos 7 1.1 christos This program is free software; you can redistribute it and/or modify 8 1.1 christos it under the terms of the GNU General Public License as published by 9 1.1 christos the Free Software Foundation; either version 3 of the License, or 10 1.1 christos (at your option) any later version. 11 1.1 christos 12 1.1 christos This program is distributed in the hope that it will be useful, 13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 1.1 christos GNU General Public License for more details. 16 1.1 christos 17 1.1 christos You should have received a copy of the GNU General Public License 18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 1.1 christos 20 1.1 christos #ifndef CGEN_TRACE_H 21 1.1 christos #define CGEN_TRACE_H 22 1.1 christos 23 1.1.1.10 christos #include "ansidecl.h" 24 1.1.1.11 christos #include "bfd.h" 25 1.1.1.10 christos 26 1.1.1.5 christos void cgen_trace_insn_init (SIM_CPU *, int); 27 1.1.1.5 christos void cgen_trace_insn_fini (SIM_CPU *, const struct argbuf *, int); 28 1.1.1.5 christos void cgen_trace_insn (SIM_CPU *, const struct cgen_insn *, 29 1.1.1.5 christos const struct argbuf *, IADDR); 30 1.1.1.10 christos void cgen_trace_extract (SIM_CPU *, IADDR, const char *, ...); 31 1.1.1.10 christos void cgen_trace_result (SIM_CPU *, const char *, int, ...); 32 1.1.1.10 christos void cgen_trace_printf (SIM_CPU *, const char *fmt, ...) ATTRIBUTE_PRINTF_2; 33 1.1 christos 34 1.1 christos /* Trace instruction results. */ 35 1.1.1.5 christos #define CGEN_TRACE_RESULT_P(cpu, abuf) \ 36 1.1.1.5 christos (TRACE_INSN_P (cpu) && ARGBUF_TRACE_P (abuf)) 37 1.1 christos 38 1.1.1.5 christos #define CGEN_TRACE_INSN_INIT(cpu, abuf, first_p) \ 39 1.1 christos do { \ 40 1.1 christos if (TRACE_INSN_P (cpu)) \ 41 1.1.1.5 christos cgen_trace_insn_init ((cpu), (first_p)); \ 42 1.1 christos } while (0) 43 1.1.1.5 christos #define CGEN_TRACE_INSN_FINI(cpu, abuf, last_p) \ 44 1.1 christos do { \ 45 1.1 christos if (TRACE_INSN_P (cpu)) \ 46 1.1.1.5 christos cgen_trace_insn_fini ((cpu), (abuf), (last_p)); \ 47 1.1 christos } while (0) 48 1.1.1.5 christos #define CGEN_TRACE_PRINTF(cpu, what, args) \ 49 1.1 christos do { \ 50 1.1 christos if (TRACE_P ((cpu), (what))) \ 51 1.1 christos cgen_trace_printf args ; \ 52 1.1 christos } while (0) 53 1.1.1.5 christos #define CGEN_TRACE_INSN(cpu, insn, abuf, pc) \ 54 1.1 christos do { \ 55 1.1 christos if (TRACE_INSN_P (cpu) && ARGBUF_TRACE_P (abuf)) \ 56 1.1.1.5 christos cgen_trace_insn ((cpu), (insn), (abuf), (pc)) ; \ 57 1.1 christos } while (0) 58 1.1.1.5 christos #define CGEN_TRACE_EXTRACT(cpu, abuf, args) \ 59 1.1 christos do { \ 60 1.1 christos if (TRACE_EXTRACT_P (cpu)) \ 61 1.1.1.5 christos cgen_trace_extract args ; \ 62 1.1 christos } while (0) 63 1.1.1.5 christos #define CGEN_TRACE_RESULT(cpu, abuf, name, type, val) \ 64 1.1 christos do { \ 65 1.1.1.5 christos if (CGEN_TRACE_RESULT_P ((cpu), (abuf))) \ 66 1.1.1.5 christos cgen_trace_result ((cpu), (name), (type), (val)) ; \ 67 1.1 christos } while (0) 68 1.1 christos 69 1.1 christos /* Disassembly support. */ 71 1.1 christos 72 1.1 christos /* Function to use for cgen-based disassemblers. */ 73 1.1 christos extern CGEN_DISASSEMBLER sim_cgen_disassemble_insn; 74 1.1 christos 75 1.1 christos /* Pseudo FILE object for strings. */ 76 1.1 christos typedef struct { 77 1.1 christos char *buffer; 78 1.1 christos char *current; 79 1.1 christos } SFILE; 80 1.1 christos 81 1.1.1.10 christos /* String printer for the disassembler. */ 82 1.1.1.10 christos extern int sim_disasm_sprintf (SFILE *, const char *, ...) ATTRIBUTE_PRINTF_2; 83 1.1 christos extern int sim_disasm_styled_sprintf (SFILE *, enum disassembler_style, const char *, ...) ATTRIBUTE_PRINTF_3; 84 1.1 christos 85 1.1 christos /* For opcodes based disassemblers. */ 86 1.1 christos #ifdef __BFD_H_SEEN__ 87 1.1 christos struct disassemble_info; 88 1.1 christos extern int 89 1.1 christos sim_disasm_read_memory (bfd_vma memaddr_, bfd_byte *myaddr_, unsigned int length_, 90 1.1 christos struct disassemble_info *info_); 91 1.1 christos extern void 92 1.1 christos sim_disasm_perror_memory (int status_, bfd_vma memaddr_, 93 1.1 christos struct disassemble_info *info_); 94 1.1 christos #endif 95 1.1 christos 96 #endif /* CGEN_TRACE_H */ 97