Skip to content

Commit 81eb713

Browse files
committed
Add upgraders for all the source table changes
1 parent a69ba55 commit 81eb713

File tree

8 files changed

+164
-51
lines changed

8 files changed

+164
-51
lines changed

docs-developer/CHANGELOG-formats.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Note that this is not an exhaustive list. Processed profile format upgraders can
66

77
## Processed profile format
88

9+
### Version 61
10+
11+
The `SourceTable` in `profile.shared.sources` was updated:
12+
13+
- The `uuid` field was renamed to `id`.
14+
- Two new fields `startLine` and `startColumn` were added (1-based, defaulting to 1). These describe the start position of the script within its resource, useful for inline scripts.
15+
- A new `sourceMapURL` field was added (defaulting to `null`).
16+
917
### Version 60
1018

1119
The following tables have moved into `profile.shared`: `stackTable`, `frameTable`, `funcTable`, `resourceTable`, `nativeSymbols`. They are no longer per-thread.
@@ -137,6 +145,14 @@ Older versions are not documented in this changelog but can be found in [process
137145

138146
## Gecko profile format
139147

148+
### Version 34
149+
150+
The `SourceTable` schema was updated:
151+
152+
- The `uuid` field was renamed to `id`.
153+
- Two new fields `startLine` and `startColumn` were added (1-based, defaulting to 1).
154+
- A new `sourceMapURL` field was added (defaulting to `null`).
155+
140156
### Version 33
141157

142158
The `sources` field in the Gecko profile format is now non-optional. An upgrader was added that creates an empty `SourceTable` for profiles that don't have one.

src/app-logic/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import type { MarkerPhase } from 'firefox-profiler/types';
77
// The current version of the Gecko profile format.
88
// Please don't forget to update the gecko profile format changelog in
99
// `docs-developer/CHANGELOG-formats.md`.
10-
export const GECKO_PROFILE_VERSION = 33;
10+
export const GECKO_PROFILE_VERSION = 34;
1111

1212
// The current version of the "processed" profile format.
1313
// Please don't forget to update the processed profile format changelog in
1414
// `docs-developer/CHANGELOG-formats.md`.
15-
export const PROCESSED_PROFILE_VERSION = 60;
15+
export const PROCESSED_PROFILE_VERSION = 61;
1616

1717
// The following are the margin sizes for the left and right of the timeline. Independent
1818
// components need to share these values.

src/profile-logic/gecko-profile-versioning.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,38 @@ const _upgraders: {
15221522
convertToVersion33Recursive(profile);
15231523
},
15241524

1525+
[34]: (profile: any) => {
1526+
// The source table schema was updated:
1527+
// - The "uuid" field was renamed to "id".
1528+
// - startLine and startColumn are added, defaulting to 1 as they are 1-based.
1529+
// - sourceMapURL was added, defaulting to null.
1530+
function convertToVersion34Recursive(p: any) {
1531+
if (p.sources) {
1532+
const schema = p.sources.schema;
1533+
1534+
schema.id = schema.uuid;
1535+
delete schema.uuid;
1536+
1537+
// Set the canonical indices for the new required fields and fill the
1538+
// arrays with default values.
1539+
schema.startLine = 2;
1540+
schema.startColumn = 3;
1541+
schema.sourceMapURL = 4;
1542+
1543+
for (const row of p.sources.data) {
1544+
row[2] = 1;
1545+
row[3] = 1;
1546+
row[4] = null;
1547+
}
1548+
}
1549+
1550+
for (const subprocessProfile of p.processes) {
1551+
convertToVersion34Recursive(subprocessProfile);
1552+
}
1553+
}
1554+
convertToVersion34Recursive(profile);
1555+
},
1556+
15251557
// If you add a new upgrader here, please document the change in
15261558
// `docs-developer/CHANGELOG-formats.md`.
15271559
};

src/profile-logic/processed-profile-versioning.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,26 @@ const _upgraders: {
30293029
profile.shared.nativeSymbols = newNativeSymbols;
30303030
upgradeInfo.v60 = { threadMappings, newFuncCount: newFuncTable.length };
30313031
},
3032+
3033+
[61]: (profile: any) => {
3034+
// The source table schema was updated:
3035+
// - The "uuid" field was renamed to "id". Profiles stored at v58-60 before
3036+
// this rename may still have the old "uuid" field name.
3037+
// - startLine and startColumn were added, defaulting to 1 as they are 1-based.
3038+
// - sourceMapURL was added, defaulting to null.
3039+
const sources = profile.shared && profile.shared.sources;
3040+
if (sources) {
3041+
if (sources.uuid !== undefined && sources.id === undefined) {
3042+
sources.id = sources.uuid;
3043+
delete sources.uuid;
3044+
}
3045+
const length = sources.length;
3046+
sources.startLine = new Array(length).fill(1);
3047+
sources.startColumn = new Array(length).fill(1);
3048+
sources.sourceMapURL = new Array(length).fill(null);
3049+
}
3050+
},
3051+
30323052
// If you add a new upgrader here, please document the change in
30333053
// `docs-developer/CHANGELOG-formats.md`.
30343054
};

src/test/integration/symbolicator-cli/__snapshots__/symbolicator-cli.test.ts.snap

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Object {
8787
"markerSchema": Array [],
8888
"oscpu": "macOS 14.6.1",
8989
"pausedRanges": Array [],
90-
"preprocessedProfileVersion": 60,
90+
"preprocessedProfileVersion": 61,
9191
"processType": 0,
9292
"product": "a.out",
9393
"sampleUnits": Object {
@@ -727,6 +727,9 @@ Object {
727727
"filename": Array [],
728728
"id": Array [],
729729
"length": 0,
730+
"sourceMapURL": Array [],
731+
"startColumn": Array [],
732+
"startLine": Array [],
730733
},
731734
"stackTable": Object {
732735
"frame": Array [
@@ -1412,7 +1415,7 @@ Object {
14121415
"markerSchema": Array [],
14131416
"oscpu": "macOS 14.6.1",
14141417
"pausedRanges": Array [],
1415-
"preprocessedProfileVersion": 60,
1418+
"preprocessedProfileVersion": 61,
14161419
"processType": 0,
14171420
"product": "a.out",
14181421
"sampleUnits": Object {
@@ -2052,6 +2055,9 @@ Object {
20522055
"filename": Array [],
20532056
"id": Array [],
20542057
"length": 0,
2058+
"sourceMapURL": Array [],
2059+
"startColumn": Array [],
2060+
"startLine": Array [],
20552061
},
20562062
"stackTable": Object {
20572063
"frame": Array [

src/test/store/__snapshots__/profile-view.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,15 @@ Object {
418418
"oscpu": "",
419419
"physicalCPUs": 0,
420420
"platform": "",
421-
"preprocessedProfileVersion": 60,
421+
"preprocessedProfileVersion": 61,
422422
"processType": 0,
423423
"product": "Firefox",
424424
"sourceURL": "",
425425
"stackwalk": 0,
426426
"startTime": 0,
427427
"symbolicated": true,
428428
"toolkit": "",
429-
"version": 33,
429+
"version": 34,
430430
},
431431
"pages": Array [
432432
Object {

0 commit comments

Comments
 (0)