]> granicus.if.org Git - php/commitdiff
class printer
authorkrakjoe <joe.watkins@live.co.uk>
Wed, 13 Nov 2013 01:35:39 +0000 (01:35 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Wed, 13 Nov 2013 01:35:39 +0000 (01:35 +0000)
phpdbg_opcode.c
phpdbg_print.c
phpdbg_prompt.c
phpdbg_utils.c
test.php

index 5796678cad13a77048c9374d7c9214227d4e5651..39a51692b19df8c5297fecee71f70062dfce8d82 100644 (file)
@@ -191,6 +191,7 @@ const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */
                CASE(ZEND_RECV_VARIADIC);
 #endif
                CASE(ZEND_OP_DATA);
-               default: return "UNKNOWN";
+               default: 
+                   return "UNKNOWN";
        }
 } /* }}} */
index c0d8fb4dcd1a50ee78afe76173cad3cfe4c7d324..f5cbbd3eec7b4a052c9b2e7d73c1bc48d489a95d 100644 (file)
@@ -20,6 +20,7 @@
 #include "phpdbg.h"
 #include "phpdbg_print.h"
 #include "phpdbg_utils.h"
+#include "phpdbg_opcode.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
 
@@ -41,7 +42,59 @@ PHPDBG_PRINT(class) /* {{{ */
     
        if (expr && expr_len > 0L) {
            if (zend_lookup_class(expr, strlen(expr), &ce TSRMLS_CC) == SUCCESS) {
+               phpdbg_notice(
+                   "%s %s: %s", 
+                   ((*ce)->type == ZEND_USER_CLASS) ? 
+                       "User" : "Internal",
+                   ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ? 
+                       "Interface" :
+                           ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ?
+                               "Abstract Class" :
+                                   "Class", 
+                   (*ce)->name);
                
+               phpdbg_writeln("Methods (%d):", zend_hash_num_elements(&(*ce)->function_table));
+               if (zend_hash_num_elements(&(*ce)->function_table)) {
+                   HashPosition position;
+                   zend_function *method;
+                   
+                   for (zend_hash_internal_pointer_reset_ex(&(*ce)->function_table, &position);
+                        zend_hash_get_current_data_ex(&(*ce)->function_table, (void**) &method, &position) == SUCCESS;
+                        zend_hash_move_forward_ex(&(*ce)->function_table, &position)) {
+                        switch (method->type) {
+                           case ZEND_USER_FUNCTION: {
+                               zend_op_array* op_array = &method->op_array;
+   
+                            if (op_array) {
+                                zend_op     *opline = &op_array->opcodes[0];
+                                zend_uint   opcode = 0,
+                                            end =  op_array->last-1;
+
+                                 phpdbg_writeln(
+                                    "\t%s::%s() in %s:%d-%d", 
+                                    (*ce)->name, method->common.function_name,
+                                    op_array->filename ? op_array->filename : "unknown",
+                                    op_array->line_start, op_array->line_end);
+                                
+                                do {
+                                    char *decode = phpdbg_decode_opcode(opline->opcode);
+                                    if (decode != NULL) {
+                                        phpdbg_writeln(
+                                            "\t\t%p:%s", opline, decode); 
+                                    } else phpdbg_error("\tFailed to decode opline @ %ld", opline);
+                                    
+                                    opline++;
+                                } while (++opcode < end);
+                            }  
+                           } break;
+                           
+                           default: {
+                               phpdbg_writeln(
+                                   "\tInternal Method %s::%s()", (*ce)->name, method->common.function_name);
+                           }
+                        }
+                   }
+               }
            } else {
                phpdbg_error("Cannot find class %s/%lu", expr, expr_len);
            }
index f7cba8cd751d05cc49060be8359a05a8bda4ba56..d2cd8be7a8a47a577e32cb24a8b97606b4158a92 100644 (file)
@@ -547,7 +547,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
 
 phpdbg_interactive_enter:
     phpdbg_write(PROMPT);
-
+    
        while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING) &&
               fgets(cmd, PHPDBG_MAX_CMD, stdin) != NULL) {
            cmd_len = strlen(cmd) - 1;
index 27ada70ef7bdb39534901f6740f3ac0d80ae5da9..3c8606cc22ff2b29588361632f65cb3f588cb44b 100644 (file)
@@ -23,6 +23,7 @@
 #include "php.h"
 #include "spprintf.h"
 #include "phpdbg.h"
+#include "phpdbg_opcode.h"
 #include "phpdbg_utils.h"
 
 ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
index 457e487db703d7eb48631c9bac07d73735c7cb91..0f240e1618fa4c8345be8836f1b0aa3cf57c9806 100644 (file)
--- a/test.php
+++ b/test.php
@@ -2,6 +2,7 @@
 
 class my {
     public function method() {
+        echo "Hello";
         return $this;
     }
 }