1 1.1 christos /* This file is part of the program psim. 2 1.1 christos 3 1.1 christos Copyright (C) 1994-1997, Andrew Cagney <cagney (at) highland.com.au> 4 1.1 christos 5 1.1 christos This program is free software; you can redistribute it and/or modify 6 1.1 christos it under the terms of the GNU General Public License as published by 7 1.1 christos the Free Software Foundation; either version 3 of the License, or 8 1.1 christos (at your option) any later version. 9 1.1 christos 10 1.1 christos This program is distributed in the hope that it will be useful, 11 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 12 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 1.1 christos GNU General Public License for more details. 14 1.1 christos 15 1.1 christos You should have received a copy of the GNU General Public License 16 1.1 christos along with this program; if not, see <http://www.gnu.org/licenses/>. 17 1.1 christos 18 1.1 christos */ 19 1.1 christos 20 1.1 christos 21 1.1 christos #ifndef _DEBUG_C_ 22 1.1 christos #define _DEBUG_C_ 23 1.1 christos 24 1.6 christos /* This must come before any other includes. */ 25 1.6 christos #include "defs.h" 26 1.6 christos 27 1.1 christos #include "basics.h" 28 1.1 christos 29 1.1 christos #include <stdlib.h> 30 1.1 christos #include <string.h> 31 1.1 christos 32 1.1 christos int ppc_trace[nr_trace_options]; 33 1.1 christos 34 1.1 christos typedef struct _trace_option_descriptor { 35 1.1 christos trace_options option; 36 1.1 christos const char *name; 37 1.1 christos const char *description; 38 1.1 christos } trace_option_descriptor; 39 1.1 christos 40 1.1 christos static trace_option_descriptor trace_description[] = { 41 1.1 christos { trace_gdb, "gdb", "calls made by gdb to the sim_calls.c file" }, 42 1.1 christos { trace_os_emul, "os-emul", "VEA mode sytem calls - like strace" }, 43 1.1 christos { trace_events, "events", "event queue handling" }, 44 1.1 christos /* decode/issue */ 45 1.1 christos { trace_semantics, "semantics", "Instruction execution (issue)" }, 46 1.1 christos { trace_idecode, "idecode", "instruction decode (when miss in icache)" }, 47 1.1 christos { trace_alu, "alu", "results of integer ALU" }, 48 1.1 christos { trace_vm, "vm", "OEA address translation" }, 49 1.1 christos { trace_load_store, "load-store", "transfers between registers and memory" }, 50 1.1 christos { trace_model, "model", "model specific information" }, 51 1.1 christos { trace_interrupts, "interrupts", "interrupt handling" }, 52 1.1 christos /* devices */ 53 1.1 christos { trace_device_tree, "device-tree", }, 54 1.1 christos { trace_devices, "devices" }, 55 1.1 christos { trace_binary_device, "binary-device" }, 56 1.1 christos { trace_com_device, "com-device" }, 57 1.1 christos { trace_console_device, "console-device" }, 58 1.1 christos { trace_core_device, "core-device" }, 59 1.1 christos { trace_disk_device, "disk-device" }, 60 1.1 christos { trace_eeprom_device, "eeprom-device" }, 61 1.1 christos { trace_file_device, "file-device" }, 62 1.1 christos { trace_glue_device, "glue-device" }, 63 1.1 christos { trace_halt_device, "halt-device" }, 64 1.1 christos { trace_htab_device, "htab-device" }, 65 1.1 christos { trace_icu_device, "icu-device" }, 66 1.1 christos { trace_ide_device, "ide-device" }, 67 1.1 christos { trace_memory_device, "memory-device" }, 68 1.1 christos { trace_opic_device, "opic-device" }, 69 1.1 christos { trace_pal_device, "pal-device" }, 70 1.1 christos { trace_pass_device, "pass-device" }, 71 1.1 christos { trace_phb_device, "phb-device" }, 72 1.1 christos { trace_register_device, "register-device", "Device initializing registers" }, 73 1.1 christos { trace_sem_device, "sem-device" }, 74 1.1 christos { trace_shm_device, "shm-device" }, 75 1.1 christos { trace_stack_device, "stack-device" }, 76 1.1 christos { trace_vm_device, "vm-device" }, 77 1.1 christos /* packages */ 78 1.1 christos { trace_disklabel_package, "disklabel-package" }, 79 1.1 christos /* misc */ 80 1.1 christos { trace_print_info, "print-info", "Print performance analysis information" }, 81 1.1 christos { trace_opts, "options", "Print options simulator was compiled with" }, 82 1.1 christos /*{ trace_tbd, "tbd", "Trace any missing features" },*/ 83 1.1 christos { trace_print_device_tree, "print-device-tree", "Output the contents of the device tree" }, 84 1.1 christos { trace_dump_device_tree, "dump-device-tree", "Output the contents of the device tree then exit" }, 85 1.1 christos /* sentinal */ 86 1.1 christos { nr_trace_options, NULL }, 87 1.1 christos }; 88 1.1 christos 89 1.1 christos extern void 90 1.1 christos trace_option(const char *option, 91 1.1 christos int setting) 92 1.1 christos { 93 1.1 christos if (strcmp(option, "all") == 0) { 94 1.1 christos trace_options i; 95 1.1 christos for (i = 0; i < nr_trace_options; i++) 96 1.1 christos if (i != trace_dump_device_tree) { 97 1.1 christos ppc_trace[i] = setting; 98 1.1 christos } 99 1.1 christos } 100 1.1 christos else { 101 1.1 christos int i = 0; 102 1.1 christos while (trace_description[i].option < nr_trace_options 103 1.1 christos && strcmp(option, trace_description[i].name) != 0) 104 1.1 christos i++; 105 1.1 christos if (trace_description[i].option < nr_trace_options) 106 1.1 christos ppc_trace[trace_description[i].option] = setting; 107 1.1 christos else { 108 1.1 christos i = strtoul(option, 0, 0); 109 1.1 christos if (i > 0 && i < nr_trace_options) 110 1.1 christos ppc_trace[i] = setting; 111 1.1 christos else 112 1.1 christos error("Unknown trace option: %s\n", option); 113 1.1 christos } 114 1.1 christos 115 1.1 christos } 116 1.1 christos } 117 1.1 christos 118 1.1 christos 119 1.1 christos extern void 120 1.1 christos trace_usage(int verbose) 121 1.1 christos { 122 1.1 christos if (verbose) { 123 1.1 christos printf_filtered("\n"); 124 1.1 christos printf_filtered("The following are possible <trace> options:\n"); 125 1.1 christos printf_filtered("\n"); 126 1.1 christos } 127 1.1 christos if (verbose == 1) { 128 1.1 christos int pos; 129 1.1 christos int i; 130 1.1 christos printf_filtered(" all"); 131 1.1 christos pos = strlen("all") + 2; 132 1.1 christos for (i = 0; trace_description[i].option < nr_trace_options; i++) { 133 1.1 christos pos += strlen(trace_description[i].name) + 2; 134 1.1 christos if (pos > 75) { 135 1.1 christos pos = strlen(trace_description[i].name) + 2; 136 1.1 christos printf_filtered("\n"); 137 1.1 christos } 138 1.1 christos printf_filtered(" %s", trace_description[i].name); 139 1.1 christos } 140 1.1 christos printf_filtered("\n"); 141 1.1 christos } 142 1.1 christos if (verbose > 1) { 143 1.6 christos static const char format[] = "\t%-18s%s\n"; 144 1.1 christos int i; 145 1.1 christos printf_filtered(format, "all", "enable all the trace options"); 146 1.1 christos for (i = 0; trace_description[i].option < nr_trace_options; i++) 147 1.1 christos printf_filtered(format, 148 1.1 christos trace_description[i].name, 149 1.1 christos (trace_description[i].description 150 1.1 christos ? trace_description[i].description 151 1.1 christos : "")); 152 1.1 christos } 153 1.1 christos } 154 1.1 christos 155 1.1 christos #endif /* _DEBUG_C_ */ 156