phpdbg_bp.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Authors: Felipe Pena <felipe@php.net> |
  14. | Authors: Joe Watkins <joe.watkins@live.co.uk> |
  15. | Authors: Bob Weinand <bwoebi@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. #ifndef PHPDBG_BP_H
  19. #define PHPDBG_BP_H
  20. /* {{{ defines */
  21. #define PHPDBG_BREAK_FILE 0
  22. #define PHPDBG_BREAK_FILE_PENDING 1
  23. #define PHPDBG_BREAK_SYM 2
  24. #define PHPDBG_BREAK_OPLINE 3
  25. #define PHPDBG_BREAK_METHOD 4
  26. #define PHPDBG_BREAK_COND 5
  27. #define PHPDBG_BREAK_OPCODE 6
  28. #define PHPDBG_BREAK_FUNCTION_OPLINE 7
  29. #define PHPDBG_BREAK_METHOD_OPLINE 8
  30. #define PHPDBG_BREAK_FILE_OPLINE 9
  31. #define PHPDBG_BREAK_MAP 10
  32. #define PHPDBG_BREAK_TABLES 11 /* }}} */
  33. /* {{{ */
  34. typedef struct _zend_op *phpdbg_opline_ptr_t; /* }}} */
  35. /* {{{ breakpoint base structure */
  36. #define phpdbg_breakbase(name) \
  37. int id; \
  38. zend_uchar type; \
  39. zend_ulong hits; \
  40. bool disabled; \
  41. const char *name /* }}} */
  42. /* {{{ breakpoint base */
  43. typedef struct _phpdbg_breakbase_t {
  44. phpdbg_breakbase(name);
  45. } phpdbg_breakbase_t; /* }}} */
  46. /**
  47. * Breakpoint file-based representation
  48. */
  49. typedef struct _phpdbg_breakfile_t {
  50. phpdbg_breakbase(filename);
  51. zend_ulong line;
  52. } phpdbg_breakfile_t;
  53. /**
  54. * Breakpoint symbol-based representation
  55. */
  56. typedef struct _phpdbg_breaksymbol_t {
  57. phpdbg_breakbase(symbol);
  58. } phpdbg_breaksymbol_t;
  59. /**
  60. * Breakpoint method based representation
  61. */
  62. typedef struct _phpdbg_breakmethod_t {
  63. phpdbg_breakbase(class_name);
  64. size_t class_len;
  65. const char *func_name;
  66. size_t func_len;
  67. } phpdbg_breakmethod_t;
  68. /**
  69. * Breakpoint opline num based representation
  70. */
  71. typedef struct _phpdbg_breakopline_t {
  72. phpdbg_breakbase(func_name);
  73. size_t func_len;
  74. const char *class_name;
  75. size_t class_len;
  76. zend_ulong opline_num;
  77. zend_ulong opline;
  78. } phpdbg_breakopline_t;
  79. /**
  80. * Breakpoint opline based representation
  81. */
  82. typedef struct _phpdbg_breakline_t {
  83. phpdbg_breakbase(name);
  84. zend_ulong opline;
  85. phpdbg_breakopline_t *base;
  86. } phpdbg_breakline_t;
  87. /**
  88. * Breakpoint opcode based representation
  89. */
  90. typedef struct _phpdbg_breakop_t {
  91. phpdbg_breakbase(name);
  92. zend_ulong hash;
  93. } phpdbg_breakop_t;
  94. /**
  95. * Breakpoint condition based representation
  96. */
  97. typedef struct _phpdbg_breakcond_t {
  98. phpdbg_breakbase(code);
  99. size_t code_len;
  100. bool paramed;
  101. phpdbg_param_t param;
  102. zend_ulong hash;
  103. zend_op_array *ops;
  104. } phpdbg_breakcond_t;
  105. /* {{{ Resolving breaks API */
  106. PHPDBG_API void phpdbg_resolve_op_array_breaks(zend_op_array *op_array);
  107. PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array);
  108. PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break);
  109. PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint32_t filelen, zend_string *cur, HashTable *fileht);
  110. PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file); /* }}} */
  111. /* {{{ Breakpoint Creation API */
  112. PHPDBG_API void phpdbg_set_breakpoint_file(const char* filename, size_t path_len, zend_ulong lineno);
  113. PHPDBG_API void phpdbg_set_breakpoint_symbol(const char* func_name, size_t func_name_len);
  114. PHPDBG_API void phpdbg_set_breakpoint_method(const char* class_name, const char* func_name);
  115. PHPDBG_API void phpdbg_set_breakpoint_opcode(const char* opname, size_t opname_len);
  116. PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline);
  117. PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline);
  118. PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const char *method, zend_ulong opline);
  119. PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend_ulong opline);
  120. PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong opline);
  121. PHPDBG_API void phpdbg_set_breakpoint_expression(const char* expression, size_t expression_len);
  122. PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param); /* }}} */
  123. /* {{{ Breakpoint Detection API */
  124. PHPDBG_API phpdbg_breakbase_t* phpdbg_find_breakpoint(zend_execute_data*); /* }}} */
  125. /* {{{ Misc Breakpoint API */
  126. PHPDBG_API void phpdbg_hit_breakpoint(phpdbg_breakbase_t* brake, bool output);
  127. PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type);
  128. PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t* brake);
  129. PHPDBG_API void phpdbg_reset_breakpoints(void);
  130. PHPDBG_API void phpdbg_clear_breakpoints(void);
  131. PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num);
  132. PHPDBG_API void phpdbg_enable_breakpoints(void);
  133. PHPDBG_API void phpdbg_enable_breakpoint(zend_ulong id);
  134. PHPDBG_API void phpdbg_disable_breakpoint(zend_ulong id);
  135. PHPDBG_API void phpdbg_disable_breakpoints(void); /* }}} */
  136. /* {{{ Breakbase API */
  137. PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id);
  138. PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable **table, zend_ulong *numkey, zend_string **strkey); /* }}} */
  139. /* {{{ Breakpoint Exportation API */
  140. PHPDBG_API void phpdbg_export_breakpoints(FILE *handle);
  141. PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str); /* }}} */
  142. #endif /* PHPDBG_BP_H */