com php-src: phpdbg_break userland: phpdbg.c phpdbg _bp.c phpdbg_bp.h phpdbg_prompt.c test.php
| From: | Bob Weinand | Date: | Mon, 11 Nov 2013 14:33:53 +0000 |
| Subject: | com php-src: phpdbg_break userland: phpdbg.c phpdbg _bp.c phpdbg_bp.h phpdbg_prompt.c test.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75134@lists.php.net to get a copy of this message | ||
Commit: 34ae94ad9a080b0a4862344a51fa0da8dfd4d80f
Author: krakjoe <joe.watkins@live.co.uk> Mon, 11 Nov 2013 14:33:53 +0000
Parents: dc3ef209641194e5ccea7ad493c1587b5f74ec4f
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=34ae94ad9a080b0a4862344a51fa0da8dfd4d80f
Log:
phpdbg_break userland
Changed paths:
M phpdbg.c
M phpdbg_bp.c
M phpdbg_bp.h
M phpdbg_prompt.c
M test.php
Diff:
diff --git a/phpdbg.c b/phpdbg.c
index 214a6fb..6ed4e65 100644
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -94,10 +94,27 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
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),
diff --git a/phpdbg_bp.c b/phpdbg_bp.c
index 8185196..e17608c 100644
--- a/phpdbg_bp.c
+++ b/phpdbg_bp.c
@@ -104,6 +104,24 @@ void phpdbg_set_breakpoint_opline(const char *name TSRMLS_DC) /* {{{ */
}
} /* }}} */
+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);
@@ -166,3 +184,4 @@ int phpdbg_find_breakpoint_opline(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ *
return FAILURE;
} /* }}} */
+
diff --git a/phpdbg_bp.h b/phpdbg_bp.h
index f6a8b6b..1f04af9 100644
--- a/phpdbg_bp.h
+++ b/phpdbg_bp.h
@@ -52,6 +52,7 @@ typedef struct _phpdbg_breakline_t {
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);
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index 8db72ed..f0f299e 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -376,6 +376,10 @@ static PHPDBG_COMMAND(clear) /* {{{ */
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;
} /* }}} */
diff --git a/test.php b/test.php
index bed99d3..3ac566c 100644
--- a/test.php
+++ b/test.php
@@ -10,6 +10,8 @@ if (!isset($greeting)) {
echo test();
}
+phpdbg_break();
+
test2();
return true;
?>