From 1fcc54a6b822c1f1acb7349f9d683403c100e08a Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 10 Nov 2013 17:15:32 -0200 Subject: [PATCH] - Added breakpoint counter --- phpdbg.c | 2 ++ phpdbg.h | 1 + phpdbg_bp.c | 21 +++++++++++++-------- phpdbg_bp.h | 2 ++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 48b5728d77..feed5ecd39 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -17,6 +17,7 @@ */ #include "phpdbg.h" +#include "phpdbg_prompt.h" ZEND_DECLARE_MODULE_GLOBALS(phpdbg); @@ -30,6 +31,7 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ pg->stepping = 0; pg->vmret = 0; pg->quitting = 0; + pg->bp_count = 0; } /* }}} */ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ diff --git a/phpdbg.h b/phpdbg.h index 437fe8a244..c2f949bc89 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -51,6 +51,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) size_t exec_len; /* size of exec */ zend_op_array *ops; /* op_array */ zval *retval; /* return value */ + size_t bp_count; /* breakpoint count */ int stepping; /* stepping */ int vmret; /* return from last opcode handler execution */ zend_bool has_file_bp; /* file-based breakpoint has been set */ diff --git a/phpdbg_bp.c b/phpdbg_bp.c index a45ab164f7..a531f4f1af 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -70,6 +70,8 @@ void phpdbg_set_breakpoint_file(const char *expr, const char *line_pos TSRMLS_DC new_break.filename, name_len, &break_files, sizeof(zend_llist), (void**)&break_files_ptr); } + + new_break.id = PHPDBG_G(bp_count)++; zend_llist_add_element(break_files_ptr, &new_break); } /* }}} */ @@ -96,6 +98,8 @@ void phpdbg_set_breakpoint_symbol(const char *expr, const char *opline_num_pos T new_break.symbol, name_len, &break_syms, sizeof(zend_llist), (void**)&break_sym_ptr); } + + new_break.id = PHPDBG_G(bp_count)++; zend_llist_add_element(break_sym_ptr, &new_break); } /* }}} */ @@ -103,18 +107,19 @@ int phpdbg_breakpoint_file(zend_op_array *op_array TSRMLS_DC) /* {{{ */ { size_t name_len = strlen(op_array->filename); zend_llist *break_list; + zend_llist_element *le; if (zend_hash_find(&PHPDBG_G(bp_files), op_array->filename, name_len, - (void**)&break_list) == SUCCESS) { - zend_llist_element *le; + (void**)&break_list) == FAILURE) { + return FAILURE; + } - for (le = break_list->head; le; le = le->next) { - phpdbg_breakfile_t *bp = (phpdbg_breakfile_t*) le->data; + for (le = break_list->head; le; le = le->next) { + const phpdbg_breakfile_t *bp = (phpdbg_breakfile_t*)le->data; - if (bp->line == (*EG(opline_ptr))->lineno) { - printf("breakpoint reached!\n"); - return SUCCESS; - } + if (bp->line == (*EG(opline_ptr))->lineno) { + printf("Breakpoint #%d at %s:%ld\n", bp->id, bp->filename, bp->line); + return SUCCESS; } } diff --git a/phpdbg_bp.h b/phpdbg_bp.h index 78909d2ae3..c6d057c280 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -26,6 +26,7 @@ typedef struct _phpdbg_breakfile_t { const char *filename; long line; + size_t id; } phpdbg_breakfile_t; /** @@ -34,6 +35,7 @@ typedef struct _phpdbg_breakfile_t { typedef struct _phpdbg_breaksymbol_t { const char *symbol; long opline_num; + size_t id; } phpdbg_breaksymbol_t; void phpdbg_set_breakpoint_file(const char*, const char* TSRMLS_DC); -- 2.40.0