]> granicus.if.org Git - php/commitdiff
- Passing input ptr to handlers
authorFelipe Pena <felipensp@gmail.com>
Wed, 20 Nov 2013 13:28:41 +0000 (11:28 -0200)
committerFelipe Pena <felipensp@gmail.com>
Wed, 20 Nov 2013 13:28:41 +0000 (11:28 -0200)
phpdbg.c
phpdbg_cmd.c
phpdbg_cmd.h
phpdbg_prompt.c

index c8a39957cda8ce73877c7acc82cdd1da1139cd2c..200c48d376addcf8f0f1673fa7fdded689340677 100644 (file)
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -102,15 +102,15 @@ static void php_phpdbg_destroy_bp_condition(void *data) /* {{{ */
 static void php_phpdbg_destroy_registered(void *data)
 {
        TSRMLS_FETCH();
-       
+
        zend_function *function = (zend_function*) data;
-       
+
        destroy_zend_function(
                function TSRMLS_CC);
 }
 
 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);
@@ -118,7 +118,7 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
     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);
        zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0);
-       
+
        return SUCCESS;
 } /* }}} */
 
@@ -131,7 +131,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
     zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]);
        zend_hash_destroy(&PHPDBG_G(seek));
        zend_hash_destroy(&PHPDBG_G(registered));
-       
+
     if (PHPDBG_G(exec)) {
         efree(PHPDBG_G(exec));
         PHPDBG_G(exec) = NULL;
@@ -170,19 +170,19 @@ static PHP_FUNCTION(phpdbg_break)
 
         switch (type) {
             case METHOD_PARAM:
-                phpdbg_do_break_method(&param TSRMLS_CC);
+                phpdbg_do_break_method(&param, NULL TSRMLS_CC);
             break;
 
             case FILE_PARAM:
-                phpdbg_do_break_file(&param TSRMLS_CC);
+                phpdbg_do_break_file(&param, NULL TSRMLS_CC);
             break;
 
             case NUMERIC_PARAM:
-                phpdbg_do_break_lineno(&param TSRMLS_CC);
+                phpdbg_do_break_lineno(&param, NULL TSRMLS_CC);
             break;
 
             case STR_PARAM:
-                phpdbg_do_break_func(&param TSRMLS_CC);
+                phpdbg_do_break_func(&param, NULL TSRMLS_CC);
             break;
 
             default: zend_error(
@@ -616,7 +616,7 @@ phpdbg_main:
 
         /* print blurb */
                phpdbg_welcome((cleaning > 0) TSRMLS_CC);
-               
+
                zend_try {
                /* activate globals, they can be overwritten */
                zend_activate_auto_globals(TSRMLS_C);
index 32e99f17aeda2409560403b818ee489a35e55ab5..90d8c1e5799a76e6590ecb0b359a54e7562a8814 100644 (file)
@@ -303,7 +303,7 @@ void phpdbg_destroy_input(phpdbg_input_t **input TSRMLS_DC) /*{{{ */
        }
 } /* }}} */
 
-int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_DC) /* {{{ */
+int phpdbg_do_cmd(const phpdbg_command_t *command, const phpdbg_input_t *input TSRMLS_DC) /* {{{ */
 {
        int rc = FAILURE;
 
@@ -357,7 +357,7 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_
                                        &PHPDBG_G(lparam) TSRMLS_CC);
                                PHPDBG_G(lparam) = param;
 
-                               rc = command->handler(&param TSRMLS_CC);
+                               rc = command->handler(&param, input TSRMLS_CC);
                                break;
                        }
                        command++;
index 696a49a6c199c90f7e7fba60203534589a65ad84..259078ac9d26e6448f6a03539ae0a00c21be5e4e 100644 (file)
@@ -66,7 +66,7 @@ typedef struct _phpdbg_param {
        size_t len;
 } phpdbg_param_t;
 
-typedef int (*phpdbg_command_handler_t)(phpdbg_param_t* TSRMLS_DC);
+typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t*, const phpdbg_input_t* TSRMLS_DC);
 
 struct _phpdbg_command_t {
        const char *name;                   /* Command name */
@@ -114,7 +114,7 @@ const char* phpdbg_get_param_type(const phpdbg_param_t* TSRMLS_DC);
 /*
 * Command Executor
 */
-int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t *input TSRMLS_DC);
+int phpdbg_do_cmd(const phpdbg_command_t*, const phpdbg_input_t* TSRMLS_DC);
 
 /**
  * Command Declarators
@@ -127,7 +127,9 @@ int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t *input TSRMLS_DC);
 #define PHPDBG_COMMAND_D(name, tip, alias, children, has_args) \
        {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, has_args}
 
-#define PHPDBG_COMMAND(name) int phpdbg_do_##name(phpdbg_param_t *param TSRMLS_DC)
+#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC)
+
+#define PHPDBG_COMMAND_ARGS param, input TSRMLS_CC
 
 #define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0'}
 
index cda710aba00268edf00c5451be634b48658fb38b..8532a8a74f83c46ea9629cb3bb19fba42872fb93 100644 (file)
@@ -899,17 +899,17 @@ static PHPDBG_COMMAND(list) /* {{{ */
        switch (param->type) {
         case NUMERIC_PARAM:
            case EMPTY_PARAM:
-                       return PHPDBG_LIST_HANDLER(lines)(param TSRMLS_CC);
+                       return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS);
 
                case FILE_PARAM:
-                       return PHPDBG_LIST_HANDLER(lines)(param TSRMLS_CC);
+                       return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS);
 
                case STR_PARAM:
                    phpdbg_list_function_byname(param->str, param->len TSRMLS_CC);
                        break;
 
                case METHOD_PARAM:
-                   return PHPDBG_LIST_HANDLER(method)(param TSRMLS_CC);
+                   return PHPDBG_LIST_HANDLER(method)(PHPDBG_COMMAND_ARGS);
 
                phpdbg_default_switch_case();
     }
@@ -926,7 +926,7 @@ int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
 
                zval fname, *fretval;
                zend_fcall_info *fci = ecalloc(1, sizeof(zend_fcall_info));
-               
+
                ZVAL_STRINGL(&fname, function->string, function->length, 1);
 
                fci->size = sizeof(zend_fcall_info);
@@ -936,36 +936,36 @@ int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
                fci->object_ptr = NULL;
                fci->retval_ptr_ptr = &fretval;
                fci->no_separation = 1;
-               
+
                if (input->argc > 1) {
                        int param;
                        zval params;
-                       
+
                        array_init(&params);
-                       
+
                        for (param = 0; param < (input->argc-1); param++) {
                                add_next_index_stringl(
-                                       &params, 
+                                       &params,
                                        input->argv[param+1]->string,
                                        input->argv[param+1]->length, 1);
-                       
+
                                phpdbg_debug(
-                                       "created param[%d] from argv[%d]: %s", 
+                                       "created param[%d] from argv[%d]: %s",
                                        param, param+1, input->argv[param+1]->string);
                        }
-                       
+
                        zend_fcall_info_args(fci, &params TSRMLS_CC);
                } else {
                        fci->params = NULL;
                        fci->param_count = 0;
                }
-               
+
                phpdbg_debug(
-                       "created %d params from %d argvuments", 
+                       "created %d params from %d argvuments",
                        fci->param_count, input->argc);
-               
+
                zend_call_function(fci, NULL TSRMLS_CC);
-               
+
                if (fretval) {
                        zend_print_zval_r(
                                fretval, 0 TSRMLS_CC);
@@ -977,9 +977,9 @@ int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
                if (fci->params) {
                        efree(fci->params);
                }
-               
+
                efree(fci);
-               
+
                return SUCCESS;
        }
 
@@ -1024,7 +1024,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
 last:
                if (PHPDBG_G(lcmd)) {
                        ret = PHPDBG_G(lcmd)->handler(
-                                       &PHPDBG_G(lparam) TSRMLS_CC);
+                                       &PHPDBG_G(lparam), input TSRMLS_CC);
                        goto out;
                }
        }