com php-src: fix break on opline: phpdbg.c phpdbg_bp.c ph pdbg_bp.h phpdbg_prompt.c
| From: | Bob Weinand | Date: | Mon, 11 Nov 2013 13:04:21 +0000 |
| Subject: | com php-src: fix break on opline: phpdbg.c phpdbg_bp.c ph pdbg_bp.h phpdbg_prompt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75141@lists.php.net to get a copy of this message | ||
Commit: 764d7d492cfdb406df21108ce5e2280a9b077c10
Author: krakjoe <joe.watkins@live.co.uk> Mon, 11 Nov 2013 13:04:21 +0000
Parents: 616cb9c35f2b0a54300e0484a180090570485f1f
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=764d7d492cfdb406df21108ce5e2280a9b077c10
Log:
fix break on opline
Changed paths:
M phpdbg.c
M phpdbg_bp.c
M phpdbg_bp.h
M phpdbg_prompt.c
Diff:
diff --git a/phpdbg.c b/phpdbg.c
index 3aa8c03..214a6fb 100644
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -63,11 +63,16 @@ static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */
efree((char*)((phpdbg_breaksymbol_t*)brake)->symbol);
} /* }}} */
+static void php_phpdbg_destroy_bp_opline(void *brake) /* {{{ */
+{
+ efree((char*)((phpdbg_breakline_t*)brake)->name);
+} /* }}} */
+
static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
{
zend_hash_init(&PHPDBG_G(bp_files), 8, NULL, php_phpdbg_destroy_bp_file, 0);
zend_hash_init(&PHPDBG_G(bp_symbols), 8, NULL, php_phpdbg_destroy_bp_symbol, 0);
- zend_hash_init(&PHPDBG_G(bp_oplines), 8, NULL, NULL, 0);
+ zend_hash_init(&PHPDBG_G(bp_oplines), 8, NULL, php_phpdbg_destroy_bp_opline, 0);
return SUCCESS;
} /* }}} */
diff --git a/phpdbg_bp.c b/phpdbg_bp.c
index b8b2d35..799ea11 100644
--- a/phpdbg_bp.c
+++ b/phpdbg_bp.c
@@ -85,22 +85,20 @@ void phpdbg_set_breakpoint_symbol(const char *name TSRMLS_DC) /* {{{ */
void phpdbg_set_breakpoint_opline(const char *name TSRMLS_DC) /* {{{ */
{
- size_t name_len = strlen(name);
-
- if (!zend_hash_exists(&PHPDBG_G(bp_oplines), name, name_len)) {
+ zend_ulong opline = strtoul(name, 0, 16);
+
+ if (!zend_hash_index_exists(&PHPDBG_G(bp_oplines), opline)) {
phpdbg_breakline_t new_break;
PHPDBG_G(has_opline_bp) = 1;
-
- sscanf(
- name, "%x", &new_break.opline);
-
+
+ new_break..name = estrdup(name);
+ new_break.opline = opline;
new_break.id = PHPDBG_G(bp_count)++;
- zend_hash_update(&PHPDBG_G(bp_oplines), name,
- name_len, &new_break, sizeof(phpdbg_breakline_t), NULL);
+ zend_hash_index_update(&PHPDBG_G(bp_oplines), opline, &new_break,
sizeof(phpdbg_breakline_t), NULL);
- printf("Breakpoint #%d added at 0x%x\n", new_break.id, new_break.opline);
+ printf("Breakpoint #%d added at %s\n", new_break.id, new_break.name);
} else {
printf("Breakpoint exists at %s\n", name);
}
@@ -154,24 +152,19 @@ int phpdbg_find_breakpoint_symbol(zend_function *fbc TSRMLS_DC) /* {{{ */
return FAILURE;
} /* }}} */
-int phpdbg_find_breakpoint_opline(void *opline TSRMLS_DC) /* {{{ */
+typedef struct _zend_op *zend_op_ptr;
+
+int phpdbg_find_breakpoint_opline(zend_op_ptr opline TSRMLS_DC) /* {{{ */
{
- char *opstring = NULL;
- size_t opstring_len;
phpdbg_breakline_t *bp;
- opstring_len = asprintf(
- &opstring, "0x%x", (unsigned int) opline);
-
- if (zend_hash_find(&PHPDBG_G(bp_oplines), opstring, opstring_len,
- (void**)&bp) == SUCCESS) {
- printf("Breakpoint #%d in 0x%x at %s\n", bp->id, bp->opline,
+ if (zend_hash_index_find(&PHPDBG_G(bp_oplines), (zend_ulong) opline,
+ (void**)&bp) == SUCCESS) {
+ printf("Breakpoint #%d in %s at %s\n", bp->id, bp->name,
zend_get_executed_filename(TSRMLS_C));
- free(opstring);
return SUCCESS;
}
- free(opstring);
return FAILURE;
} /* }}} */
diff --git a/phpdbg_bp.h b/phpdbg_bp.h
index 3ab0004..164ff48 100644
--- a/phpdbg_bp.h
+++ b/phpdbg_bp.h
@@ -41,7 +41,8 @@ typedef struct _phpdbg_breaksymbol_t {
* Breakpoint opline based representation
*/
typedef struct _phpdbg_breakline_t {
- zend_uint opline;
+ const char *name;
+ zend_ulong opline;
int id;
} phpdbg_breakline_t;
@@ -51,6 +52,6 @@ void phpdbg_set_breakpoint_opline(const char* TSRMLS_DC);
int phpdbg_find_breakpoint_file(zend_op_array* TSRMLS_DC);
int phpdbg_find_breakpoint_symbol(zend_function* TSRMLS_DC);
-int phpdbg_find_breakpoint_opline(void * TSRMLS_DC);
+int phpdbg_find_breakpoint_opline(zend_op* TSRMLS_DC);
#endif /* PHPDBG_BP_H */
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index e6b1791..5f8c56a 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -269,7 +269,7 @@ static PHPDBG_COMMAND(print) /* {{{ */
for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp_oplines), &position);
zend_hash_get_current_data_ex(&PHPDBG_G(bp_oplines), (void**) &brake,
&position) == SUCCESS;
zend_hash_move_forward_ex(&PHPDBG_G(bp_oplines), &position)) {
- printf("#%d\t0x%x\n", brake->id, brake->opline);
+ printf("#%d\t%s\n", brake->id, brake->name);
}
}