laruence                                 Tue, 06 Dec 2011 09:56:01 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=320486

Log:
Add zbacktrace_ex to .gdbinit which will print extra argument info than 
zbacktrace
Implement FR #60448

Bug: https://bugs.php.net/60448 (Assigned) Add argument info in zbacktrace
      
Changed paths:
    U   php/php-src/branches/PHP_5_4/.gdbinit
    U   php/php-src/trunk/.gdbinit

Modified: php/php-src/branches/PHP_5_4/.gdbinit
===================================================================
--- php/php-src/branches/PHP_5_4/.gdbinit       2011-12-06 06:44:22 UTC (rev 
320485)
+++ php/php-src/branches/PHP_5_4/.gdbinit       2011-12-06 09:56:01 UTC (rev 
320486)
@@ -39,7 +39,62 @@
        while $t
                printf "[0x%08x] ", $t
                if $t->function_state.function->common.function_name
-                       printf "%s() ", 
$t->function_state.function->common.function_name
+                       if !$__plain
+                               if $t->function_state.arguments
+                                       set $count = 
(int)*($t->function_state.arguments)
+                                       printf "%s(", 
$t->function_state.function->common.function_name
+                                       while $count > 0
+                                               set $zvalue = *(zval 
**)($t->function_state.arguments - $count)
+                                               set $type = $zvalue->type
+                                               if $type == 0
+                                                       printf "NULL"
+                                               end
+                                               if $type == 1
+                                                       printf "%ld", 
$zvalue->value.lval
+                                               end
+                                               if $type == 2
+                                                       printf "%lf", 
$zvalue->value.dval
+                                               end
+                                               if $type == 3
+                                                       if $zvalue->value.lval
+                                                               printf "true"
+                                                       else
+                                                               printf "false"
+                                                       end
+                                               end
+                                               if $type == 4
+                                                       printf 
"array(%d)[0x%08x]", $zvalue->value.ht->nNumOfElements, $zvalue
+                                               end
+                                               if $type == 5
+                                                       printf 
"object[0x%08x]", $zvalue
+                                               end
+                                               if $type == 6
+                                                       ____print_str 
$zvalue->value.str.val $zvalue->value.str.len
+                                               end
+                                               if $type == 7
+                                                       printf "resource(#%d)", 
$zvalue->value.lval
+                                               end
+                                               if $type == 8
+                                                       printf "constant"
+                                               end
+                                               if $type == 9
+                                                       printf "const_array"
+                                               end
+                                               if $type > 9
+                                                       printf "unknown type 
%d", $type
+                                               end
+                                               set $count = $count -1
+                                               if $count > 0
+                                                       printf ", "
+                                               end
+                                       end
+                                       printf ") "
+                               else
+                                       printf "%s() ", 
$t->function_state.function->common.function_name
+                               end
+                       else
+                               printf "%s() ", 
$t->function_state.function->common.function_name
+                       end
                else
                        printf "??? "
                end
@@ -480,6 +535,7 @@

 define zbacktrace
        ____executor_globals
+       set $__plain = 1
        dump_bt $eg.current_execute_data
 end

@@ -490,6 +546,21 @@
        > (gdb) dump_bt $eg.current_execute_data
 end

+define zbacktrace_ex
+       ____executor_globals
+       set $__plain = 0
+       dump_bt $eg.current_execute_data
+       set $__plain = 1
+end
+
+document zbacktrace_ex
+       prints backtrace with arguments info
+       This command is almost a short cut for
+    > set $__plain = 0
+       > (gdb) ____executor_globals
+       > (gdb) dump_bt $eg.current_execute_data
+end
+
 define zmemcheck
        set $p = alloc_globals.head
        set $stat = "?"

Modified: php/php-src/trunk/.gdbinit
===================================================================
--- php/php-src/trunk/.gdbinit  2011-12-06 06:44:22 UTC (rev 320485)
+++ php/php-src/trunk/.gdbinit  2011-12-06 09:56:01 UTC (rev 320486)
@@ -39,7 +39,62 @@
        while $t
                printf "[0x%08x] ", $t
                if $t->function_state.function->common.function_name
-                       printf "%s() ", 
$t->function_state.function->common.function_name
+                       if !$__plain
+                               if $t->function_state.arguments
+                                       set $count = 
(int)*($t->function_state.arguments)
+                                       printf "%s(", 
$t->function_state.function->common.function_name
+                                       while $count > 0
+                                               set $zvalue = *(zval 
**)($t->function_state.arguments - $count)
+                                               set $type = $zvalue->type
+                                               if $type == 0
+                                                       printf "NULL"
+                                               end
+                                               if $type == 1
+                                                       printf "%ld", 
$zvalue->value.lval
+                                               end
+                                               if $type == 2
+                                                       printf "%lf", 
$zvalue->value.dval
+                                               end
+                                               if $type == 3
+                                                       if $zvalue->value.lval
+                                                               printf "true"
+                                                       else
+                                                               printf "false"
+                                                       end
+                                               end
+                                               if $type == 4
+                                                       printf 
"array(%d)[0x%08x]", $zvalue->value.ht->nNumOfElements, $zvalue
+                                               end
+                                               if $type == 5
+                                                       printf 
"object[0x%08x]", $zvalue
+                                               end
+                                               if $type == 6
+                                                       ____print_str 
$zvalue->value.str.val $zvalue->value.str.len
+                                               end
+                                               if $type == 7
+                                                       printf "resource(#%d)", 
$zvalue->value.lval
+                                               end
+                                               if $type == 8
+                                                       printf "constant"
+                                               end
+                                               if $type == 9
+                                                       printf "const_array"
+                                               end
+                                               if $type > 9
+                                                       printf "unknown type 
%d", $type
+                                               end
+                                               set $count = $count -1
+                                               if $count > 0
+                                                       printf ", "
+                                               end
+                                       end
+                                       printf ") "
+                               else
+                                       printf "%s() ", 
$t->function_state.function->common.function_name
+                               end
+                       else
+                               printf "%s() ", 
$t->function_state.function->common.function_name
+                       end
                else
                        printf "??? "
                end
@@ -480,6 +535,7 @@

 define zbacktrace
        ____executor_globals
+       set $__plain = 1
        dump_bt $eg.current_execute_data
 end

@@ -490,6 +546,21 @@
        > (gdb) dump_bt $eg.current_execute_data
 end

+define zbacktrace_ex
+       ____executor_globals
+       set $__plain = 0
+       dump_bt $eg.current_execute_data
+       set $__plain = 1
+end
+
+document zbacktrace_ex
+       prints backtrace with arguments info
+       This command is almost a short cut for
+    > set $__plain = 0
+       > (gdb) ____executor_globals
+       > (gdb) dump_bt $eg.current_execute_data
+end
+
 define zmemcheck
        set $p = alloc_globals.head
        set $stat = "?"

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to