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 2 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, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 */ 20 21 22#ifndef _DEBUG_H_ 23#define _DEBUG_H_ 24 25#include "filter_filename.h" 26 27typedef enum { 28 trace_invalid, 29 trace_tbd, 30 /**/ 31 trace_gdb, 32 trace_os_emul, 33 /**/ 34 trace_events, 35 trace_device_tree, 36 trace_devices, 37 trace_binary_device, 38 trace_com_device, 39 trace_console_device, 40 trace_core_device, 41 trace_disk_device, 42 trace_eeprom_device, 43 trace_file_device, 44 trace_glue_device, 45 trace_halt_device, 46 trace_htab_device, 47 trace_icu_device, 48 trace_ide_device, 49 trace_memory_device, 50 trace_opic_device, 51 trace_pal_device, 52 trace_pass_device, 53 trace_phb_device, 54 trace_sem_device, 55 trace_shm_device, 56 trace_stack_device, 57 trace_register_device, 58 trace_vm_device, 59 /**/ 60 trace_disklabel_package, 61 /**/ 62 trace_semantics, 63 trace_idecode, 64 trace_alu, 65 trace_load_store, 66 trace_model, 67 /**/ 68 trace_vm, 69 trace_core, 70 trace_interrupts, 71 trace_psim, 72 trace_device_init, 73 trace_cpu, 74 trace_breakpoint, 75 trace_opts, 76 trace_print_info, 77 trace_print_device_tree, 78 trace_dump_device_tree, 79 nr_trace_options 80} trace_options; 81 82 83 84extern int ppc_trace[nr_trace_options]; 85 86/* simple */ 87#define TRACE(OBJECT, ARGS) \ 88do { \ 89 if (WITH_TRACE) { \ 90 if (ppc_trace[OBJECT]) { \ 91 printf_filtered("%s:%d: ", filter_filename(__FILE__), __LINE__); \ 92 printf_filtered ARGS; \ 93 } \ 94 } \ 95} while (0) 96 97/* issue */ 98#define ITRACE(OBJECT, ARGS) \ 99do { \ 100 if (WITH_TRACE) { \ 101 if (ppc_trace[OBJECT]) { \ 102 printf_filtered("%s:%d:0x%08lx:%s ", itable[MY_INDEX].file, itable[MY_INDEX].line_nr, (long)cia, itable[MY_INDEX].name); \ 103 printf_filtered ARGS; \ 104 } \ 105 } \ 106} while (0) 107 108/* device */ 109#define DTRACE(OBJECT, ARGS) \ 110do { \ 111 if (WITH_TRACE) { \ 112 int trace_device = device_trace(me); \ 113 if (ppc_trace[trace_devices] \ 114 || ppc_trace[trace_##OBJECT##_device] \ 115 || trace_device) { \ 116 printf_filtered("%s:%d:%s:%s%s ", \ 117 filter_filename(__FILE__), __LINE__, #OBJECT, \ 118 trace_device ? device_path(me) : "", \ 119 trace_device ? ":" : ""); \ 120 printf_filtered ARGS; \ 121 } \ 122 } \ 123} while (0) 124 125/* device instance */ 126#define DITRACE(OBJECT, ARGS) \ 127do { \ 128 if (WITH_TRACE) { \ 129 device *me = device_instance_device(instance); \ 130 int trace_device = device_trace(me); \ 131 if (ppc_trace[trace_devices] \ 132 || ppc_trace[trace_##OBJECT##_device] \ 133 || trace_device) { \ 134 printf_filtered("%s:%d:%s:%s%s ", \ 135 filter_filename(__FILE__), __LINE__, #OBJECT, \ 136 trace_device ? device_path(me) : "", \ 137 trace_device ? ":" : ""); \ 138 printf_filtered ARGS; \ 139 } \ 140 } \ 141} while (0) 142 143/* package */ 144#define PTRACE(OBJECT, ARGS) \ 145do { \ 146 if (WITH_TRACE) { \ 147 if (ppc_trace[trace_##OBJECT##_package]) { \ 148 printf_filtered("%s:%d:%s: ", filter_filename(__FILE__), __LINE__, #OBJECT); \ 149 printf_filtered ARGS; \ 150 } \ 151 } \ 152} while (0) 153 154 155#define ASSERT(EXPRESSION) \ 156do { \ 157 if (WITH_ASSERT) { \ 158 if (!(EXPRESSION)) { \ 159 error("%s:%d: assertion failed - %s\n", \ 160 filter_filename(__FILE__), __LINE__, #EXPRESSION); \ 161 } \ 162 } \ 163} while (0) 164 165/* Parse OPTION updating the trace array */ 166extern void 167trace_option(const char *option, int setting); 168 169/* Output the list of trace options */ 170extern void trace_usage 171(int verbose); 172 173 174#endif /* _DEBUG_H_ */ 175