From: krakjoe Date: Mon, 11 Nov 2013 13:04:21 +0000 (+0000) Subject: fix break on opline X-Git-Tag: php-5.6.0alpha1~110^2~489 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=764d7d492cfdb406df21108ce5e2280a9b077c10;p=php fix break on opline --- diff --git a/phpdbg.c b/phpdbg.c index 3aa8c03524..214a6fb0fb 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 b8b2d35113..799ea11357 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 3ab00048d9..164ff48fac 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 e6b17912e8..5f8c56a0c5 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); } }