debug.c 5.0 KB

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