Advertisement
PT_

Untitled

PT_
Apr 28th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. /**
  2. * @file
  3. * @author Matt "MateoConLechuga" Waltz
  4. * @brief Contains useful debugging features for use with the integrated CEmu debugger
  5. */
  6.  
  7. /**
  8. * void dbg_sprintf(out, const char*, ...)
  9. *
  10. * @brief Use to print to the emulator console.
  11. *
  12. * See the syntax for 'printf' for more information
  13. * @param out Can be dbgout (black) or dbgerr (red)
  14. * @def dbg_sprintf
  15. */
  16.  
  17. /**
  18. * void dbg_Debugger(void)
  19. *
  20. * @brief Opens the debugger
  21. * @def dbg_Debugger
  22. */
  23.  
  24. /**
  25. * void dbg_SetBreakpoint(void *address)
  26. *
  27. * @brief Sets a breakpoint at a particular address in an emulator
  28. * @param address The address of the breakpoint to set
  29. * @def dbg_SetBreakpoint
  30. */
  31.  
  32. /**
  33. * @def dbg_RemoveBreakpoint
  34. * void dbg_RemoveBreakpoint(void *address)
  35. *
  36. * @brief Removes a breakpoint at a particular address in an emulator
  37. * @param address The address of the breakpoint to remove
  38. */
  39.  
  40. /**
  41. * void dbg_SetWatchpoint(void *address, unsigned length)
  42. *
  43. * @brief Sets a non-breaking watchpoint at a particular address in an emulator
  44. * @param address The address of the watchpoint to set
  45. * @param length The size of the data at the address (values 1-4)
  46. * @def dbg_SetWatchpoint
  47. */
  48.  
  49. /**
  50. * void dbg_SetReadWatchpoint(void *address, unsigned length)
  51. *
  52. * @brief Sets a read watchpoint at a particular address in an emulator
  53. * @param address The address of the watchpoint to set
  54. * @param length The size of the data at the address (values 1-4)
  55. * @def dbg_SetReadWatchpoint
  56. */
  57.  
  58. /**
  59. * void dbg_SetWriteWatchpoint(void *address, unsigned length)
  60. *
  61. * @brief Sets a write watchpoint at a particular address in an emulator
  62. * @param address The address of the watchpoint to set
  63. * @param length The size of the data at the address (values 1-4)
  64. * @def dbg_SetWriteWatchpoint
  65. */
  66.  
  67. /**
  68. * void dbg_SetReadWriteWatchpoint(void *address, unsigned length)
  69. *
  70. * @brief Sets a read and write watchpoint at a particular address in an emulator
  71. * @param address The address of the watchpoint to set
  72. * @param length The size of the data at the address (values 1-4)
  73. * @def dbg_SetReadWriteWatchpoint
  74. */
  75.  
  76. /**
  77. * void dbg_RemoveWatchpoint(void *address)
  78. *
  79. * @brief Removes a watchpoint at a particular address in an emulator
  80. * @param address The address of the watchpoint to remove
  81. * @def dbg_RemoveWatchpoint
  82. */
  83.  
  84. /**
  85. * void dbg_RemoveAllBreakpoints(void)
  86. * @brief Removes all breakpoints in an emulator
  87. * @def dbg_RemoveAllBreakpoints(void)
  88. */
  89.  
  90. /**
  91. * void dbg_RemoveAllWatchpoints(void)
  92. * @brief Removes all watchpoints in an emulator
  93. * @def dbg_RemoveAllWatchpoints
  94. */
  95.  
  96. /* Preprocessor definitions (should not be looked at :P) */
  97. #ifdef dbg_Debugger
  98. #undef dbg_Debugger
  99. #endif
  100.  
  101. #ifdef dbg_SetBreakpoint
  102. #undef dbg_SetBreakpoint
  103. #endif
  104.  
  105. #ifdef dbg_RemoveBreakpoint
  106. #undef dbg_RemoveBreakpoint
  107. #endif
  108.  
  109. #ifdef dbg_RemoveWatchpoint
  110. #undef dbg_RemoveWatchpoint
  111. #endif
  112.  
  113. #ifdef dbg_SetWatchpoint
  114. #undef dbg_SetWatchpoint
  115. #endif
  116.  
  117. #ifdef dbg_SetReadWriteWatchpoint
  118. #undef dbg_SetReadWriteWatchpoint
  119. #endif
  120.  
  121. #ifdef dbg_SetReadWatchpoint
  122. #undef dbg_SetReadWatchpoint
  123. #endif
  124.  
  125. #ifdef dbg_SetWriteWatchpoint
  126. #undef dbg_SetWriteWatchpoint
  127. #endif
  128.  
  129. #ifdef dbg_RemoveAllWatchpoints
  130. #undef dbg_RemoveAllWatchpoints
  131. #endif
  132.  
  133. #ifdef dbg_RemoveAllBreakpoints
  134. #undef dbg_RemoveAllBreakpoints
  135. #endif
  136.  
  137. #ifdef dbg_sprintf
  138. #undef dbg_sprintf
  139. #endif
  140.  
  141. #ifdef dbgout
  142. #undef dbgout
  143. #endif
  144.  
  145. #ifdef dbgerr
  146. #undef dbgerr
  147. #endif
  148.  
  149. #ifndef NDEBUG
  150. #define dbg_Debugger Debugger
  151. #define dbg_SetBreakpoint SetBreakpoint
  152. #define dbg_RemoveBreakpoint RemoveBreakpoint
  153. #define dbg_SetWatchpoint SetWatchpoint
  154. #define dbg_SetReadWatchpoint SetReadWatchpoint
  155. #define dbg_SetWriteWatchpoint SetWriteWatchpoint
  156. #define dbg_SetReadWriteWatchpoint SetReadWriteWatchpoint
  157. #define dbg_RemoveWatchpoint RemoveWatchpoint
  158. #define dbg_RemoveAllWatchpoints RemoveAllWatchpoints
  159. #define dbg_RemoveAllBreakpoints RemoveAllBreakpoints
  160. #define dbg_sprintf sprintf
  161. #define dbgout ((const char*)0xFB0000)
  162. #define dbgerr ((const char*)0xFC0000)
  163. #else
  164. #define dbg_Debugger(ignore) //
  165. #define dbg_SetBreakpoint(ignore) //
  166. #define dbg_RemoveBreakpoint(ignore) //
  167. #define dbg_SetWatchpoint(ignore,ignore) //
  168. #define dbg_SetReadWatchpoint(ignore,ignore) //
  169. #define dbg_SetWriteWatchpoint(ignore,ignore) //
  170. #define dbg_SetReadWriteWatchpoint(ignore,ignore) //
  171. #define dbg_RemoveWatchpoint(ignore) //
  172. #define dbg_RemoveAllWatchpoints(ignore) //
  173. #define dbg_RemoveAllBreakpoints(ignore) //
  174. #define dbg_sprintf //
  175. #define dbgout (NULL)
  176. #define dbgerr (NULL)
  177. #endif
  178.  
  179. /* simple function prototypes (should not ever be used or even looked at) */
  180. void SetBreakpoint(void *address);
  181. void RemoveBreakpoint(void *address);
  182. void SetWatchpoint(void *address, unsigned length);
  183. void SetReadWatchpoint(void *address, unsigned length);
  184. void SetWriteWatchpoint(void *address, unsigned length);
  185. void SetReadWriteWatchpoint(void *address, unsigned length);
  186. void RemoveWatchpoint(void *address);
  187. void RemoveAllWatchpoints(void);
  188. void RemoveAllBreakpoints(void);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement