debug.c 5.0 KB

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