]> granicus.if.org Git - php/commitdiff
fix break on opline
authorkrakjoe <joe.watkins@live.co.uk>
Mon, 11 Nov 2013 13:04:21 +0000 (13:04 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Mon, 11 Nov 2013 13:04:21 +0000 (13:04 +0000)
phpdbg.c
phpdbg_bp.c
phpdbg_bp.h
phpdbg_prompt.c

index 3aa8c035241355a4d68b320e005a6894c305d475..214a6fb0fba4efbf134ccac5c11ce35c32b4f039 100644 (file)
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -63,11 +63,16 @@ static void php_phpdbg_destroy_bp_symbol(void *brake) /* {{{ */
        efree((char*)((phpdbg_breaksymbol_t*)brake)->symbol);
 } /* }}} */
 
+static void php_phpdbg_destroy_bp_opline(void *brake) /* {{{ */
+{
+       efree((char*)((phpdbg_breakline_t*)brake)->name);
+} /* }}} */
+
 static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
 {
        zend_hash_init(&PHPDBG_G(bp_files),   8, NULL, php_phpdbg_destroy_bp_file, 0);
        zend_hash_init(&PHPDBG_G(bp_symbols), 8, NULL, php_phpdbg_destroy_bp_symbol, 0);
-    zend_hash_init(&PHPDBG_G(bp_oplines), 8, NULL, NULL, 0);
+    zend_hash_init(&PHPDBG_G(bp_oplines), 8, NULL, php_phpdbg_destroy_bp_opline, 0);
     
        return SUCCESS;
 } /* }}} */
index b8b2d35113e44a42bda86a7416ca7f25420e1d8d..799ea11357cbbd00d03cbf54113f220aafcfbda9 100644 (file)
@@ -85,22 +85,20 @@ void phpdbg_set_breakpoint_symbol(const char *name TSRMLS_DC) /* {{{ */
 
 void phpdbg_set_breakpoint_opline(const char *name TSRMLS_DC) /* {{{ */
 {
-       size_t name_len = strlen(name);
-
-       if (!zend_hash_exists(&PHPDBG_G(bp_oplines), name, name_len)) {
+       zend_ulong opline = strtoul(name, 0, 16);
+    
+       if (!zend_hash_index_exists(&PHPDBG_G(bp_oplines), opline)) {
                phpdbg_breakline_t new_break;
 
                PHPDBG_G(has_opline_bp) = 1;
-
-               sscanf(
-                   name, "%x", &new_break.opline);
-               
+        
+        new_break.name = estrdup(name);
+               new_break.opline = opline;
                new_break.id = PHPDBG_G(bp_count)++;
         
-               zend_hash_update(&PHPDBG_G(bp_oplines), name,
-                       name_len, &new_break, sizeof(phpdbg_breakline_t), NULL);
+               zend_hash_index_update(&PHPDBG_G(bp_oplines), opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
            
-           printf("Breakpoint #%d added at 0x%x\n", new_break.id, new_break.opline);
+           printf("Breakpoint #%d added at %s\n", new_break.id, new_break.name);
        } else {
            printf("Breakpoint exists at %s\n", name);
        }
@@ -154,24 +152,19 @@ int phpdbg_find_breakpoint_symbol(zend_function *fbc TSRMLS_DC) /* {{{ */
        return FAILURE;
 } /* }}} */
 
-int phpdbg_find_breakpoint_opline(void *opline TSRMLS_DC) /* {{{ */
+typedef struct _zend_op *zend_op_ptr;
+
+int phpdbg_find_breakpoint_opline(zend_op_ptr opline TSRMLS_DC) /* {{{ */
 {
-       char *opstring = NULL;
-       size_t opstring_len;
        phpdbg_breakline_t *bp;
 
-    opstring_len = asprintf(
-        &opstring, "0x%x", (unsigned int) opline);
-
-       if (zend_hash_find(&PHPDBG_G(bp_oplines), opstring, opstring_len,
-               (void**)&bp) == SUCCESS) {
-               printf("Breakpoint #%d in 0x%x at %s\n", bp->id, bp->opline,
+       if (zend_hash_index_find(&PHPDBG_G(bp_oplines), (zend_ulong) opline,
+               (void**)&bp) == SUCCESS) {
+               printf("Breakpoint #%d in %s at %s\n", bp->id, bp->name,
                        zend_get_executed_filename(TSRMLS_C));
-           free(opstring);
            
                return SUCCESS;
        }
        
-    free(opstring);
        return FAILURE;
 } /* }}} */
index 3ab00048d954ad222e8dd5ad8daeabfb09c48fcb..164ff48facbd873f8640f8615b639fbf653805cd 100644 (file)
@@ -41,7 +41,8 @@ typedef struct _phpdbg_breaksymbol_t {
  * Breakpoint opline based representation
  */
 typedef struct _phpdbg_breakline_t {
-    zend_uint opline;
+    const char *name;
+    zend_ulong opline;
     int id;
 } phpdbg_breakline_t;
 
@@ -51,6 +52,6 @@ void phpdbg_set_breakpoint_opline(const char* TSRMLS_DC);
 
 int phpdbg_find_breakpoint_file(zend_op_array* TSRMLS_DC);
 int phpdbg_find_breakpoint_symbol(zend_function* TSRMLS_DC);
-int phpdbg_find_breakpoint_opline(void * TSRMLS_DC);
+int phpdbg_find_breakpoint_opline(zend_op* TSRMLS_DC);
 
 #endif /* PHPDBG_BP_H */
index e6b17912e804582b8186b70898ae0ac0d60135d1..5f8c56a0c5dd626e2de519d641071d7597831f81 100644 (file)
@@ -269,7 +269,7 @@ static PHPDBG_COMMAND(print) /* {{{ */
         for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp_oplines), &position);
              zend_hash_get_current_data_ex(&PHPDBG_G(bp_oplines), (void**) &brake, &position) == SUCCESS;
              zend_hash_move_forward_ex(&PHPDBG_G(bp_oplines), &position)) {
-             printf("#%d\t0x%x\n", brake->id, brake->opline);
+             printf("#%d\t%s\n", brake->id, brake->name);
         }
     }