From 46c2d8c49e41a4cef39dc769e6d3c312f9a3a8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Fri, 18 Sep 2015 13:49:24 +0200 Subject: [PATCH] Fix backtraces in the profiler when using PhantomJS 2 --- .../src/js/directives/offendersDirectives.js | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/front/src/js/directives/offendersDirectives.js b/front/src/js/directives/offendersDirectives.js index d122393..3ed389a 100644 --- a/front/src/js/directives/offendersDirectives.js +++ b/front/src/js/directives/offendersDirectives.js @@ -608,7 +608,12 @@ for (var i = 0 ; i < parsedBacktrace.length ; i++) { html += '
'; html += '
' + (parsedBacktrace[i].fnName || '(anonymous function)') + '
'; - html += '
' + getUrlLink(parsedBacktrace[i].filePath, 40) + ':' + parsedBacktrace[i].line + '
'; + html += '
' + getUrlLink(parsedBacktrace[i].filePath, 40) + '
'; + if (parsedBacktrace[i].column) { + html += '
' + parsedBacktrace[i].line + ':' + parsedBacktrace[i].column + '
'; + } else { + html += '
line ' + parsedBacktrace[i].line + '
'; + } html += '
'; } } @@ -630,6 +635,17 @@ var fnName = null, fileAndLine; var withFnResult = /^([^\s\(]+) \((.+:\d+)\)$/.exec(trace); + + if (withFnResult === null) { + // Try the PhantomJS 2 format + withFnResult = /^([^\s\(]+) \((.+:\d+:\d+)\)$/.exec(trace); + } + + if (withFnResult === null) { + // Try the PhantomJS 2 ERROR format + withFnResult = /^([^\s\(]+) (http.+:\d+)$/.exec(trace); + } + if (withFnResult === null) { fileAndLine = trace; } else { @@ -637,14 +653,22 @@ fileAndLine = withFnResult[2]; } - var fileAndLineSplit = /^(.*):(\d+)$/.exec(fileAndLine); + // And now the second part + var fileAndLineSplit = /^(.*):(\d+):(\d+)$/.exec(fileAndLine); + + if (fileAndLineSplit === null) { + fileAndLineSplit = /^(.*):(\d+)$/.exec(fileAndLine); + } + var filePath = fileAndLineSplit[1]; var line = fileAndLineSplit[2]; + var column = fileAndLineSplit[3]; out.push({ fnName: fnName, filePath: filePath, - line: line + line: line, + column: column }); });