debug.h 4.6 KB

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