From 3955dcf67313053ced77706e48d96c3f01eda631 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Mon, 11 Nov 2013 09:14:30 +0000 Subject: [PATCH] more output on setting break points output breaks with print command --- phpdbg_bp.c | 11 ++++++-- phpdbg_prompt.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 4ae8863534..236c0b4e0e 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -38,9 +38,9 @@ void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{ zend_llist *break_files_ptr; size_t path_len = strlen(path); - new_break.filename = estrndup(path, path_len + 1); + new_break.filename = estrndup(path, path_len); new_break.line = line_num; - + PHPDBG_G(has_file_bp) = 1; if (zend_hash_find(&PHPDBG_G(bp_files), @@ -57,6 +57,9 @@ void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{ new_break.id = PHPDBG_G(bp_count)++; zend_llist_add_element(break_files_ptr, &new_break); + + printf( + "Breakpoint #%d added at %s:%d\n", new_break.id, new_break.filename, new_break.line); } /* }}} */ void phpdbg_set_breakpoint_symbol(const char *name TSRMLS_DC) /* {{{ */ @@ -73,6 +76,10 @@ void phpdbg_set_breakpoint_symbol(const char *name TSRMLS_DC) /* {{{ */ zend_hash_update(&PHPDBG_G(bp_symbols), new_break.symbol, name_len, &new_break, sizeof(phpdbg_breaksymbol_t), NULL); + + printf("Breakpoint #%d added at %s\n", new_break.id, new_break.symbol); + } else { + printf("Breakpoint exists at %s\n", name); } } /* }}} */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 8238ea32cf..cc109e8f8b 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -187,8 +187,9 @@ static PHPDBG_COMMAND(print) /* {{{ */ printf("%s\n", expr); return SUCCESS; } - - printf("Showing Execution Context Information:\n"); + + printf("--------------------------------------\n"); + printf("Execution Context Information:\n"); printf("Exec\t\t%s\n", PHPDBG_G(exec) ? PHPDBG_G(exec) : "none"); printf("Compiled\t%s\n", PHPDBG_G(ops) ? "yes" : "no"); printf("Stepping\t%s\n", PHPDBG_G(stepping) ? "on" : "off"); @@ -203,11 +204,59 @@ static PHPDBG_COMMAND(print) /* {{{ */ } } printf("Executing\t%s\n", EG(in_execution) ? "yes" : "no"); - if (EG(in_execution)) { printf("VM Return\t%d\n", PHPDBG_G(vmret)); } - + printf("Classes\t\t%d\n", zend_hash_num_elements(EG(class_table))); + printf("Functions\t%d\n", zend_hash_num_elements(EG(function_table))); + printf("Constants\t%d\n", zend_hash_num_elements(EG(zend_constants))); + printf("Included\t%d\n", zend_hash_num_elements(&EG(included_files))); + + if (PHPDBG_G(has_file_bp)) { + HashPosition position; + zend_llist *points; + + printf("--------------------------------------\n"); + printf("File Break Point Information:\n"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp_files), &position); + zend_hash_get_current_data_ex(&PHPDBG_G(bp_files), (void**) &points, &position) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp_files), &position)) { + zend_llist_position lposition; + phpdbg_breakfile_t *brake; + + if ((brake = zend_llist_get_first_ex(points, &lposition))) { + printf("%s:\n", brake->filename); + do { + printf("\t%lu\n", brake->line); + } while ((brake = zend_llist_get_next_ex(points, &lposition))); + } + } + } + +#if 0 + if (PHPDBG_G(has_sym_bp)) { + HashPosition position; + zend_llist *points; + + printf("--------------------------------------\n"); + printf("Symbol Break Point Information:\n"); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp_symbols), &position); + zend_hash_get_current_data_ex(&PHPDBG_G(bp_symbols), (void**) &points, &position) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp_symbols), &position)) { + zend_llist_position lposition; + phpdbg_breaksymbol_t *brake; + + if ((brake = zend_llist_get_first_ex(points, &lposition))) { + printf("%s:\n", brake->symbol); + do { + printf("\t%d\n", brake->id); + } while ((brake = zend_llist_get_next_ex(points, &lposition))); + } + } + } +#endif + + printf("--------------------------------------\n"); return SUCCESS; } /* }}} */ @@ -267,10 +316,23 @@ static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) static PHPDBG_COMMAND(clean) /* {{{ */ { + printf("Cleaning Environment:\n"); + printf("\tClasses: %d\n", zend_hash_num_elements(EG(class_table))); + printf("\tFunctions: %d\n", zend_hash_num_elements(EG(function_table))); + printf("\tConstants: %d\n", zend_hash_num_elements(EG(zend_constants))); + printf("\tIncluded: %d\n", zend_hash_num_elements(&EG(included_files))); + zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function_full TSRMLS_CC); zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class_full TSRMLS_CC); zend_hash_reverse_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant_full TSRMLS_CC); zend_hash_clean(&EG(included_files)); + + printf("Clean Environment:\n"); + printf("\tClasses: %d\n", zend_hash_num_elements(EG(class_table))); + printf("\tFunctions: %d\n", zend_hash_num_elements(EG(function_table))); + printf("\tConstants: %d\n", zend_hash_num_elements(EG(zend_constants))); + printf("\tIncluded: %d\n", zend_hash_num_elements(&EG(included_files))); + return SUCCESS; } /* }}} */ -- 2.40.0