return SUCCESS;
} /* }}} */
+static PHP_FUNCTION(phpdbg_break) /* {{{ */
+{
+ if (EG(active_op_array)) {
+ phpdbg_set_breakpoint_opline_ex(
+ EG(active_op_array)->opcodes TSRMLS_CC);
+ }
+} /* }}} */
+
+zend_function_entry phpdbg_user_functions[] = {
+ PHP_FE(phpdbg_break, NULL)
+#ifdef PHP_FE_END
+ PHP_FE_END
+#else
+ {NULL,NULL,NULL}
+#endif
+};
+
static zend_module_entry sapi_phpdbg_module_entry = {
STANDARD_MODULE_HEADER,
"phpdbg",
- NULL,
+ phpdbg_user_functions,
PHP_MINIT(phpdbg),
NULL,
PHP_RINIT(phpdbg),
}
} /* }}} */
+void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ */
+{
+ if (!zend_hash_index_exists(&PHPDBG_G(bp_oplines), (zend_ulong) opline)) {
+ phpdbg_breakline_t new_break;
+
+ PHPDBG_G(has_opline_bp) = 1;
+
+ asprintf((char**)&new_break.name, "%#x", opline);
+
+ new_break.opline = opline;
+ new_break.id = PHPDBG_G(bp_count)++;
+
+ zend_hash_index_update(&PHPDBG_G(bp_oplines), opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
+
+ printf("[Breakpoint #%d added at %#x]\n", new_break.id, new_break.opline);
+ }
+} /* }}} */
+
int phpdbg_find_breakpoint_file(zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
size_t name_len = strlen(op_array->filename);
return FAILURE;
} /* }}} */
+
void phpdbg_set_breakpoint_file(const char*, long TSRMLS_DC);
void phpdbg_set_breakpoint_symbol(const char* TSRMLS_DC);
void phpdbg_set_breakpoint_opline(const char* TSRMLS_DC);
+void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t TSRMLS_DC);
int phpdbg_find_breakpoint_file(zend_op_array* TSRMLS_DC);
int phpdbg_find_breakpoint_symbol(zend_function* TSRMLS_DC);
zend_hash_clean(&PHPDBG_G(bp_symbols));
zend_hash_clean(&PHPDBG_G(bp_oplines));
+ PHPDBG_G(has_file_bp) = 0;
+ PHPDBG_G(has_sym_bp) = 0;
+ PHPDBG_G(has_opline_bp) = 0;
+
return SUCCESS;
} /* }}} */
echo test();
}
+phpdbg_break();
+
test2();
return true;
?>