]> granicus.if.org Git - php/commitdiff
- Added print information about opcode breakpoint
authorFelipe Pena <felipensp@gmail.com>
Sun, 24 Nov 2013 11:43:05 +0000 (09:43 -0200)
committerFelipe Pena <felipensp@gmail.com>
Sun, 24 Nov 2013 11:43:05 +0000 (09:43 -0200)
phpdbg.c
phpdbg_bp.c
phpdbg_bp.h
phpdbg_break.c
phpdbg_prompt.c

index a81edf556d13fc503431d998617a7e376b7ee639..2811362272bc2bf6f02d0a5a43f8ee34fec0eaf3 100644 (file)
--- 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);
index 0985034c7aac961ffbcca124f96ac9439dd0ff1b..1a0452deac281ff8e65217769abe377cd599aeb7 100644 (file)
@@ -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;
     }
 } /* }}} */
 
index 92d2a634dbf45c41b859927f3d639f33413a6763..953d5a6d906d2b774d6316d0db9151df19e8a37a 100644 (file)
@@ -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);
index 62404b3d31d21779082846ed86b56d6f5687d0b4..9bc9b95436b0523180c64c433078354381f5cf95 100644 (file)
@@ -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();
index 8889450ab288cc510b218d17ac4ac85b324903a4..1eaaef7856f9f2c6233a3751cc7f4fb1dc4beeee 100644 (file)
@@ -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;