phpdbg_bp.h 6.1 KB

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