1/* This file is part of the program psim. 2 3 Copyright (C) 1994-1997, Andrew Cagney <cagney@highland.com.au> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, see <http://www.gnu.org/licenses/>. 17 18 */ 19 20 21#ifndef _DEBUG_H_ 22#define _DEBUG_H_ 23 24#include "filter_filename.h" 25 26typedef enum { 27 trace_invalid, 28 trace_tbd, 29 /**/ 30 trace_gdb, 31 trace_os_emul, 32 /**/ 33 trace_events, 34 trace_device_tree, 35 trace_devices, 36 trace_binary_device, 37 trace_com_device, 38 trace_console_device, 39 trace_core_device, 40 trace_disk_device, 41 trace_eeprom_device, 42 trace_file_device, 43 trace_glue_device, 44 trace_halt_device, 45 trace_htab_device, 46 trace_icu_device, 47 trace_ide_device, 48 trace_memory_device, 49 trace_opic_device, 50 trace_pal_device, 51 trace_pass_device, 52 trace_phb_device, 53 trace_sem_device, 54 trace_shm_device, 55 trace_stack_device, 56 trace_register_device, 57 trace_vm_device, 58 /**/ 59 trace_disklabel_package, 60 /**/ 61 trace_semantics, 62 trace_idecode, 63 trace_alu, 64 trace_load_store, 65 trace_model, 66 /**/ 67 trace_vm, 68 trace_core, 69 trace_interrupts, 70 trace_psim, 71 trace_device_init, 72 trace_cpu, 73 trace_breakpoint, 74 trace_opts, 75 trace_print_info, 76 trace_print_device_tree, 77 trace_dump_device_tree, 78 nr_trace_options 79} trace_options; 80 81 82 83extern int ppc_trace[nr_trace_options]; 84 85/* simple */ 86#define TRACE(OBJECT, ARGS) \ 87do { \ 88 if (WITH_TRACE) { \ 89 if (ppc_trace[OBJECT]) { \ 90 sim_io_printf_filtered("%s:%d: ", filter_filename(__FILE__), __LINE__); \ 91 sim_io_printf_filtered ARGS; \ 92 } \ 93 } \ 94} while (0) 95 96/* issue */ 97#define ITRACE(OBJECT, ARGS) \ 98do { \ 99 if (WITH_TRACE) { \ 100 if (ppc_trace[OBJECT]) { \ 101 sim_io_printf_filtered("%s:%d:0x%08lx:%s ", itable[MY_INDEX].file, itable[MY_INDEX].line_nr, (long)cia, itable[MY_INDEX].name); \ 102 sim_io_printf_filtered ARGS; \ 103 } \ 104 } \ 105} while (0) 106 107/* device */ 108#define DTRACE(OBJECT, ARGS) \ 109do { \ 110 if (WITH_TRACE) { \ 111 int trace_device = device_trace(me); \ 112 if (ppc_trace[trace_devices] \ 113 || ppc_trace[trace_##OBJECT##_device] \ 114 || trace_device) { \ 115 sim_io_printf_filtered("%s:%d:%s:%s%s ", \ 116 filter_filename(__FILE__), __LINE__, #OBJECT, \ 117 trace_device ? device_path(me) : "", \ 118 trace_device ? ":" : ""); \ 119 sim_io_printf_filtered ARGS; \ 120 } \ 121 } \ 122} while (0) 123 124/* device instance */ 125#define DITRACE(OBJECT, ARGS) \ 126do { \ 127 if (WITH_TRACE) { \ 128 device *me = device_instance_device(instance); \ 129 int trace_device = device_trace(me); \ 130 if (ppc_trace[trace_devices] \ 131 || ppc_trace[trace_##OBJECT##_device] \ 132 || trace_device) { \ 133 sim_io_printf_filtered("%s:%d:%s:%s%s ", \ 134 filter_filename(__FILE__), __LINE__, #OBJECT, \ 135 trace_device ? device_path(me) : "", \ 136 trace_device ? ":" : ""); \ 137 sim_io_printf_filtered ARGS; \ 138 } \ 139 } \ 140} while (0) 141 142/* package */ 143#define PTRACE(OBJECT, ARGS) \ 144do { \ 145 if (WITH_TRACE) { \ 146 if (ppc_trace[trace_##OBJECT##_package]) { \ 147 sim_io_printf_filtered("%s:%d:%s: ", filter_filename(__FILE__), __LINE__, #OBJECT); \ 148 sim_io_printf_filtered ARGS; \ 149 } \ 150 } \ 151} while (0) 152 153 154#define ASSERT(EXPRESSION) \ 155do { \ 156 if (WITH_ASSERT) { \ 157 if (!(EXPRESSION)) { \ 158 error("%s:%d: assertion failed - %s\n", \ 159 filter_filename(__FILE__), __LINE__, #EXPRESSION); \ 160 } \ 161 } \ 162} while (0) 163 164/* Parse OPTION updating the trace array */ 165extern void 166trace_option(const char *option, int setting); 167 168/* Output the list of trace options */ 169extern void trace_usage 170(int verbose); 171 172/* TODO: These values aren't currently used by the ppc port. They're here to 173 glue the common sim compile-time settings in. The ppc_trace settings above 174 would need to be overhauled. */ 175#define TRACE_insn 1 176#define TRACE_disasm 1 177#define TRACE_decode 1 178#define TRACE_extract 1 179#define TRACE_linenum 1 180#define TRACE_memory 1 181#define TRACE_model 1 182#define TRACE_alu 1 183#define TRACE_core 1 184#define TRACE_events 1 185#define TRACE_fpu 1 186#define TRACE_vpu 1 187#define TRACE_branch 1 188#define TRACE_syscall 1 189#define TRACE_register 1 190#define TRACE_debug 1 191 192#endif /* _DEBUG_H_ */ 193