]> granicus.if.org Git - php/commitdiff
phpdbg_break userland
authorkrakjoe <joe.watkins@live.co.uk>
Mon, 11 Nov 2013 14:33:53 +0000 (14:33 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Mon, 11 Nov 2013 14:33:53 +0000 (14:33 +0000)
phpdbg.c
phpdbg_bp.c
phpdbg_bp.h
phpdbg_prompt.c
test.php

index 214a6fb0fba4efbf134ccac5c11ce35c32b4f039..6ed4e654df5948886942d8dedf267d7655096c88 100644 (file)
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -94,10 +94,27 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
     return SUCCESS;
 } /* }}} */
 
+static PHP_FUNCTION(phpdbg_break) /* {{{ */ 
+{
+    if (EG(active_op_array)) {
+        phpdbg_set_breakpoint_opline_ex(
+            EG(active_op_array)->opcodes TSRMLS_CC);
+    }
+} /* }}} */
+
+zend_function_entry phpdbg_user_functions[] = {
+    PHP_FE(phpdbg_break, NULL)
+#ifdef  PHP_FE_END
+       PHP_FE_END
+#else
+       {NULL,NULL,NULL}
+#endif
+};
+
 static zend_module_entry sapi_phpdbg_module_entry = {
        STANDARD_MODULE_HEADER,
        "phpdbg",
-       NULL,
+       phpdbg_user_functions,
        PHP_MINIT(phpdbg),
        NULL,
        PHP_RINIT(phpdbg),
index 8185196bd12fa08cd0468f7d3c5009ed8041dcf3..e17608c60900251d8de33a2b60888842140c3a7d 100644 (file)
@@ -104,6 +104,24 @@ void phpdbg_set_breakpoint_opline(const char *name TSRMLS_DC) /* {{{ */
        }
 } /* }}} */
 
+void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ */
+{
+       if (!zend_hash_index_exists(&PHPDBG_G(bp_oplines), (zend_ulong) opline)) {
+               phpdbg_breakline_t new_break;
+
+               PHPDBG_G(has_opline_bp) = 1;
+        
+        asprintf((char**)&new_break.name, "%#x", opline);
+        
+               new_break.opline = opline;
+               new_break.id = PHPDBG_G(bp_count)++;
+        
+               zend_hash_index_update(&PHPDBG_G(bp_oplines), opline, &new_break, sizeof(phpdbg_breakline_t), NULL);
+           
+           printf("[Breakpoint #%d added at %#x]\n", new_break.id, new_break.opline);
+       }
+} /* }}} */
+
 int phpdbg_find_breakpoint_file(zend_op_array *op_array TSRMLS_DC) /* {{{ */
 {
        size_t name_len = strlen(op_array->filename);
@@ -166,3 +184,4 @@ int phpdbg_find_breakpoint_opline(phpdbg_opline_ptr_t opline TSRMLS_DC) /* {{{ *
        
        return FAILURE;
 } /* }}} */
+
index f6a8b6bcd7c978a08134fcf12d8cccb7b7372339..1f04af9f6c637e846a3efbaf04a51a4923237db4 100644 (file)
@@ -52,6 +52,7 @@ typedef struct _phpdbg_breakline_t {
 void phpdbg_set_breakpoint_file(const char*, long TSRMLS_DC);
 void phpdbg_set_breakpoint_symbol(const char* TSRMLS_DC);
 void phpdbg_set_breakpoint_opline(const char* TSRMLS_DC);
+void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t TSRMLS_DC);
 
 int phpdbg_find_breakpoint_file(zend_op_array* TSRMLS_DC);
 int phpdbg_find_breakpoint_symbol(zend_function* TSRMLS_DC);
index 8db72ed44a06f599896e20e67f2a37b1f0eb4457..f0f299ec51c9a6dee829f6668528de07ff12fa33 100644 (file)
@@ -376,6 +376,10 @@ static PHPDBG_COMMAND(clear) /* {{{ */
     zend_hash_clean(&PHPDBG_G(bp_symbols));
     zend_hash_clean(&PHPDBG_G(bp_oplines));
     
+    PHPDBG_G(has_file_bp) = 0;
+    PHPDBG_G(has_sym_bp) = 0;
+    PHPDBG_G(has_opline_bp) = 0;
+    
     return SUCCESS;
 } /* }}} */
 
index bed99d3e9b7e794c828803fc48409d8160dc8d36..3ac566ce761e7d0dbfbdfa73ec237dcca4207281 100644 (file)
--- a/test.php
+++ b/test.php
@@ -10,6 +10,8 @@ if (!isset($greeting)) {
     echo test();
 }
 
+phpdbg_break();
+
 test2();
 return true;
 ?>