[xdebug-dev] xdebug xdebug/xdebug.c xdebug/tests/functrace_comp_0.phpt xdebug/tests/functrace_comp_1.phpt xdebug/tests/functrace_comp_2.phpt xdebug/tests/functrace_comp_3.phpt xdebug/tests/functrace_comp_4.phpt xdebug/tests/trace1.phpt - Implemented feature #245: Function parameters in computerized function traces.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Wed, 21 Nov 2007 14:44:38 +0100

Date: Wed Nov 21 14:44:38 CET 2007
User: Derick Rethans
Directory: xdebug

Log Message:
[2.50]
- Implemented feature #245: Function parameters in computerized function traces.

Modified files:
           xdebug/xdebug.c (version: 1.413)
           xdebug/tests/trace1.phpt (version: 1.2)
Added files:
           xdebug/tests/functrace_comp_0.phpt (new version: 1.1)
           xdebug/tests/functrace_comp_1.phpt (new version: 1.1)
           xdebug/tests/functrace_comp_2.phpt (new version: 1.1)
           xdebug/tests/functrace_comp_3.phpt (new version: 1.1)
           xdebug/tests/functrace_comp_4.phpt (new version: 1.1)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.412
retrieving revision 1.413
diff -u -r1.412 -r1.413
--- xdebug/xdebug.c:1.412 Wed Nov 21 12:42:15 2007 GMT
+++ xdebug/xdebug.c Wed Nov 21 12:44:37 2007 GMT
@@ -2106,7 +2106,46 @@
                         xdebug_str_add(&str, i->include_filename, 0);
                 }
 
- xdebug_str_add(&str, xdebug_sprintf("\t%s\t%d\n", i->filename, i->lineno), 1);
+ /* Filename and Lineno (9, 10) */
+ xdebug_str_add(&str, xdebug_sprintf("\t%s\t%d", i->filename, i->lineno), 1);
+
+
+ if (XG(collect_params) > 0) {
+ int j = 0; /* Counter */
+
+ /* Nr of arguments (11) */
+ xdebug_str_add(&str, xdebug_sprintf("\t%d", i->varc), 1);
+
+ /* Arguments (12-...) */
+ for (j = 0; j < i->varc; j++) {
+ char *tmp_value;
+
+ xdebug_str_addl(&str, "\t", 1, 0);
+
+ if (i->var[j].name && XG(collect_params) >= 4) {
+ xdebug_str_add(&str, xdebug_sprintf("$%s = ", i->var[j].name), 1);
+ }
+
+ switch (XG(collect_params)) {
+ case 1: // synopsis
+ case 2:
+ tmp_value = xdebug_get_zval_synopsis(i->var[j].addr, 0, NULL);
+ break;
+ case 3:
+ default:
+ tmp_value = xdebug_get_zval_value(i->var[j].addr, 0, NULL);
+ break;
+ }
+ if (tmp_value) {
+ xdebug_str_add(&str, tmp_value, 1);
+ } else {
+ xdebug_str_add(&str, "???", 0);
+ }
+ }
+ }
+
+ /* Trailing \n */
+ xdebug_str_add(&str, "\n", 0);
 
         } else if (whence == 1) { /* end */
                 xdebug_str_add(&str, "1\t", 0);
@@ -2884,6 +2923,7 @@
         if (XG(trace_file)) {
                 if (XG(trace_format) == 1) {
                         fprintf(XG(trace_file), "Version: %s\n", XDEBUG_VERSION);
+ fprintf(XG(trace_file), "File format: 2\n");
                 }
                 if (XG(trace_format) == 0 || XG(trace_format) == 1) {
                         str_time = xdebug_get_time();

[FILE: /xdebug/tests/functrace_comp_0.phpt]

--TEST--
Test computerized function traces (level0, comp)
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
--INI--
xdebug.default_enable=1
xdebug.profiler_enable=0
xdebug.auto_trace=0
xdebug.trace_format=1
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.collect_vars=0
xdebug.collect_params=0
xdebug.collect_returns=0
--FILE--
<?php
$tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE), XDEBUG_TRACE_COMPUTERIZED);

function foo( $a, $b )
{
        // do nothing really
}

@foo( 42 );
@foo( "string" );
@foo( "string\nwith\nnewline" );
@foo( 1, false );
@foo( true, null );
@foo( "foo", "bar", 3.1415 );

xdebug_stop_trace();
echo file_get_contents($tf);
unlink($tf);
?>
--EXPECTF--
Version: 2.1.0-dev
File format: 2
TRACE START [%d-%d-%d %d:%d:%d]
2 2 1 %f %d
2 3 0 %f %d foo 1 %sfunctrace_comp_0.php 9
2 3 1 %f %d
2 4 0 %f %d foo 1 %sfunctrace_comp_0.php 10
2 4 1 %f %d
2 5 0 %f %d foo 1 %sfunctrace_comp_0.php 11
2 5 1 %f %d
2 6 0 %f %d foo 1 %sfunctrace_comp_0.php 12
2 6 1 %f %d
2 7 0 %f %d foo 1 %sfunctrace_comp_0.php 13
2 7 1 %f %d
2 8 0 %f %d foo 1 %sfunctrace_comp_0.php 14
2 8 1 %f %d
2 9 0 %f %d xdebug_stop_trace 0 %sfunctrace_comp_0.php 16
                        %f %d
TRACE END [%d-%d-%d %d:%d:%d]

[FILE: /xdebug/tests/functrace_comp_1.phpt]

--TEST--
Test computerized function traces (level1, comp)
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
--INI--
xdebug.default_enable=1
xdebug.profiler_enable=0
xdebug.auto_trace=0
xdebug.trace_format=1
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.collect_vars=0
xdebug.collect_params=1
xdebug.collect_returns=0
--FILE--
<?php
$tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE), XDEBUG_TRACE_COMPUTERIZED);

function foo( $a, $b )
{
        // do nothing really
}

@foo( 42 );
@foo( "string" );
@foo( "string\nwith\nnewline" );
@foo( 1, false );
@foo( true, null );
@foo( "foo", "bar", 3.1415 );

xdebug_stop_trace();
echo file_get_contents($tf);
unlink($tf);
?>
--EXPECTF--
Version: 2.1.0-dev
File format: 2
TRACE START [%d-%d-%d %d:%d:%d]
2 2 1 %f %d
2 3 0 %f %d foo 1 %sfunctrace_comp_1.php 9 2 long ???
2 3 1 %f %d
2 4 0 %f %d foo 1 %sfunctrace_comp_1.php 10 2 string(6) ???
2 4 1 %f %d
2 5 0 %f %d foo 1 %sfunctrace_comp_1.php 11 2 string(19) ???
2 5 1 %f %d
2 6 0 %f %d foo 1 %sfunctrace_comp_1.php 12 2 long bool
2 6 1 %f %d
2 7 0 %f %d foo 1 %sfunctrace_comp_1.php 13 2 bool null
2 7 1 %f %d
2 8 0 %f %d foo 1 %sfunctrace_comp_1.php 14 3 string(3) string(3) double
2 8 1 %f %d
2 9 0 %f %d xdebug_stop_trace 0 %sfunctrace_comp_1.php 16 0
                        %f %d
TRACE END [%d-%d-%d %d:%d:%d]

[FILE: /xdebug/tests/functrace_comp_2.phpt]

--TEST--
Test computerized function traces (level2, comp)
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
--INI--
xdebug.default_enable=1
xdebug.profiler_enable=0
xdebug.auto_trace=0
xdebug.trace_format=1
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.collect_vars=0
xdebug.collect_params=2
xdebug.collect_returns=0
--FILE--
<?php
$tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE), XDEBUG_TRACE_COMPUTERIZED);

function foo( $a, $b )
{
        // do nothing really
}

@foo( 42 );
@foo( "string" );
@foo( "string\nwith\nnewline" );
@foo( 1, false );
@foo( true, null );
@foo( "foo", "bar", 3.1415 );

xdebug_stop_trace();
echo file_get_contents($tf);
unlink($tf);
?>
--EXPECTF--
Version: 2.1.0-dev
File format: 2
TRACE START [%d-%d-%d %d:%d:%d]
2 2 1 %f %d
2 3 0 %f %d foo 1 %sfunctrace_comp_2.php 9 2 long ???
2 3 1 %f %d
2 4 0 %f %d foo 1 %sfunctrace_comp_2.php 10 2 string(6) ???
2 4 1 %f %d
2 5 0 %f %d foo 1 %sfunctrace_comp_2.php 11 2 string(19) ???
2 5 1 %f %d
2 6 0 %f %d foo 1 %sfunctrace_comp_2.php 12 2 long bool
2 6 1 %f %d
2 7 0 %f %d foo 1 %sfunctrace_comp_2.php 13 2 bool null
2 7 1 %f %d
2 8 0 %f %d foo 1 %sfunctrace_comp_2.php 14 3 string(3) string(3) double
2 8 1 %f %d
2 9 0 %f %d xdebug_stop_trace 0 %sfunctrace_comp_2.php 16 0
                        %f %d
TRACE END [%d-%d-%d %d:%d:%d]

[FILE: /xdebug/tests/functrace_comp_3.phpt]

--TEST--
Test computerized function traces (level3, comp)
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
--INI--
xdebug.default_enable=1
xdebug.profiler_enable=0
xdebug.auto_trace=0
xdebug.trace_format=1
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.collect_vars=0
xdebug.collect_params=3
xdebug.collect_returns=0
--FILE--
<?php
$tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE), XDEBUG_TRACE_COMPUTERIZED);

function foo( $a, $b )
{
        // do nothing really
}

@foo( 42 );
@foo( "string" );
@foo( "string\nwith\nnewline" );
@foo( 1, false );
@foo( true, null );
@foo( "foo", "bar", 3.1415 );

xdebug_stop_trace();
echo file_get_contents($tf);
unlink($tf);
?>
--EXPECTF--
Version: 2.1.0-dev
File format: 2
TRACE START [%d-%d-%d %d:%d:%d]
2 2 1 %f %d
2 3 0 %f %d foo 1 %sfunctrace_comp_3.php 9 2 42 ???
2 3 1 %f %d
2 4 0 %f %d foo 1 %sfunctrace_comp_3.php 10 2 'string' ???
2 4 1 %f %d
2 5 0 %f %d foo 1 %sfunctrace_comp_3.php 11 2 'string\nwith\nnewline' ???
2 5 1 %f %d
2 6 0 %f %d foo 1 %sfunctrace_comp_3.php 12 2 1 FALSE
2 6 1 %f %d
2 7 0 %f %d foo 1 %sfunctrace_comp_3.php 13 2 TRUE NULL
2 7 1 %f %d
2 8 0 %f %d foo 1 %sfunctrace_comp_3.php 14 3 'foo' 'bar' 3.1415
2 8 1 %f %d
2 9 0 %f %d xdebug_stop_trace 0 %sfunctrace_comp_3.php 16 0
                        %f %d
TRACE END [%d-%d-%d %d:%d:%d]

[FILE: /xdebug/tests/functrace_comp_4.phpt]

--TEST--
Test computerized function traces (level4, comp)
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
--INI--
xdebug.default_enable=1
xdebug.profiler_enable=0
xdebug.auto_trace=0
xdebug.trace_format=1
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.collect_vars=0
xdebug.collect_params=4
xdebug.collect_returns=0
--FILE--
<?php
$tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE), XDEBUG_TRACE_COMPUTERIZED);

function foo( $a, $b )
{
        // do nothing really
}

@foo( 42 );
@foo( "string" );
@foo( "string\nwith\nnewline" );
@foo( 1, false );
@foo( true, null );
@foo( "foo", "bar", 3.1415 );

xdebug_stop_trace();
echo file_get_contents($tf);
unlink($tf);
?>
--EXPECTF--
Version: 2.1.0-dev
File format: 2
TRACE START [%d-%d-%d %d:%d:%d]
2 2 1 %f %d
2 3 0 %f %d foo 1 %sfunctrace_comp_4.php 9 2 $a = 42 $b = ???
2 3 1 %f %d
2 4 0 %f %d foo 1 %sfunctrace_comp_4.php 10 2 $a = 'string' $b = ???
2 4 1 %f %d
2 5 0 %f %d foo 1 %sfunctrace_comp_4.php 11 2 $a = 'string\nwith\nnewline' $b = ???
2 5 1 %f %d
2 6 0 %f %d foo 1 %sfunctrace_comp_4.php 12 2 $a = 1 $b = FALSE
2 6 1 %f %d
2 7 0 %f %d foo 1 %sfunctrace_comp_4.php 13 2 $a = TRUE $b = NULL
2 7 1 %f %d
2 8 0 %f %d foo 1 %sfunctrace_comp_4.php 14 3 $a = 'foo' $b = 'bar' 3.1415
2 8 1 %f %d
2 9 0 %f %d xdebug_stop_trace 0 %sfunctrace_comp_4.php 16 0
                        %f %d
TRACE END [%d-%d-%d %d:%d:%d]

[FILE: /xdebug/tests/trace1.phpt]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- xdebug/tests/trace1.phpt:1.1 Tue Jul 24 18:06:41 2007 GMT
+++ xdebug/tests/trace1.phpt Wed Nov 21 12:44:37 2007 GMT
@@ -5,7 +5,7 @@
 --INI--
 xdebug.enable=1
 xdebug.auto_trace=0
-xdebug.collect_params=3
+xdebug.collect_params=0
 xdebug.collect_return=0
 xdebug.auto_profile=0
 xdebug.profiler_enable=0
@@ -40,6 +40,7 @@
 ?>
 --EXPECTF--
 Version: 2.%d.%d%s
+File format: 2
 TRACE START [%d-%d-%d %d:%d:%d]
 2 2 1 %f %d
 2 3 0 %f %d fibonacci_cache 1 %strace1.php 22
Received on Wed Nov 21 2007 - 14:57:01 GMT

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST