mirror of
https://github.com/jlfwong/speedscope.git
synced 2024-11-22 22:14:25 +03:00
Normalize line & column numbers to be 1-based in Chrome & Firefox imports (#318)
This also fixes a dumb bug in the Firefox import that just completely failed to import column numbers.
This commit is contained in:
parent
8a4f38a8cb
commit
16e32dc08e
File diff suppressed because it is too large
Load Diff
@ -64,17 +64,17 @@ exports[`importFromFirefox ignore self-hosted 1`] = `
|
||||
Object {
|
||||
"frames": Array [
|
||||
Frame {
|
||||
"col": undefined,
|
||||
"file": "http://localhost:8000/simple.js:1",
|
||||
"col": 15,
|
||||
"file": "http://localhost:8000/simple.js",
|
||||
"key": "alpha (http://localhost:8000/simple.js:1:14)",
|
||||
"line": 14,
|
||||
"line": 1,
|
||||
"name": "alpha",
|
||||
"selfWeight": 0,
|
||||
"totalWeight": 26.983816999942064,
|
||||
},
|
||||
Frame {
|
||||
"col": undefined,
|
||||
"file": "http://localhost:8000/simple.js:14",
|
||||
"col": 15,
|
||||
"file": "http://localhost:8000/simple.js",
|
||||
"key": "delta (http://localhost:8000/simple.js:14:14)",
|
||||
"line": 14,
|
||||
"name": "delta",
|
||||
@ -82,19 +82,19 @@ Object {
|
||||
"totalWeight": 11.946324001066387,
|
||||
},
|
||||
Frame {
|
||||
"col": undefined,
|
||||
"file": "http://localhost:8000/simple.js:20",
|
||||
"col": 15,
|
||||
"file": "http://localhost:8000/simple.js",
|
||||
"key": "gamma (http://localhost:8000/simple.js:20:14)",
|
||||
"line": 14,
|
||||
"line": 20,
|
||||
"name": "gamma",
|
||||
"selfWeight": 26.983816999942064,
|
||||
"totalWeight": 26.983816999942064,
|
||||
},
|
||||
Frame {
|
||||
"col": undefined,
|
||||
"file": "http://localhost:8000/simple.js:8",
|
||||
"col": 14,
|
||||
"file": "http://localhost:8000/simple.js",
|
||||
"key": "beta (http://localhost:8000/simple.js:8:13)",
|
||||
"line": 13,
|
||||
"line": 8,
|
||||
"name": "beta",
|
||||
"selfWeight": 0,
|
||||
"totalWeight": 15.037492998875678,
|
||||
|
@ -170,8 +170,17 @@ function frameInfoForCallFrame(callFrame: CPUProfileCallFrame) {
|
||||
return getOrInsert(callFrameToFrameInfo, callFrame, callFrame => {
|
||||
const name = callFrame.functionName || '(anonymous)'
|
||||
const file = callFrame.url
|
||||
const line = callFrame.lineNumber
|
||||
const col = callFrame.columnNumber
|
||||
|
||||
// In Chrome profiles, line numbers & column numbers are both 0-indexed.
|
||||
//
|
||||
// We're going to normalize these to be 1-based to avoid needing to normalize
|
||||
// these at the presentation layer.
|
||||
let line = callFrame.lineNumber
|
||||
if (line != null) line++
|
||||
|
||||
let col = callFrame.columnNumber
|
||||
if (col != null) col++
|
||||
|
||||
return {
|
||||
key: `${name}:${file}:${line}:${col}`,
|
||||
name,
|
||||
|
@ -176,7 +176,7 @@ export function importFromFirefox(firefoxProfile: FirefoxProfile): Profile {
|
||||
const frameData = thread.frameTable.data[f]
|
||||
const location = thread.stringTable[frameData[0]]
|
||||
|
||||
const match = /(.*)\s+\((.*?):?(\d+)?\)$/.exec(location)
|
||||
const match = /(.*)\s+\((.*?)(?::(\d+))?(?::(\d+))?\)$/.exec(location)
|
||||
|
||||
if (!match) return null
|
||||
|
||||
@ -193,7 +193,11 @@ export function importFromFirefox(firefoxProfile: FirefoxProfile): Profile {
|
||||
key: location,
|
||||
name: match[1]!,
|
||||
file: match[2]!,
|
||||
|
||||
// In Firefox profiles, line numbers are 1-based, but columns are
|
||||
// 0-based. Let's normalize both to be 1-based.
|
||||
line: match[3] ? parseInt(match[3]) : undefined,
|
||||
col: match[4] ? parseInt(match[4]) + 1 : undefined,
|
||||
}))
|
||||
})
|
||||
.filter(f => f != null) as FrameInfo[]
|
||||
|
@ -68,9 +68,9 @@ class StackTraceView extends Component<StackTraceViewProps, {}> {
|
||||
|
||||
if (frame.file) {
|
||||
let pos = frame.file
|
||||
if (frame.line) {
|
||||
if (frame.line != null) {
|
||||
pos += `:${frame.line}`
|
||||
if (frame.col) {
|
||||
if (frame.col != null) {
|
||||
pos += `:${frame.col}`
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user