[xdebug-dev] svn: /xdebug/branches/xdebug_2_1/ tests/bug00631.phpt tests/bug00639-2.inc tests/bug00639.phpt tests/bug00643-t1.inc tests/bug00643-t2.inc tests/bug00643.phpt xdebug_profiler.c

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Mon, 21 Mar 2011 20:39:56 +0000

derick Mon, 21 Mar 2011 20:39:56 +0000

Revision: http://svn.xdebug.org/cgi-bin/viewvc.cgi?view=rev&revision=3415&root=xdebug

Log:
- Merged from HEAD:
  - Changed file version and added creator as per
    https://bugs.kde.org/show_bug.cgi?id=256425#c10
  - Added the (optional) positions line as per section 1.2 of
    http://kcachegrind.sourceforge.net/html/CallgrindFormat.html
  - Tentative fix for bug #639: Xdebug profiling: output not correct - missing
    'cfl='.
  - Fixed bug #643: Profiler gets line numbers wrong

Changed paths:
    U xdebug/branches/xdebug_2_1/tests/bug00631.phpt
    A xdebug/branches/xdebug_2_1/tests/bug00639-2.inc
    A xdebug/branches/xdebug_2_1/tests/bug00639.phpt
    A xdebug/branches/xdebug_2_1/tests/bug00643-t1.inc
    A xdebug/branches/xdebug_2_1/tests/bug00643-t2.inc
    A xdebug/branches/xdebug_2_1/tests/bug00643.phpt
    U xdebug/branches/xdebug_2_1/xdebug_profiler.c

Modified: xdebug/branches/xdebug_2_1/tests/bug00631.phpt
===================================================================
--- xdebug/branches/xdebug_2_1/tests/bug00631.phpt 2011-03-21 20:09:20 UTC (rev 3414)
+++ xdebug/branches/xdebug_2_1/tests/bug00631.phpt 2011-03-21 20:39:56 UTC (rev 3415)
@@ -13,9 +13,11 @@
 exit();
 ?>
 --EXPECTF--
-version: 0.9.6
+version: 1
+creator: xdebug 2.%s
 cmd: %sbug00631.php
 part: 1
+positions: line

 events: Time

@@ -33,9 +35,11 @@
 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

Added: xdebug/branches/xdebug_2_1/tests/bug00639-2.inc
===================================================================
--- xdebug/branches/xdebug_2_1/tests/bug00639-2.inc (rev 0)
+++ xdebug/branches/xdebug_2_1/tests/bug00639-2.inc 2011-03-21 20:39:56 UTC (rev 3415)
@@ -0,0 +1,6 @@
+<?php
+function func2()
+{
+ strlen("42");
+}
+?>

Added: xdebug/branches/xdebug_2_1/tests/bug00639.phpt
===================================================================
--- xdebug/branches/xdebug_2_1/tests/bug00639.phpt (rev 0)
+++ xdebug/branches/xdebug_2_1/tests/bug00639.phpt 2011-03-21 20:39:56 UTC (rev 3415)
@@ -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
+2 %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
+2 %d
+cfl=php:internal
+cfn=php::strlen
+calls=1 0 0
+4 %d
+
+fl=%sbug00639.php
+fn=func1
+4 %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
+2 %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
+2 %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
+2 %d
+cfl=php:internal
+cfn=php::strlen
+calls=1 0 0
+4 %d
+
+fl=php:internal
+fn=php::xdebug_get_profiler_filename
+15 %d

Added: xdebug/branches/xdebug_2_1/tests/bug00643-t1.inc
===================================================================
--- xdebug/branches/xdebug_2_1/tests/bug00643-t1.inc (rev 0)
+++ xdebug/branches/xdebug_2_1/tests/bug00643-t1.inc 2011-03-21 20:39:56 UTC (rev 3415)
@@ -0,0 +1,29 @@
+<?php
+require_once('bug00643-t2.inc');
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+function t1()
+{
+ global $a;
+ if (count($a) && errors_fatal($a))
+ {
+ echo "ok";
+ }
+ return TRUE;
+}
+?>

Added: xdebug/branches/xdebug_2_1/tests/bug00643-t2.inc
===================================================================
--- xdebug/branches/xdebug_2_1/tests/bug00643-t2.inc (rev 0)
+++ xdebug/branches/xdebug_2_1/tests/bug00643-t2.inc 2011-03-21 20:39:56 UTC (rev 3415)
@@ -0,0 +1,15 @@
+<?php
+
+
+
+
+
+
+
+
+function errors_fatal($a)
+{
+ count($a) && is_array($a);
+ return FALSE;
+}
+?>

Added: xdebug/branches/xdebug_2_1/tests/bug00643.phpt
===================================================================
--- xdebug/branches/xdebug_2_1/tests/bug00643.phpt (rev 0)
+++ xdebug/branches/xdebug_2_1/tests/bug00643.phpt 2011-03-21 20:39:56 UTC (rev 3415)
@@ -0,0 +1,73 @@
+--TEST--
+Test for bug #643: Profiler gets line numbers wrong
+--INI--
+xdebug.profiler_enable=1
+--FILE--
+<?php
+require_once('bug00643-t1.inc');
+
+$a = array("testing");
+
+t1();
+echo file_get_contents(xdebug_get_profiler_filename());
+?>
+--EXPECTF--
+version: 1
+creator: xdebug 2.%s
+cmd: %sbug00643.php
+part: 1
+positions: line
+
+events: Time
+
+fl=%sbug00643-t2.inc
+fn=require_once::%sbug00643-t2.inc
+1 %d
+
+fl=%sbug00643-t1.inc
+fn=require_once::%sbug00643-t1.inc
+1 %d
+cfl=%sbug00643-t2.inc
+cfn=require_once::%sbug00643-t2.inc
+calls=1 0 0
+2 %d
+
+fl=php:internal
+fn=php::count
+23 %d
+
+fl=php:internal
+fn=php::count
+12 %d
+
+fl=php:internal
+fn=php::is_array
+12 %d
+
+fl=%sbug00643-t2.inc
+fn=errors_fatal
+10 %d
+cfl=php:internal
+cfn=php::count
+calls=1 0 0
+12 %d
+cfl=php:internal
+cfn=php::is_array
+calls=1 0 0
+12 %d
+
+fl=%sbug00643-t1.inc
+fn=t1
+20 %d
+cfl=php:internal
+cfn=php::count
+calls=1 0 0
+23 %d
+cfl=%sbug00643-t2.inc
+cfn=errors_fatal
+calls=1 0 0
+23 %d
+
+fl=php:internal
+fn=php::xdebug_get_profiler_filename
+7 %d

Modified: xdebug/branches/xdebug_2_1/xdebug_profiler.c
===================================================================
--- xdebug/branches/xdebug_2_1/xdebug_profiler.c 2011-03-21 20:09:20 UTC (rev 3414)
+++ xdebug/branches/xdebug_2_1/xdebug_profiler.c 2011-03-21 20:39:56 UTC (rev 3415)
@@ -82,7 +82,9 @@
         if (XG(profiler_append)) {
                 fprintf(XG(profile_file), "\n==== NEW PROFILING FILE ==============================================\n");
         }
- fprintf(XG(profile_file), "version: 0.9.6\ncmd: %s\npart: 1\n\nevents: Time\n\n", script_name);
+ fprintf(XG(profile_file), "version: 1\ncreator: xdebug %s\n", XDEBUG_VERSION);
+ fprintf(XG(profile_file), "cmd: %s\npart: 1\npositions: line\n\n", script_name);
+ fprintf(XG(profile_file), "events: Time\n\n");
         fflush(XG(profile_file));
         return SUCCESS;
 }
@@ -146,13 +148,20 @@
                         break;

                 default:
- default_lineno = fse->lineno;
+ if (op_array) {
+ default_lineno = op_array->line_start;
+ } else {
+ default_lineno = fse->lineno;
+ }
                         break;
         }
+ if (default_lineno == 0) {
+ default_lineno = 1;
+ }

         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;
@@ -203,8 +212,10 @@
                 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);
                 }

Received on Mon Mar 21 2011 - 20:39:56 GMT

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