]> granicus.if.org Git - php/commitdiff
- Added breakpoint counter
authorFelipe Pena <felipensp@gmail.com>
Sun, 10 Nov 2013 19:15:32 +0000 (17:15 -0200)
committerFelipe Pena <felipensp@gmail.com>
Sun, 10 Nov 2013 19:15:32 +0000 (17:15 -0200)
phpdbg.c
phpdbg.h
phpdbg_bp.c
phpdbg_bp.h

index 48b5728d77a8ee1135bb468857ff36021762f56f..feed5ecd398ce146c88ef55e38b7ea334301e02a 100644 (file)
--- 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) /* {{{ */
index 437fe8a24413682e4053b59adfe9b35a77a4e43b..c2f949bc8998c09930ba5bdfc50d3cf8a5652c97 100644 (file)
--- 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 */
index a45ab164f7ecbf2fcdab19472b1d26fee441e634..a531f4f1af3408eef38737f7725e9090ea24404a 100644 (file)
@@ -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;
                }
        }
 
index 78909d2ae368df47121adfb79e47b9781e7585f5..c6d057c2806627bb679e504b07dca01d4f691787 100644 (file)
@@ -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);