[xdebug-dev] xdebug xdebug/xdebug.c xdebug/tests/xdebug_call.phpt xdebug/tests/xdebug_call_depth.phpt xdebug/tests/xdebug_call_depth2.phpt - Implemented FR #70: Provide optional depth on xdebug_call_* functions .

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Sat, 19 Aug 2006 15:34:03 +0200

Date: Sat Aug 19 15:34:03 CEST 2006
User: Derick Rethans
Directory: xdebug

Log Message:
[0.50]
- Implemented FR #70: Provide optional depth on xdebug_call_* functions .

Modified files:
           xdebug/xdebug.c (version: 1.327)
Added files:
           xdebug/tests/xdebug_call.phpt (new version: 1.1)
           xdebug/tests/xdebug_call_depth.phpt (new version: 1.1)
           xdebug/tests/xdebug_call_depth2.phpt (new version: 1.1)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.326
retrieving revision 1.327
diff -u -r1.326 -r1.327
--- xdebug/xdebug.c:1.326 Sat Aug 19 10:18:31 2006 GMT
+++ xdebug/xdebug.c Sat Aug 19 11:34:03 2006 GMT
@@ -2113,19 +2113,14 @@
    Returns the name of the calling class */
 PHP_FUNCTION(xdebug_call_class)
 {
- xdebug_llist_element *le;
         function_stack_entry *i;
+ long depth = 0;
 
- le = XDEBUG_LLIST_TAIL(XG(stack));
- if (le) {
- if (le->prev) {
- le = XDEBUG_LLIST_PREV(le);
- if (le->prev) {
- le = XDEBUG_LLIST_PREV(le);
- }
- }
- i = XDEBUG_LLIST_VALP(le);
-
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &depth) == FAILURE) {
+ return;
+ }
+ i = xdebug_get_stack_frame(2 + depth);
+ if (i) {
                 RETURN_STRING(i->function.class ? i->function.class : "", 1);
         } else {
                 RETURN_FALSE;
@@ -2137,19 +2132,14 @@
    Returns the function name from which the current function was called from. */
 PHP_FUNCTION(xdebug_call_function)
 {
- xdebug_llist_element *le;
         function_stack_entry *i;
+ long depth = 0;
 
- le = XDEBUG_LLIST_TAIL(XG(stack));
- if (le) {
- if (le->prev) {
- le = XDEBUG_LLIST_PREV(le);
- if (le->prev) {
- le = XDEBUG_LLIST_PREV(le);
- }
- }
- i = XDEBUG_LLIST_VALP(le);
-
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &depth) == FAILURE) {
+ return;
+ }
+ i = xdebug_get_stack_frame(2 + depth);
+ if (i) {
                 RETURN_STRING(i->function.function ? i->function.function : "{}", 1);
         } else {
                 RETURN_FALSE;
@@ -2161,16 +2151,14 @@
    Returns the line number where the current function was called from. */
 PHP_FUNCTION(xdebug_call_line)
 {
- xdebug_llist_element *le;
         function_stack_entry *i;
+ long depth = 0;
 
- le = XDEBUG_LLIST_TAIL(XG(stack));
- if (le) {
- if (le->prev) {
- le = XDEBUG_LLIST_PREV(le);
- }
- i = XDEBUG_LLIST_VALP(le);
-
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &depth) == FAILURE) {
+ return;
+ }
+ i = xdebug_get_stack_frame(1 + depth);
+ if (i) {
                 RETURN_LONG(i->lineno);
         } else {
                 RETURN_FALSE;
@@ -2182,16 +2170,14 @@
    Returns the filename where the current function was called from. */
 PHP_FUNCTION(xdebug_call_file)
 {
- xdebug_llist_element *le;
         function_stack_entry *i;
+ long depth = 0;
 
- le = XDEBUG_LLIST_TAIL(XG(stack));
- if (le) {
- if (le->prev) {
- le = XDEBUG_LLIST_PREV(le);
- }
- i = XDEBUG_LLIST_VALP(le);
-
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &depth) == FAILURE) {
+ return;
+ }
+ i = xdebug_get_stack_frame(1 + depth);
+ if (i) {
                 RETURN_STRING(i->filename, 1);
         } else {
                 RETURN_FALSE;

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

--TEST--
Test for xdebug_call_*()
--INI--
xdebug.default_enable=1
xdebug.auto_trace=0
xdebug.trace_options=0
xdebug.trace_output_dir=/tmp
xdebug.collect_return=0
xdebug.collect_params=0
xdebug.auto_profile=0
xdebug.profiler_enable=0
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.trace_format=0
--FILE--
<?php
class a {
        public function __construct( $var )
        {
                echo $var, ': ', xdebug_call_class(), '>', xdebug_call_function(), ' @ ', xdebug_call_file(), ':', xdebug_call_line(), "\n";
                c( $var + 1);
        }

        public function aa( $var )
        {
                echo $var, ': ', xdebug_call_class(), '>', xdebug_call_function(), ' @ ', xdebug_call_file(), ':', xdebug_call_line(), "\n";
                a::b( $var + 1 );
        }

        static public function b( $var )
        {
                echo $var, ': ', xdebug_call_class(), '>', xdebug_call_function(), ' @ ', xdebug_call_file(), ':', xdebug_call_line(), "\n";
                c( $var + 1);
        }
}

function c( $var )
{
        echo $var, ': ', xdebug_call_class(), '>', xdebug_call_function(), ' @ ', xdebug_call_file(), ':', xdebug_call_line(), "\n";
        d( $var + 1 );
}

function d( $var )
{
        echo $var, ': ', xdebug_call_class(), '>', xdebug_call_function(), ' @ ', xdebug_call_file(), ':', xdebug_call_line(), "\n";
}

d( 1 );
echo "\n";
c( 1 );
echo "\n";
a::b( 1 );
echo "\n";
$a = new a( 1 );
echo "\n";
$a->aa( 1 );
?>
--EXPECTF--
1: >{main} @ %sxdebug_call.php:33

1: >{main} @ %sxdebug_call.php:35
2: >c @ %sxdebug_call.php:25

1: >{main} @ %sxdebug_call.php:37
2: a>b @ %sxdebug_call.php:18
3: >c @ %sxdebug_call.php:25

1: >{main} @ %sxdebug_call.php:39
2: a>__construct @ %sxdebug_call.php:6
3: >c @ %sxdebug_call.php:25

1: >{main} @ %sxdebug_call.php:41
2: a>aa @ %sxdebug_call.php:12
3: a>b @ %sxdebug_call.php:18
4: >c @ %sxdebug_call.php:25

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

--TEST--
Test for xdebug_call_*(1)
--INI--
xdebug.default_enable=1
xdebug.auto_trace=0
xdebug.trace_options=0
xdebug.trace_output_dir=/tmp
xdebug.collect_return=0
xdebug.collect_params=0
xdebug.auto_profile=0
xdebug.profiler_enable=0
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.trace_format=0
--FILE--
<?php
class a {
        public function __construct( $var )
        {
                echo $var, ': ', xdebug_call_class(1), '>', xdebug_call_function(1), ' @ ', xdebug_call_file(1), ':', xdebug_call_line(1), "\n";
                c( $var + 1);
        }

        public function aa( $var )
        {
                echo $var, ': ', xdebug_call_class(1), '>', xdebug_call_function(1), ' @ ', xdebug_call_file(1), ':', xdebug_call_line(1), "\n";
                a::b( $var + 1 );
        }

        static public function b( $var )
        {
                echo $var, ': ', xdebug_call_class(1), '>', xdebug_call_function(1), ' @ ', xdebug_call_file(1), ':', xdebug_call_line(1), "\n";
                c( $var + 1);
        }
}

function c( $var )
{
        echo $var, ': ', xdebug_call_class(1), '>', xdebug_call_function(1), ' @ ', xdebug_call_file(1), ':', xdebug_call_line(1), "\n";
        d( $var + 1 );
}

function d( $var )
{
        echo $var, ': ', xdebug_call_class(1), '>', xdebug_call_function(1), ' @ ', xdebug_call_file(1), ':', xdebug_call_line(1), "\n";
}

d( 1 );
echo "\n";
c( 1 );
echo "\n";
a::b( 1 );
echo "\n";
$a = new a( 1 );
echo "\n";
$a->aa( 1 );
?>
--EXPECTF--
1: > @ %sxdebug_call_depth.php:0

1: > @ %sxdebug_call_depth.php:0
2: >{main} @ %sxdebug_call_depth.php:35

1: > @ %sxdebug_call_depth.php:0
2: >{main} @ %sxdebug_call_depth.php:37
3: a>b @ %sxdebug_call_depth.php:18

1: > @ %sxdebug_call_depth.php:0
2: >{main} @ %sxdebug_call_depth.php:39
3: a>__construct @ %sxdebug_call_depth.php:6

1: > @ %sxdebug_call_depth.php:0
2: >{main} @ %sxdebug_call_depth.php:41
3: a>aa @ %sxdebug_call_depth.php:12
4: a>b @ %sxdebug_call_depth.php:18

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

--TEST--
Test for xdebug_call_*(2)
--INI--
xdebug.default_enable=1
xdebug.auto_trace=0
xdebug.trace_options=0
xdebug.trace_output_dir=/tmp
xdebug.collect_return=0
xdebug.collect_params=0
xdebug.auto_profile=0
xdebug.profiler_enable=0
xdebug.dump_globals=0
xdebug.show_mem_delta=0
xdebug.trace_format=0
--FILE--
<?php
class a {
        public function __construct( $var )
        {
                echo $var, ': ', xdebug_call_class(2), '>', xdebug_call_function(2), ' @ ', xdebug_call_file(2), ':', xdebug_call_line(2), "\n";
                c( $var + 1);
        }

        public function aa( $var )
        {
                echo $var, ': ', xdebug_call_class(2), '>', xdebug_call_function(2), ' @ ', xdebug_call_file(2), ':', xdebug_call_line(2), "\n";
                a::b( $var + 1 );
        }

        static public function b( $var )
        {
                echo $var, ': ', xdebug_call_class(2), '>', xdebug_call_function(2), ' @ ', xdebug_call_file(2), ':', xdebug_call_line(2), "\n";
                c( $var + 1);
        }
}

function c( $var )
{
        echo $var, ': ', xdebug_call_class(2), '>', xdebug_call_function(2), ' @ ', xdebug_call_file(2), ':', xdebug_call_line(2), "\n";
        d( $var + 1 );
}

function d( $var )
{
        echo $var, ': ', xdebug_call_class(2), '>', xdebug_call_function(2), ' @ ', xdebug_call_file(2), ':', xdebug_call_line(2), "\n";
}

d( 1 );
echo "\n";
c( 1 );
echo "\n";
a::b( 1 );
echo "\n";
$a = new a( 1 );
echo "\n";
$a->aa( 1 );
?>
--EXPECTF--
1: > @ :

1: > @ :
2: > @ %sxdebug_call_depth2.php:0

1: > @ :
2: > @ %sxdebug_call_depth2.php:0
3: >{main} @ %sxdebug_call_depth2.php:37

1: > @ :
2: > @ %sxdebug_call_depth2.php:0
3: >{main} @ %sxdebug_call_depth2.php:39

1: > @ :
2: > @ %sxdebug_call_depth2.php:0
3: >{main} @ %sxdebug_call_depth2.php:41
4: a>aa @ %sxdebug_call_depth2.php:12
Received on Sat Aug 19 2006 - 15:34:09 BST

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