summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlpha <ngcoder@live.com>2015-07-23 16:19:00 -0400
committerAlpha <ngcoder@live.com>2015-07-23 16:44:48 -0400
commit26cd17bfd1b544dae6e4f1dd2f771610dfa6dc82 (patch)
tree48c6e82564d9f75600ba79f78aa2f9d2b24a3ffc
parent8c5cddb9712a24eab606e4ed7c5affcdc8dac5c6 (diff)
parent5155395152a3ab23f38ca8d403a34ef04003102a (diff)
downloadwebgrind-26cd17bfd1b544dae6e4f1dd2f771610dfa6dc82.zip
webgrind-26cd17bfd1b544dae6e4f1dd2f771610dfa6dc82.tar.gz
webgrind-26cd17bfd1b544dae6e4f1dd2f771610dfa6dc82.tar.bz2
Merge pull request #68 from bionoren/xdebug23
Support for XDebug 2.3 function/file name compression in calls/called by and top level names.
-rw-r--r--library/Preprocessor.php26
1 files changed, 23 insertions, 3 deletions
diff --git a/library/Preprocessor.php b/library/Preprocessor.php
index 2291006..1366848 100644
--- a/library/Preprocessor.php
+++ b/library/Preprocessor.php
@@ -5,7 +5,7 @@
* Information from the callgrind file is extracted and written in a binary format for
* fast random access.
*
- * @see http://code.google.com/p/webgrind/wiki/PreprocessedFormat
+ * @see https://github.com/jokkedk/webgrind/wiki/Preprocessed-Format
* @see http://valgrind.org/docs/manual/cl-format.html
* @package Webgrind
* @author Jacob Oettinger
@@ -61,6 +61,7 @@ class Webgrind_Preprocessor
if (substr($line,0,3)==='fl=') {
// Found invocation of function. Read functionname
fscanf($in,"fn=%[^\n\r]s",$function);
+ $function = self::getCompressedName($function, false);
// Special case for ENTRY_POINT - it contains summary header
if (self::ENTRY_POINT == $function) {
fgets($in);
@@ -74,7 +75,7 @@ class Webgrind_Preprocessor
$index = $nextFuncNr++;
$functionNames[$function] = $index;
$functions[$index] = array(
- 'filename' => substr(trim($line),3),
+ 'filename' => self::getCompressedName(substr(trim($line),3), true),
'line' => $lnr,
'invocationCount' => 1,
'summedSelfCost' => $cost,
@@ -90,7 +91,7 @@ class Webgrind_Preprocessor
}
} else if (substr($line,0,4)==='cfn=') {
// Found call to function. ($function should contain function call originates from)
- $calledFunctionName = substr(trim($line),4);
+ $calledFunctionName = self::getCompressedName(substr(trim($line),4), false);
// Skip call line
fgets($in);
// Cost line
@@ -162,4 +163,23 @@ class Webgrind_Preprocessor
}
}
+ /**
+ * Extract information from $inFile and store in preprocessed form in $outFile
+ *
+ * @param string $name String to parse (either a filename or function name line)
+ * @param int $isFile True if this is a filename line (since files and functions have their own symbol tables)
+ * @return void
+ **/
+ static function getCompressedName($name, $isFile) {
+ global $compressedNames;
+ if (!preg_match("/\((\d+)\)(.+)?/", $name, $matches)) {
+ return $name;
+ }
+ $functionIndex = $matches[1];
+ if (!isset($compressedNames[$isFile][$functionIndex]) || isset($matches[2])) {
+ $compressedNames[$isFile][$functionIndex] = trim($matches[2]);
+ }
+ return $compressedNames[$isFile][$functionIndex];
+ }
+
}