]> granicus.if.org Git - php/commitdiff
fix bug in passing correct expression length
authorkrakjoe <joe.watkins@live.co.uk>
Wed, 13 Nov 2013 00:36:47 +0000 (00:36 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Wed, 13 Nov 2013 00:36:47 +0000 (00:36 +0000)
add class printer (half done)

phpdbg_print.c
phpdbg_print.h
phpdbg_prompt.c
phpdbg_utils.c
phpdbg_utils.h

index 37daf028b3c12c622f2728fb0e980e6325055a87..c0d8fb4dcd1a50ee78afe76173cad3cfe4c7d324 100644 (file)
@@ -34,3 +34,20 @@ PHPDBG_PRINT(opline) /* {{{ */
 
        return SUCCESS;
 } /* }}} */
+
+PHPDBG_PRINT(class) /* {{{ */
+{
+    zend_class_entry **ce;
+    
+       if (expr && expr_len > 0L) {
+           if (zend_lookup_class(expr, strlen(expr), &ce TSRMLS_CC) == SUCCESS) {
+               
+           } else {
+               phpdbg_error("Cannot find class %s/%lu", expr, expr_len);
+           }
+       } else {
+               phpdbg_error("No class name provided!");
+       }
+
+       return SUCCESS;
+} /* }}} */
index ae8453bd0ff5cedc906e71147a3c7b61c41e2969..2358f0bab4c656b9d338b1aaf4ca0fe896deb516 100644 (file)
  * Printer Forward Declarations
  */
 PHPDBG_PRINT(opline);
+PHPDBG_PRINT(class);
 
 /**
  * Commands
  */
 static const phpdbg_command_t phpdbg_print_commands[] = {
        PHPDBG_PRINT_D(opline,     "print the current opline information"),
+       PHPDBG_PRINT_D(class,      "print out the instructions in the specified class"),
        {NULL, 0, 0}
 };
 
index f221b581eaeb43f8dbf108a83be2669dcaeb1279..f7cba8cd751d05cc49060be8359a05a8bda4ba56 100644 (file)
@@ -513,21 +513,24 @@ static const phpdbg_command_t phpdbg_prompt_commands[] = {
 
 int phpdbg_do_cmd(const phpdbg_command_t *command, char *cmd_line, size_t cmd_len TSRMLS_DC) /* {{{ */
 {
-       char *params = NULL;
+       char *expr = NULL;
 #ifndef _WIN32
-       const char *cmd = strtok_r(cmd_line, " ", &params);
+       const char *cmd = strtok_r(cmd_line, " ", &expr);
 #else
-       const char *cmd = strtok_s(cmd_line, " ", &params);
+       const char *cmd = strtok_s(cmd_line, " ", &expr);
 #endif
-       size_t expr_len = cmd != NULL ? strlen(cmd) : 0;
-
+       size_t expr_len = (cmd != NULL) ? strlen(cmd) : 0;
+    
        while (command && command->name) {
                if (command->name_len == expr_len
                            && memcmp(cmd, command->name, expr_len) == 0) {
+                       
                        PHPDBG_G(last) = (phpdbg_command_t*) command;
-                       PHPDBG_G(last_params) = params;
-                       PHPDBG_G(last_params_len) = cmd_len - expr_len;
-                       return command->handler(params, cmd_len - expr_len TSRMLS_CC);
+                       PHPDBG_G(last_params) = expr;
+                       PHPDBG_G(last_params_len) = ((cmd_len - expr_len) - sizeof(" "))+1;
+                       
+                       return command->handler(
+                           PHPDBG_G(last_params), PHPDBG_G(last_params_len) TSRMLS_CC);
                }
                ++command;
        }
index 4031b2d209c29703d71b1e208c8e4111a1295938..27ada70ef7bdb39534901f6740f3ac0d80ae5da9 100644 (file)
@@ -119,3 +119,19 @@ void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
                efree(buffer);
        }
 } /* }}} */
+
+char *phpdbg_trim(const char *expr, size_t *expr_len) /* {{{ */
+{
+    char *pointer = expr;
+    
+    while (*pointer && isspace(*pointer)) {
+        pointer++;
+        (*expr_len)--;
+    }
+    
+    while (expr_len > 0L && isspace(pointer[(*expr_len)-1])) {
+        pointer[--(*expr_len)]='\0';
+    }
+    
+    return pointer;
+} /* }}} */
index 7682201493f94bfc1bb6171e9a6fdf2953f70b3a..278019fd1a35fd975968d2042a372ee4b0000dab 100644 (file)
@@ -28,6 +28,12 @@ int phpdbg_is_empty(const char*);
 int phpdbg_is_addr(const char*);
 int phpdbg_is_class_method(const char*, size_t, char**, char**);
 
+/**
+ * Input trim function
+ * NOTE: efree all the things
+ */
+char *phpdbg_trim(const char*, size_t*);
+
 /**
  * Error/notice/formatting helper
  */