* elf64-ppc.c (dec_dynrel_count): Don't error when elf_gc_sweep_symbol
[external/binutils.git] / sim / ppc / debug.c
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_C_
22 #define _DEBUG_C_
23
24 #include "config.h"
25 #include "basics.h"
26
27 #ifdef HAVE_STDLIB_H
28 #include <stdlib.h>
29 #endif
30 #ifdef HAVE_STRING_H
31 #include <string.h>
32 #endif
33
34 int ppc_trace[nr_trace_options];
35
36 typedef struct _trace_option_descriptor {
37   trace_options option;
38   const char *name;
39   const char *description;
40 } trace_option_descriptor;
41
42 static trace_option_descriptor trace_description[] = {
43   { trace_gdb, "gdb", "calls made by gdb to the sim_calls.c file" },
44   { trace_os_emul, "os-emul", "VEA mode sytem calls - like strace" },
45   { trace_events, "events", "event queue handling" },
46   /* decode/issue */
47   { trace_semantics, "semantics", "Instruction execution (issue)" },
48   { trace_idecode, "idecode", "instruction decode (when miss in icache)" },
49   { trace_alu, "alu", "results of integer ALU" },
50   { trace_vm, "vm", "OEA address translation" },
51   { trace_load_store, "load-store", "transfers between registers and memory" },
52   { trace_model, "model", "model specific information" },
53   { trace_interrupts, "interrupts", "interrupt handling" },
54   /* devices */
55   { trace_device_tree, "device-tree",  },
56   { trace_devices, "devices" },
57   { trace_binary_device, "binary-device" },
58   { trace_com_device, "com-device" },
59   { trace_console_device, "console-device" },
60   { trace_core_device, "core-device" },
61   { trace_disk_device, "disk-device" },
62   { trace_eeprom_device, "eeprom-device" },
63   { trace_file_device, "file-device" },
64   { trace_glue_device, "glue-device" },
65   { trace_halt_device, "halt-device" },
66   { trace_htab_device, "htab-device" },
67   { trace_icu_device, "icu-device" },
68   { trace_ide_device, "ide-device" },
69   { trace_memory_device, "memory-device" },
70   { trace_opic_device, "opic-device" },
71   { trace_pal_device, "pal-device" },
72   { trace_pass_device, "pass-device" },
73   { trace_phb_device, "phb-device" },
74   { trace_register_device, "register-device", "Device initializing registers" },
75   { trace_sem_device, "sem-device" },
76   { trace_shm_device, "shm-device" },
77   { trace_stack_device, "stack-device" },
78   { trace_vm_device, "vm-device" },
79   /* packages */
80   { trace_disklabel_package, "disklabel-package" },
81   /* misc */
82   { trace_print_info, "print-info", "Print performance analysis information" },
83   { trace_opts, "options", "Print options simulator was compiled with" },
84   /*{ trace_tbd, "tbd", "Trace any missing features" },*/
85   { trace_print_device_tree, "print-device-tree", "Output the contents of the device tree" },
86   { trace_dump_device_tree, "dump-device-tree", "Output the contents of the device tree then exit" },
87   /* sentinal */
88   { nr_trace_options, NULL },
89 };
90
91 extern void
92 trace_option(const char *option,
93              int setting)
94 {
95   if (strcmp(option, "all") == 0) {
96     trace_options i;
97     for (i = 0; i < nr_trace_options; i++)
98       if (i != trace_dump_device_tree) {
99         ppc_trace[i] = setting;
100       }
101   }
102   else {
103     int i = 0;
104     while (trace_description[i].option < nr_trace_options
105            && strcmp(option, trace_description[i].name) != 0)
106       i++;
107     if (trace_description[i].option < nr_trace_options)
108       ppc_trace[trace_description[i].option] = setting;
109     else {
110       i = strtoul(option, 0, 0);
111       if (i > 0 && i < nr_trace_options)
112         ppc_trace[i] = setting;
113       else
114         error("Unknown trace option: %s\n", option);
115     }
116       
117   }
118 }
119
120
121 extern void
122 trace_usage(int verbose)
123 {
124   if (verbose) {
125     printf_filtered("\n");
126     printf_filtered("The following are possible <trace> options:\n");
127     printf_filtered("\n");
128   }
129   if (verbose == 1) {
130     int pos;
131     int i;
132     printf_filtered("  all");
133     pos = strlen("all") + 2;
134     for (i = 0; trace_description[i].option < nr_trace_options; i++) {
135       pos += strlen(trace_description[i].name) + 2;
136       if (pos > 75) {
137         pos = strlen(trace_description[i].name) + 2;
138         printf_filtered("\n");
139       }
140       printf_filtered("  %s", trace_description[i].name);
141     }
142     printf_filtered("\n");
143   }
144   if (verbose > 1) {
145     const char *format = "\t%-18s%s\n";
146     int i;
147     printf_filtered(format, "all", "enable all the trace options");
148     for (i = 0; trace_description[i].option < nr_trace_options; i++)
149       printf_filtered(format,
150                       trace_description[i].name,
151                       (trace_description[i].description
152                        ? trace_description[i].description
153                        : ""));
154   }
155 }
156
157 #endif /* _DEBUG_C_ */