Commit b9baaa49 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

DevTools: improve regexp to source map stack traces

R=luoe@chromium.org

Bug: chromium:973782
Change-Id: I233a4c8d971396247c9a4391f399eaf0ad1f662b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1702268
Auto-Submit: Yang Guo <yangguo@chromium.org>
Reviewed-by: default avatarErik Luo <luoe@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678586}
parent 9e7e457d
......@@ -1432,10 +1432,19 @@ Console.ConsoleViewMessage = class {
let openBracketIndex = -1;
let closeBracketIndex = -1;
const match = /\([^\)\(]+\)/.exec(lines[i]);
if (match) {
openBracketIndex = match.index;
closeBracketIndex = match.index + match[0].length - 1;
const inBracketsWithLineAndColumn = /\([^\)\(]+:\d+:\d+\)/g;
const inBrackets = /\([^\)\(]+\)/g;
let lastMatch = null;
let currentMatch;
while ((currentMatch = inBracketsWithLineAndColumn.exec(lines[i])))
lastMatch = currentMatch;
if (!lastMatch) {
while ((currentMatch = inBrackets.exec(lines[i])))
lastMatch = currentMatch;
}
if (lastMatch) {
openBracketIndex = lastMatch.index;
closeBracketIndex = lastMatch.index + lastMatch[0].length - 1;
}
const hasOpenBracket = openBracketIndex !== -1;
const left = hasOpenBracket ? openBracketIndex + 1 : lines[i].indexOf('at') + 3;
......
......@@ -60,8 +60,10 @@ console-log-linkify-…ack-in-errors.js:68 Error broken stack #5
at function_name foob.js:20:30)
console-log-linkify-…ack-in-errors.js:69 Error broken stack #6
at foob.js foob.js:40
stack-with-sourceMap.coffee:3 Error
at Failure.letsFailWithStack (stack-with-sourceMap.coffee:3)
at window.failure (stack-with-sourceMap.coffee:7)
stack-with-sourceMap.coffee:2 Error
at letsFailWithStack(a:1:2) (stack-with-sourceMap.coffee:2)
at eval (eval at letsFailWithStackInEval (stack-with-sourceMap.coffee:8), <anonymous>:1:1)
at Failure.letsFailWithStackInEval(a) [as letsFailWithStackInEval] (stack-with-sourceMap.coffee:8)
at window.failure (stack-with-sourceMap.coffee:13)
at <anonymous>:1:1
window.letsFailWithStack = ->
console.log((new Error()).stack)
window.letsFailWithStack.displayName = "letsFailWithStack(a:1:2)"
class Failure
letsFailWithStack: ->
console.log((new Error()).stack)
letsFailWithStackInEval: ->
eval("letsFailWithStack()");
window.failure = () ->
window.failure = ->
failure = new Failure
failure.letsFailWithStack()
failure.letsFailWithStackInEval.displayName = "letsFailWithStackInEval(a)"
failure.letsFailWithStackInEval()
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 2.4.1
(function() {
var Failure;
Failure = (function() {
function Failure() {}
window.letsFailWithStack = function() {
return console.log((new Error()).stack);
};
Failure.prototype.letsFailWithStack = function() {
return console.log((new Error()).stack);
};
window.letsFailWithStack.displayName = "letsFailWithStack(a:1:2)";
return Failure;
Failure = class Failure {
letsFailWithStackInEval() {
return eval("letsFailWithStack()");
}
})();
};
window.failure = function() {
var failure;
failure = new Failure;
return failure.letsFailWithStack();
failure.letsFailWithStackInEval.displayName = "letsFailWithStackInEval(a)";
return failure.letsFailWithStackInEval();
};
}).call(this);
......
......@@ -6,5 +6,8 @@
"stack-with-sourceMap.coffee"
],
"names": [],
"mappings": ";AAAA;AAAA,MAAA,OAAA;;AAAA,EAAM;yBACF;;AAAA,sBAAA,iBAAA,GAAmB,SAAA,GAAA;aACf,OAAO,CAAC,GAAR,CAAY,CAAK,IAAA,KAAA,CAAA,CAAL,CAAa,CAAC,KAA1B,EADe;IAAA,CAAnB,CAAA;;mBAAA;;MADJ,CAAA;;AAAA,EAIA,MAAM,CAAC,OAAP,GAAiB,SAAA,GAAA;AACb,QAAA,OAAA;AAAA,IAAA,OAAA,GAAU,GAAA,CAAA,OAAV,CAAA;WACA,OAAO,CAAC,iBAAR,CAAA,EAFa;EAAA,CAJjB,CAAA;AAAA"
"mappings": ";AAAA;AAAA,MAAA;;EAAA,MAAM,CAAC,iBAAP,GAA2B,QAAA,CAAA,CAAA;WACvB,OAAO,CAAC,GAAR,CAAY,CAAC,IAAI,KAAJ,CAAA,CAAD,CAAa,CAAC,KAA1B;EADuB;;EAG3B,MAAM,CAAC,iBAAiB,CAAC,WAAzB,GAAuC;;EAEjC,UAAN,MAAA,QAAA;IACI,uBAAyB,CAAA,CAAA;aACrB,IAAA,CAAK,qBAAL;IADqB;;EAD7B;;EAIA,MAAM,CAAC,OAAP,GAAiB,QAAA,CAAA,CAAA;AACb,QAAA;IAAA,OAAA,GAAU,IAAI;IACd,OAAO,CAAC,uBAAuB,CAAC,WAAhC,GAA8C;WAC9C,OAAO,CAAC,uBAAR,CAAA;EAHa;AATjB",
"sourcesContent": [
"window.letsFailWithStack = ->\n console.log((new Error()).stack)\n\nwindow.letsFailWithStack.displayName = \"letsFailWithStack(a:1:2)\"\n\nclass Failure\n letsFailWithStackInEval: ->\n eval(\"letsFailWithStack()\");\n\nwindow.failure = ->\n failure = new Failure\n failure.letsFailWithStackInEval.displayName = \"letsFailWithStackInEval(a)\"\n failure.letsFailWithStackInEval()\n"
]
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment