From: Felipe Pena Date: Sun, 24 Nov 2013 11:43:05 +0000 (-0200) Subject: - Added print information about opcode breakpoint X-Git-Tag: php-5.6.0alpha1~110^2~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90ff693d6260c587041dc814310c9cb8639be643;p=php - Added print information about opcode breakpoint --- diff --git a/phpdbg.c b/phpdbg.c index a81edf556d..2811362272 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -80,6 +80,12 @@ static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */ efree((char*)((phpdbg_breaksymbol_t*)brake)->symbol); } /* }}} */ +static void php_phpdbg_destroy_bp_opcode(void *brake) /* {{{ */ +{ + efree((char*)((phpdbg_breakop_t*)brake)->name); +} /* }}} */ + + static void php_phpdbg_destroy_bp_methods(void *brake) /* {{{ */ { zend_hash_destroy((HashTable*)brake); @@ -116,7 +122,7 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, NULL, 0); - zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], 8, NULL, NULL, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], 8, NULL, php_phpdbg_destroy_bp_opcode, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0); zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0); diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 0985034c7a..1a0452deac 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -163,15 +163,16 @@ PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{ } } /* }}} */ -PHPDBG_API void phpdbg_set_breakpoint_opcode(zend_ulong hash TSRMLS_DC) /* {{{ */ +PHPDBG_API void phpdbg_set_breakpoint_opcode(const char *name, size_t name_len TSRMLS_DC) /* {{{ */ { phpdbg_breakop_t new_break; + zend_ulong hash = zend_hash_func(name, name_len); if (zend_hash_index_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], hash)) { return; } - new_break.hash = hash; + new_break.name = estrndup(name, name_len); new_break.id = PHPDBG_G(bp_count)++; zend_hash_index_update(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], hash, @@ -179,7 +180,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opcode(zend_ulong hash TSRMLS_DC) /* {{{ * PHPDBG_G(flags) |= PHPDBG_HAS_OPCODE_BP; - phpdbg_notice("Breakpoint #%d added", new_break.id); + phpdbg_notice("Breakpoint #%d added at %s", new_break.id, name); } /* }}} */ PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ */ @@ -582,6 +583,19 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ phpdbg_writeln("#%d\t\t%s", brake->id, Z_STRVAL(brake->code)); } } break; + + case PHPDBG_BREAK_OPCODE: if (PHPDBG_G(flags) & PHPDBG_HAS_OPCODE_BP) { + HashPosition position; + phpdbg_breakop_t *brake; + + phpdbg_writeln(SEPARATE); + phpdbg_writeln("Opcode Breakpoints:"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], &position); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], (void**) &brake, &position) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], &position)) { + phpdbg_writeln("#%d\t\t%s", brake->id, brake->name); + } + } break; } } /* }}} */ diff --git a/phpdbg_bp.h b/phpdbg_bp.h index 92d2a634db..953d5a6d90 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -64,7 +64,7 @@ typedef struct _phpdbg_breakline_t { * Breakpoint opcode based representation */ typedef struct _phpdbg_breakop_t { - zend_ulong hash; + const char *name; int id; } phpdbg_breakop_t; @@ -80,7 +80,7 @@ typedef struct _phpdbg_breakcond_t { PHPDBG_API void phpdbg_set_breakpoint_file(const char*, long TSRMLS_DC); PHPDBG_API void phpdbg_set_breakpoint_symbol(const char* TSRMLS_DC); PHPDBG_API void phpdbg_set_breakpoint_method(const char*, const char* TSRMLS_DC); -PHPDBG_API void phpdbg_set_breakpoint_opcode(zend_ulong TSRMLS_DC); +PHPDBG_API void phpdbg_set_breakpoint_opcode(const char*, size_t TSRMLS_DC); PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong TSRMLS_DC); PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t TSRMLS_DC); PHPDBG_API void phpdbg_set_breakpoint_expression(const char*, size_t TSRMLS_DC); diff --git a/phpdbg_break.c b/phpdbg_break.c index 62404b3d31..9bc9b95436 100644 --- a/phpdbg_break.c +++ b/phpdbg_break.c @@ -113,7 +113,7 @@ PHPDBG_BREAK(op) /* {{{ */ { switch (param->type) { case STR_PARAM: - phpdbg_set_breakpoint_opcode(zend_hash_func(param->str, param->len) TSRMLS_CC); + phpdbg_set_breakpoint_opcode(param->str, param->len TSRMLS_CC); break; phpdbg_default_switch_case(); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 8889450ab2..1eaaef7856 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -729,7 +729,7 @@ PHPDBG_COMMAND(print) /* {{{ */ if (EG(in_execution)) { phpdbg_writeln("VM Return\t%d", PHPDBG_G(vmret)); } - + phpdbg_writeln("Classes\t\t%d", zend_hash_num_elements(EG(class_table))); phpdbg_writeln("Functions\t%d", zend_hash_num_elements(EG(function_table))); phpdbg_writeln("Constants\t%d", zend_hash_num_elements(EG(zend_constants))); @@ -738,12 +738,13 @@ PHPDBG_COMMAND(print) /* {{{ */ "Memory\t\t%.3f/%.3f (kB)", (float) (zend_memory_usage(1 TSRMLS_CC)/1024), (float) (zend_memory_usage(0 TSRMLS_CC)/1024)); - + phpdbg_print_breakpoints(PHPDBG_BREAK_FILE TSRMLS_CC); phpdbg_print_breakpoints(PHPDBG_BREAK_SYM TSRMLS_CC); phpdbg_print_breakpoints(PHPDBG_BREAK_METHOD TSRMLS_CC); phpdbg_print_breakpoints(PHPDBG_BREAK_OPLINE TSRMLS_CC); phpdbg_print_breakpoints(PHPDBG_BREAK_COND TSRMLS_CC); + phpdbg_print_breakpoints(PHPDBG_BREAK_OPCODE TSRMLS_CC); phpdbg_writeln(SEPARATE); } break;