From: Bob Weinand Date: Mon, 22 Sep 2014 21:28:07 +0000 (+0200) Subject: Fix breakpoints and listing X-Git-Tag: php-5.6.3RC1~51^2~52^2~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f9e0360776f21f2e9c854aaebe9d4b559e15a4a;p=php Fix breakpoints and listing --- diff --git a/phpdbg_bp.c b/phpdbg_bp.c index dbe1da63dd..eddcbcb358 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -1357,8 +1357,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ uint32_t class_len = 0; zend_ulong class_idx = 0L; - phpdbg_out(SEPARATE); - phpdbg_out("Method Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Method Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], (void**) &class_table, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], &position[0])) { @@ -1383,8 +1383,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ HashPosition position[2]; HashTable *points; - phpdbg_out(SEPARATE); - phpdbg_out("File Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("File Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], (void**) &points, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position[0])) { @@ -1405,8 +1405,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ HashPosition position; phpdbg_breakline_t *brake; - phpdbg_out(SEPARATE); - phpdbg_out("Opline Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Opline Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (void**) &brake, &position) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], &position)) { @@ -1436,8 +1436,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ uint32_t class_len = 0, method_len = 0; zend_ulong class_idx = 0L, method_idx = 0L; - phpdbg_out(SEPARATE); - phpdbg_out("Method opline Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Method opline Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], (void**) &class_table, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], &position[0])) { @@ -1475,8 +1475,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ uint32_t function_len = 0; zend_ulong function_idx = 0L; - phpdbg_out(SEPARATE); - phpdbg_out("Function opline Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Function opline Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], (void**) &function_table, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], &position[0])) { @@ -1505,8 +1505,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ uint32_t file_len = 0; zend_ulong file_idx = 0L; - phpdbg_out(SEPARATE); - phpdbg_out("File opline Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("File opline Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], &position[0]); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], (void**) &file_table, &position[0]) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], &position[0])) { @@ -1531,8 +1531,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ HashPosition position; phpdbg_breakcond_t *brake; - phpdbg_out(SEPARATE); - phpdbg_out("Conditional Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Conditional Breakpoints:\n"); for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position); zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], (void**) &brake, &position) == SUCCESS; zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], &position)) { @@ -1607,8 +1607,8 @@ PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */ HashPosition position; phpdbg_breakop_t *brake; - phpdbg_out(SEPARATE); - phpdbg_out("Opcode Breakpoints:"); + phpdbg_out(SEPARATE "\n"); + phpdbg_out("Opcode Breakpoints:\n"); 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)) { diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 5c6ac072ea..2e91304d7e 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -750,12 +750,18 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack TSRMLS_DC) { switch (top->type) { case EVAL_PARAM: + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); return PHPDBG_COMMAND_HANDLER(ev)(top TSRMLS_CC); case RUN_PARAM: + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); return PHPDBG_COMMAND_HANDLER(run)(top TSRMLS_CC); case SHELL_PARAM: + phpdbg_activate_err_buf(0 TSRMLS_CC); + phpdbg_free_err_buf(TSRMLS_C); return PHPDBG_COMMAND_HANDLER(sh)(top TSRMLS_CC); case STR_PARAM: { @@ -765,7 +771,6 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack TSRMLS_DC) { if (phpdbg_stack_verify(handler, &top TSRMLS_CC) == SUCCESS) { phpdbg_activate_err_buf(0 TSRMLS_CC); phpdbg_free_err_buf(TSRMLS_C); - return handler->handler(top TSRMLS_CC); } } diff --git a/phpdbg_list.c b/phpdbg_list.c index 64e0d8465b..748461908c 100644 --- a/phpdbg_list.c +++ b/phpdbg_list.c @@ -159,12 +159,12 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig if (offset <= line) { if (!highlight) { - phpdbg_write("line", "num=\"%d\" code=\"%s\"", "%05ld: %s", line, buffer); + phpdbg_write("line", "num=\"%d\" code=\"%s\"", " %05ld: %s", line, buffer); } else { if (highlight != line) { - phpdbg_write("line", "num=\"%d\" code=\"%s\"", "%05ld: %s", " %05ld: %s", line, buffer); + phpdbg_write("line", "num=\"%ld\" code=\"%s\"", " %05ld: %s", line, buffer); } else { - phpdbg_write("line", "num=\"%d\" code=\"%s\" current=\"current\"", "%05ld: %s", ">%05ld: %s", line, buffer); + phpdbg_write("line", "num=\"%ld\" code=\"%s\" current=\"current\"", ">%05ld: %s", line, buffer); } } diff --git a/phpdbg_utils.c b/phpdbg_utils.c index b68a0b6d2d..6ff905c736 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -1090,7 +1090,8 @@ static int phpdbg_process_print(FILE *fp, int type, const char *tag, const char case P_WRITE: severity = "normal"; if (msg) { - msgoutlen = asprintf(&msgout, "%.*s\n", msglen, msg); + msgout = strndup(msg, msglen); + msgoutlen = msglen; } else { msgoutlen = 0; msgout = strdup("");