]> granicus.if.org Git - php/commitdiff
...
authorkrakjoe <joe.watkins@live.co.uk>
Tue, 12 Nov 2013 16:04:41 +0000 (16:04 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Tue, 12 Nov 2013 16:04:41 +0000 (16:04 +0000)
phpdbg.h
phpdbg_bp.c
phpdbg_bp.h
phpdbg_prompt.c

index 83b93fe912aed73f59b0807dc6e5d446aa869c41..f76e8377aceca4b4080ee97acf38d44e25d82dca 100644 (file)
--- a/phpdbg.h
+++ b/phpdbg.h
@@ -109,6 +109,9 @@ ZEND_END_MODULE_GLOBALS(phpdbg)
 #define PHPDBG_END_LINE(TSRMLS_D)         \
      ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]")  
 #define PHPDBG_PROMPT_LINE(TSRMLS_D)      \
-    ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64mphpdbg>\033[0m " : "phpdbg> ") /* }}} */
+    ((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64mphpdbg>\033[0m " : "phpdbg> ")
+#define PHPDBG_SEP_LINE(TSRMLS_D) do {\
+    printf("%s--------------------------------------%s\n", PHPDBG_BOLD_LINE(TSRMLS_C), PHPDBG_END_LINE(TSRMLS_C));\
+    } while(0)  /* }}} */
 
 #endif /* PHPDBG_H */
index 43f5fa7882e6eefdd156f5705eda7272f17423f9..4e23add761c8a6d91af8e15660d2f9f58b9ab717 100644 (file)
@@ -309,3 +309,85 @@ void phpdbg_clear_breakpoints(TSRMLS_D) /* {{{ */
     PHPDBG_G(bp_count) = 0;
 } /* }}} */
 
+void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC) /* {{{ */
+{
+    switch (type) {
+        case PHPDBG_BREAK_SYM: if ((PHPDBG_G(flags) & PHPDBG_HAS_SYM_BP)) {
+            HashPosition position;
+            phpdbg_breaksymbol_t *brake;
+
+            PHPDBG_SEP_LINE(TSRMLS_C);
+            printf("Function Breakpoints:\n");
+            for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position);
+                 zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], (void**) &brake, &position) == SUCCESS;
+                 zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position)) {
+                 printf(
+                    "#%d\t\t%s\n", brake->id, brake->symbol);
+            }
+        } break;
+        
+        case PHPDBG_BREAK_METHOD: if ((PHPDBG_G(flags) & PHPDBG_HAS_METHOD_BP)) {
+            HashPosition position[2];
+            HashTable *class_table;
+            char *class_name = NULL;
+            zend_uint class_len = 0;
+            zend_ulong class_idx = 0L;
+            
+            PHPDBG_SEP_LINE(TSRMLS_C);
+            printf("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])) {
+                 
+                 if (zend_hash_get_current_key_ex(
+                    &PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 
+                    &class_name, &class_len, &class_idx, 0, &position[0]) == HASH_KEY_IS_STRING) {
+                    
+                     phpdbg_breakmethod_t *brake;
+                    
+                     for (zend_hash_internal_pointer_reset_ex(class_table, &position[1]);
+                          zend_hash_get_current_data_ex(class_table, (void**)&brake, &position[1]) == SUCCESS;
+                          zend_hash_move_forward_ex(class_table, &position[1])) {
+                          printf(
+                            "#%d\t\t%s::%s\n", brake->id, brake->class_name, brake->func_name);
+                     }
+                 }
+                 
+            }
+        } break;
+        
+        case PHPDBG_BREAK_FILE: if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP)) {
+            HashPosition position;
+            zend_llist *points;
+
+            PHPDBG_SEP_LINE(TSRMLS_C);
+            printf("File Breakpoints:\n");
+            for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position);
+                 zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], (void**) &points, &position) == SUCCESS;
+                 zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position)) {
+                 zend_llist_position lposition;
+                 phpdbg_breakfile_t *brake;
+
+                 if ((brake = zend_llist_get_first_ex(points, &lposition))) {
+                    do {
+                        printf("#%d\t\t%s:%lu\n", brake->id, brake->filename, brake->line);
+                    } while ((brake = zend_llist_get_next_ex(points, &lposition)));
+                 }
+            }
+        } break;
+        
+        case PHPDBG_BREAK_OPLINE: if ((PHPDBG_G(flags) & PHPDBG_HAS_OPLINE_BP)) {
+            HashPosition position;
+            phpdbg_breakline_t *brake;
+
+            PHPDBG_SEP_LINE(TSRMLS_C);
+            printf("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)) {
+                 printf("#%d\t\t%p\n", brake->id, brake->opline);
+            }
+        } break;
+    }
+} /* }}} */
+
index 61d5004bf99a43fdf622149907ce14a2289b7c0a..d6167597f49bf8df8a93ad6b0a2023cb2861cf0f 100644 (file)
@@ -72,5 +72,6 @@ int phpdbg_find_breakpoint_method(zend_op_array* TSRMLS_DC);
 int phpdbg_find_breakpoint_opline(phpdbg_opline_ptr_t TSRMLS_DC);
 
 void phpdbg_clear_breakpoints(TSRMLS_D);
+void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC);
 
 #endif /* PHPDBG_BP_H */
index 7ec8401420f46577df9f5ac320c7eacf99dea75f..9fd03b986c417235551812610595571767989184 100644 (file)
@@ -236,7 +236,7 @@ static PHPDBG_COMMAND(print) /* {{{ */
                return SUCCESS;
        }
 
-    printf("--------------------------------------\n");
+    PHPDBG_SEP_LINE(TSRMLS_C);
        printf("Execution Context Information:\n");
 #ifdef HAVE_LIBREADLINE
     printf("Readline\tyes\n");
@@ -266,84 +266,13 @@ static PHPDBG_COMMAND(print) /* {{{ */
     printf("Constants\t%d\n", zend_hash_num_elements(EG(zend_constants)));
     printf("Included\t%d\n", zend_hash_num_elements(&EG(included_files)));
 
-    if ((PHPDBG_G(flags) & PHPDBG_HAS_FILE_BP)) {
-        HashPosition position;
-        zend_llist *points;
-
-        printf("--------------------------------------\n");
-        printf("File Breakpoints:\n");
-        for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position);
-             zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], (void**) &points, &position) == SUCCESS;
-             zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], &position)) {
-             zend_llist_position lposition;
-             phpdbg_breakfile_t *brake;
-
-             if ((brake = zend_llist_get_first_ex(points, &lposition))) {
-                do {
-                    printf("#%d\t\t%s:%lu\n", brake->id, brake->filename, brake->line);
-                } while ((brake = zend_llist_get_next_ex(points, &lposition)));
-             }
-        }
-    }
+    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);
 
-    if ((PHPDBG_G(flags) & PHPDBG_HAS_SYM_BP)) {
-        HashPosition position;
-        phpdbg_breaksymbol_t *brake;
-
-        printf("--------------------------------------\n");
-        printf("Function Breakpoints:\n");
-        for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position);
-             zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], (void**) &brake, &position) == SUCCESS;
-             zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], &position)) {
-             printf(
-                "#%d\t\t%s\n", brake->id, brake->symbol);
-        }
-    }
+    PHPDBG_SEP_LINE(TSRMLS_C);
     
-    if ((PHPDBG_G(flags) & PHPDBG_HAS_METHOD_BP)) {
-        HashPosition position[2];
-        HashTable *class_table;
-        char *class_name = NULL;
-        zend_uint class_len = 0;
-        zend_ulong class_idx = 0L;
-        
-        printf("--------------------------------------\n");
-        printf("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])) {
-             
-             if (zend_hash_get_current_key_ex(
-                &PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 
-                &class_name, &class_len, &class_idx, 0, &position[0]) == HASH_KEY_IS_STRING) {
-                
-                 phpdbg_breakmethod_t *brake;
-                
-                 for (zend_hash_internal_pointer_reset_ex(class_table, &position[1]);
-                      zend_hash_get_current_data_ex(class_table, (void**)&brake, &position[1]) == SUCCESS;
-                      zend_hash_move_forward_ex(class_table, &position[1])) {
-                      printf(
-                        "#%d\t\t%s::%s\n", brake->id, brake->class_name, brake->func_name);
-                 }
-             }
-             
-        }
-    }
-
-    if ((PHPDBG_G(flags) & PHPDBG_HAS_OPLINE_BP)) {
-        HashPosition position;
-        phpdbg_breakline_t *brake;
-
-        printf("--------------------------------------\n");
-        printf("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)) {
-             printf("#%d\t\t%p\n", brake->id, brake->opline);
-        }
-    }
-
-    printf("--------------------------------------\n");
        return SUCCESS;
 } /* }}} */