]> granicus.if.org Git - php/commitdiff
moar params for registered functions
authorkrakjoe <joe.watkins@live.co.uk>
Mon, 24 Feb 2014 22:30:46 +0000 (22:30 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Mon, 24 Feb 2014 22:30:46 +0000 (22:30 +0000)
dev/phpdbg_lexer.l
phpdbg_prompt.c
test.php

index 90f9f0c63aa22e540461bf604e371073469740af..d371e59c599cac6801d878f0ec63e0da8105b967 100644 (file)
 #include "phpdbg_parser.h"
 #include <stdio.h>
 #include <string.h>
+
+static inline int phpdbg_needs_params(phpdbg_param_t *param TSRMLS_DC) {
+       return 0;
+}
 %}
 
 %s RAW
@@ -40,6 +44,22 @@ ADDR                         0x[a-fA-F0-9]+
 OPCODE                         ?i:ZEND_([A-Za-z])+
 INPUT                          [^\n]+
 %%
+<INITIAL>[a-zA-Z]+     {
+       phpdbg_init_param(yylval, STR_PARAM);
+       yylval->str = strndup(yytext, yyleng);
+       yylval->len = yyleng;
+       if (phpdbg_needs_params(yylval TSRMLS_CC)) {
+               BEGIN(PARAMS);
+       }
+       return T_ID;
+}
+
+<PARAMS>[0-9]+         {
+       phpdbg_init_param(yylval, NUMERIC_PARAM);
+       yylval->num = atoi(yytext);
+       return T_ID;
+}
+
 <INITIAL>
 {
        [#]{1}          { return T_POUND;  }
index 2cae1b6aa962ef560bf9789848813588f28a4f1f..31c5d251222baed53ea87f589ef11cb4bc919a07 100644 (file)
@@ -106,8 +106,12 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ *
                                
                                array_init(&params);
 
-                               while (next) {  
+                               while (next) {
+                                       char *buffered = NULL;
+                                       
                                        switch (next->type) {
+                                               case OP_PARAM:
+                                               case COND_PARAM:
                                                case STR_PARAM:
                                                        add_next_index_stringl(
                                                                &params,
@@ -119,14 +123,41 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ *
                                                        add_next_index_long(&params, next->num);
                                                break;
                                                
+                                               case METHOD_PARAM:
+                                                       spprintf(&buffered, 0, "%s::%s" 
+                                                               TSRMLS_CC, next->method.class, next->method.name);
+                                                       add_next_index_string(&params, buffered, 0);
+                                               break;
+                                               
+                                               case NUMERIC_METHOD_PARAM:
+                                                       spprintf(&buffered, 0, "%s::%s#%ld" 
+                                                               TSRMLS_CC, next->method.class, next->method.name, next->num);
+                                                       add_next_index_string(&params, buffered, 0);
+                                               break;
+                                               
+                                               case NUMERIC_FUNCTION_PARAM:
+                                                       spprintf(&buffered, 0, "%s#%ld" 
+                                                               TSRMLS_CC, next->str, next->num);
+                                                       add_next_index_string(&params, buffered, 0);
+                                               break;
+                                                       
+                                               case FILE_PARAM:
+                                                       spprintf(&buffered, 0, "%s:%ld" 
+                                                               TSRMLS_CC, next->file.name, next->file.line);
+                                                       add_next_index_string(&params, buffered, 0);
+                                               break;
+                                               
+                                               case NUMERIC_FILE_PARAM:
+                                                       spprintf(&buffered, 0, "%s:#%ld" 
+                                                               TSRMLS_CC, next->file.name, next->file.line);
+                                                       add_next_index_string(&params, buffered, 0);
+                                               break;
+                                               
                                                default: {
                                                        /* not yet */
                                                }
                                        }
                                        
-                                       phpdbg_debug(
-                                               "created param[%d] from argv[%d]: %s",
-                                               param, param+1, next->str);
                                        next = next->next;      
                                }
 
index 5fdbcbe1a4544453a9d2dd99abe2ea2effb14bb7..3618ce2391c72014dcfa7f4ae7bbbabd2304d3a9 100644 (file)
--- a/test.php
+++ b/test.php
@@ -13,6 +13,10 @@ class phpdbg {
     }
 }
 
+function mine() {
+       var_dump(func_get_args());
+}
+
 function test($x, $y = 0) {
        $var = $x + 1;
        $var += 2;