Skip to content

Commit

Permalink
- Tentative fix for bug xdebug#639: Xdebug profiling: output not corr…
Browse files Browse the repository at this point in the history
…ect - missing

  'cfl='.

SVN Rev: 3413
  • Loading branch information
derickr committed Mar 21, 2011
1 parent 33a8b20 commit ca23e38
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/bug00631.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ fn={main}
summary: %d

%d %d
cfl=php:internal
cfn=php::register_shutdown_function
calls=1 0 0
%d %d
cfl=php:internal
cfn=php::strlen
calls=1 0 0
%d %d
Expand Down
6 changes: 6 additions & 0 deletions tests/bug00639-2.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
function func2()
{
strlen("42");
}
?>
110 changes: 110 additions & 0 deletions tests/bug00639.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
--TEST--
Test for bug #639: Xdebug profiling: output not correct - missing 'cfl='
--INI--
xdebug.profiler_enable=1
--FILE--
<?php
require 'bug00639-2.inc';

function func1()
{
func2();
func2();
}

func1();
func2();
func2();
func2();

echo file_get_contents(xdebug_get_profiler_filename());
unlink(xdebug_get_profiler_filename());
?>
--EXPECTF--
version: 1
creator: xdebug 2.%s
cmd: %sbug00639.php
part: 1
positions: line

events: Time

fl=%sbug00639-2.inc
fn=require::%sbug00639-2.inc
1 %d

fl=php:internal
fn=php::strlen
4 %d

fl=%sbug00639-2.inc
fn=func2
6 %d
cfl=php:internal
cfn=php::strlen
calls=1 0 0
4 %d

fl=php:internal
fn=php::strlen
4 %d

fl=%sbug00639-2.inc
fn=func2
7 %d
cfl=php:internal
cfn=php::strlen
calls=1 0 0
4 %d

fl=%sbug00639.php
fn=func1
10 %d
cfl=%sbug00639-2.inc
cfn=func2
calls=1 0 0
6 %d
cfl=%sbug00639-2.inc
cfn=func2
calls=1 0 0
7 %d

fl=php:internal
fn=php::strlen
4 %d

fl=%sbug00639-2.inc
fn=func2
11 %d
cfl=php:internal
cfn=php::strlen
calls=1 0 0
4 %d

fl=php:internal
fn=php::strlen
4 %d

fl=%sbug00639-2.inc
fn=func2
12 %d
cfl=php:internal
cfn=php::strlen
calls=1 0 0
4 %d

fl=php:internal
fn=php::strlen
4 %d

fl=%sbug00639-2.inc
fn=func2
13 %d
cfl=php:internal
cfn=php::strlen
calls=1 0 0
4 %d

fl=php:internal
fn=php::xdebug_get_profiler_filename
15 %d
4 changes: 3 additions & 1 deletion xdebug_profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void xdebug_profiler_function_user_end(function_stack_entry *fse, zend_op_array*

if (fse->prev) {
xdebug_call_entry *ce = xdmalloc(sizeof(xdebug_call_entry));
ce->filename = xdstrdup(fse->filename);
ce->filename = op_array ? xdstrdup(op_array->filename) : xdstrdup(fse->filename);
ce->function = xdstrdup(tmp_name);
ce->time_taken = fse->profile.time;
ce->lineno = fse->lineno;
Expand Down Expand Up @@ -211,8 +211,10 @@ void xdebug_profiler_function_user_end(function_stack_entry *fse, zend_op_array*
xdebug_call_entry *call_entry = XDEBUG_LLIST_VALP(le);

if (call_entry->user_defined == XDEBUG_EXTERNAL) {
fprintf(XG(profile_file), "cfl=%s\n", call_entry->filename);
fprintf(XG(profile_file), "cfn=%s\n", call_entry->function);
} else {
fprintf(XG(profile_file), "cfl=php:internal\n");
fprintf(XG(profile_file), "cfn=php::%s\n", call_entry->function);
}

Expand Down

0 comments on commit ca23e38

Please sign in to comment.