View Issue Details

IDProjectCategoryView StatusLast Update
0000763XdebugUncategorizedpublic2012-03-12 16:52
Reporterjsiponen Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionunable to reproduce 
Product Version2.1.0 
Summary0000763: DBGP lineno is wrong if php script starts with a shebang
Description

DBGP lineno is wrong if php script starts with a shebang. See "Steps to Reproduce" for more details.

Steps To Reproduce

These are the files that I tested with, the first is without a shebang and the other one begins with a shebang.

File: test_no_shebang.php
<?php
$line_2 = 2;
$line_3 = 3;

$line_4 = 4;

File: test_with_shebang.php

#!/usr/bin/env php
<?php
$line_2 = 2;
$line_3 = 3;

$line_4 = 4;

If I set the breakpoint at line two for the file "test_no_shebang.php" then XDebug protocol will report the correct line numbers when stepping over the file:

<< stack_get -d 0

<response command='stack_get' transaction_id='7' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' xmlns='urn:debugger_protocol_v1'><stack lineno='2' level='0' type='file' filename='file:///Users/joes/Desktop/xdebug_breakpoint_test.php' where='{main}'/></response>

1 <?php
2 >> $line_2 = 2;
3 $line_3 = 3;
4
5 $line_4 = 4;

<< step_over

<response command='step_over' transaction_id='10' reason='ok' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' status='break' xmlns='urn:debugger_protocol_v1'><xdebug:message lineno='3' filename='file:///Users/joes/Desktop/xdebug_breakpoint_test.php'/></response>

<< stack_get -d 0

<response command='stack_get' transaction_id='11' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' xmlns='urn:debugger_protocol_v1'><stack lineno='3' level='0' type='file' filename='file:///Users/joes/Desktop/xdebug_breakpoint_test.php' where='{main}'/></response>

1 <?php
2 $line_2 = 2;
3 >> $line_3 = 3;
4
5 $line_4 = 4;

<< step_over

<response command='step_over' transaction_id='13' reason='ok' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' status='break' xmlns='urn:debugger_protocol_v1'><xdebug:message lineno='5' filename='file:///Users/joes/Desktop/xdebug_breakpoint_test.php'/></response>
<< stack_get -d 0
<response command='stack_get' transaction_id='14' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' xmlns='urn:debugger_protocol_v1'><stack lineno='5' level='0' type='file' filename='file:///Users/joes/Desktop/xdebug_breakpoint_test.php' where='{main}'/></response>

2 $line_2 = 2;
3 $line_3 = 3;
4
5 >> $line_4 = 4;

============================================

However, if I try the same with the file ""test_with_shebang.php" the line numbers are reported wrongly (with the breakpoint set at line 3 now) after I step over once, as seen below:

<< stack_get -d 0

<response command='stack_get' transaction_id='7' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' xmlns='urn:debugger_protocol_v1'><stack lineno='3' level='0' type='file' filename='file:///Users/joes/Desktop/xdebug_breakpoint_test.php' where='{main}'/></response>

1 #!/usr/bin/env php
2 <?php
3 >> $line_2 = 2;
4 $line_3 = 3;
5
6 $line_4 = 4;

Comment: Ok line offset

<< step_over

<response command='step_over' transaction_id='10' reason='ok' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' status='break' xmlns='urn:debugger_protocol_v1'><xdebug:message lineno='5' filename='file:///Users/joes/Desktop/xdebug_breakpoint_test.php'/></response>
<< stack_get -d 0
<response command='stack_get' transaction_id='11' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' xmlns='urn:debugger_protocol_v1'><stack lineno='5' level='0' type='file' filename='file:///Users/joes/Desktop/xdebug_breakpoint_test.php' where='{main}'/></response>

2 <?php
3 $line_2 = 2;
4 $line_3 = 3;
5 >>
6 $line_4 = 4;

Comment: Something went wrong, suddenly we find ourselves to be at line 5.

<< step_over

<response command='step_over' transaction_id='13' reason='ok' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' status='stopping' xmlns='urn:debugger_protocol_v1'/>
<< stack_get -d 0
<response command='stack_get' transaction_id='14' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' xmlns='urn:debugger_protocol_v1'><error code='5'><message><![CDATA[command is not available]]></message></error></response>

Comment: Couldn't step_over to line 6

===============================================

Also 'xcmd_get_executable_lines' will report the wrong lines for the file "test_with_shebang.php". It seems there's an error in the line offset by -1.

<< xcmd_get_executable_lines -d 0

<response command='xcmd_get_executable_lines' transaction_id='10' xmlns:xdebug='http://xdebug.org/dbgp/xdebug' xmlns='urn:debugger_protocol_v1'>
<xdebug:lines>
<xdebug:line lineno='2'/>
<xdebug:line lineno='3'/>
<xdebug:line lineno='5'/>
</xdebug:lines>
</response>

TagsNo tags attached.
Operating SystemMac OS X 10.7.2
PHP Version5.3.8

Activities

derick

2012-02-29 13:08

administrator   ~0001929

I can't reproduce this. Could you please try with the latest released version (2.1.3)?

derick

2012-03-12 16:52

administrator   ~0001979

Can't reproduce, and no feedback provided.

Issue History

Date Modified Username Field Change
2011-12-27 11:01 jsiponen New Issue
2012-02-29 13:08 derick Note Added: 0001929
2012-02-29 13:08 derick Assigned To => derick
2012-02-29 13:08 derick Status new => feedback
2012-03-12 16:52 derick Note Added: 0001979
2012-03-12 16:52 derick Status feedback => resolved
2012-03-12 16:52 derick Resolution open => unable to reproduce
2016-07-31 12:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 12:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized