diff options
author | Bion Oren <bion@modopayments.com> | 2015-04-15 11:54:16 -0500 |
---|---|---|
committer | Bion Oren <bion@modopayments.com> | 2015-04-15 11:54:54 -0500 |
commit | 3a8b2a3c550d9ae1358026de20db9ea0127a7275 (patch) | |
tree | b36cf49b7881cdc656c0e93211f870a75e5b4410 | |
parent | 077f79f13ddc8efa4cb10c2c041eb4b50037e0e3 (diff) | |
download | webgrind-3a8b2a3c550d9ae1358026de20db9ea0127a7275.zip webgrind-3a8b2a3c550d9ae1358026de20db9ea0127a7275.tar.gz webgrind-3a8b2a3c550d9ae1358026de20db9ea0127a7275.tar.bz2 |
Added support to the preprocessor for function name compression in xdebug 2.3.x (cf. http://valgrind.org/docs/manual/cl-format.html#cl-format.overview.compression1).
Fixes #62. Based on work by MoleDJ at https://github.com/MoleDJ/webgrind/commit/516832571b154f093c512709ccef7c1f7bae9bba
-rw-r--r-- | library/Preprocessor.php | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/library/Preprocessor.php b/library/Preprocessor.php index b29581c..7f7714a 100644 --- a/library/Preprocessor.php +++ b/library/Preprocessor.php @@ -62,9 +62,10 @@ class Webgrind_Preprocessor if(substr($line,0,3)==='fl='){ // Found invocation of function. Read functionname list($function) = fscanf($in,"fn=%[^\n\r]s"); + $function = self::getCompressedName($function, 0); if(!isset($functions[$function])){ $functions[$function] = array( - 'filename' => substr(trim($line),3), + 'filename' => self::getCompressedName(substr(trim($line),3), 1), 'invocationCount' => 0, 'nr' => $nextFuncNr++, 'count' => 0, @@ -89,7 +90,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), 0); // Skip call line fgets($in); // Cost line @@ -157,5 +158,23 @@ class Webgrind_Preprocessor } } - + + protected static function getCompressedName($name, $type=0) + { + global $compressedNames; + if(preg_match("/\((\d+)\)(.+)?/", $name, $matches)) + { + $functionIndex = $matches[1]; + if(isset($compressedNames[$type][$functionIndex]) && isset($matches[2]) == false) + { + $name = $compressedNames[$type][$functionIndex]; + } + else + { + $name = trim($matches[2]); + $compressedNames[$type][$functionIndex] = $name; + } + } + return $name; + } } |