Hi Алексей,
On Mon, 21 Dec 2009, Алексей Шеин wrote:
> First, I'd like to thank you for your excellent work! Xdebug really helps me
> a lot :)
> I've got a question:
> Say I have the following code
> <?php
> $i = 10;
> $i +=
> ++$i
> + $i
> + $i++;
>
> print $i;
> ?>
>
> How can I trace it line by line, i.e. I want to know how $i changes its
> value from line 3 to 7, for now it's just 10 and 45 at one step. Is it
> possible?
Xdebug's debugger current stops everytime PHP encounters the end of a
statement (the EXT_STMT opcode). If we look at your snippet, it is
generated a few times:
line # op fetch ext return operands
-------------------------------------------------------------------------------
2 0 EXT_STMT
1 ASSIGN !0, 10
5 2 EXT_STMT
3 PRE_INC $1 !0
6 4 ADD ~2 $1, !0
5 POST_INC ~3 !0
6 ADD ~4 ~2, ~3
7 ASSIGN_ADD 0 !0, ~4
8 8 EXT_STMT
9 PRINT ~6 !0
10 FREE ~6
10 11 EXT_STMT
12 RETURN 1
But not for everyline. Xdebug in SVN
(http://xdebug.org/docs/install#source) provides a function call
"assignment tracing" which provides the following output:
derick[@]kossu:~$ php -dxdebug.collect_assignments=1 -dxdebug.auto_trace -dxdebug.trace_format=0
<?php
$i = 10;
$i +=
++$i
+ $i
+ $i++;
print $i;
?>
45
derick[@]kossu:~$ cat /tmp/trace.124683842.xt
TRACE START [2009-12-22 00:27:31]
3.5909 654472 -> {main}() /home/derick/-:0
=> $i = 10 /home/derick/-:2
=> $i += 33 /home/derick/-:6
3.5918 8280
TRACE END [2009-12-22 00:27:35]
But as you see, this doesn't catch the pre and post inc operators yet —
that should be handled properly though. I added a bug for this so that I
don't forget to add it.
with kind regards,
Derick
-- Like Xdebug? Send a postcard: http://derickrethans.nl/xdebug_2_released.php Xdebug | http://xdebug.org | xdebug-general@lists.xdebug.org twitter: @derickr and @xdebugReceived on Tue Dec 22 2009 - 00:39:29 GMT
This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST