From 8cfb8ccc1ac82db1990dfadf7526081e46c2cb78 Mon Sep 17 00:00:00 2001 From: Sigurd Schneider Date: Thu, 31 Oct 2019 15:00:35 +0100 Subject: [PATCH] [heap-profiler] Offer additional reveal options This CL enables the context menu of the heap profiler's summary view for snapshots to display additional reveal options, if the back-end indicated them in a suitable form. This is the most light-weight way to simplify debugging of retainment chains that involve WeakMaps. Bug: chromium:1020096 Change-Id: Ie79977e5e3899b3eee71e618104e48d640707c78 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1893075 Commit-Queue: Sigurd Schneider Reviewed-by: Jan Scheffler --- front_end/profiler/HeapSnapshotDataGrids.js | 9 +++++++++ front_end/profiler/profiler_strings.grdp | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/front_end/profiler/HeapSnapshotDataGrids.js b/front_end/profiler/HeapSnapshotDataGrids.js index ee5783d391..b3a39877d5 100644 --- a/front_end/profiler/HeapSnapshotDataGrids.js +++ b/front_end/profiler/HeapSnapshotDataGrids.js @@ -146,6 +146,15 @@ Profiler.HeapSnapshotSortableDataGrid = class extends DataGrid.DataGrid { contextMenu.revealSection().appendItem(ls`Reveal in Summary view`, () => { this._dataDisplayDelegate.showObject(node.snapshotNodeId, ls`Summary`); }); + if (node._referenceName) { + for (const match of node._referenceName.matchAll(/\((?[^@)]*) @(?\d+)\)/g)) { + const {objectName, snapshotNodeId} = /** @type {!{objectName:string, snapshotNodeId:string}} */ (match.groups); + contextMenu.revealSection().appendItem( + ls`Reveal object '${objectName}' with id @${snapshotNodeId} in Summary view`, () => { + this._dataDisplayDelegate.showObject(snapshotNodeId, ls`Summary`); + }); + } + } if (gridNode.linkElement && !contextMenu.containsTarget(gridNode.linkElement)) { contextMenu.appendApplicableItems(gridNode.linkElement); } diff --git a/front_end/profiler/profiler_strings.grdp b/front_end/profiler/profiler_strings.grdp index 81163ae4b0..a0c63f7c9a 100644 --- a/front_end/profiler/profiler_strings.grdp +++ b/front_end/profiler/profiler_strings.grdp @@ -21,6 +21,9 @@ Snapshot $1d1 + + Reveal object '$1sSomeClassConstructor' with id @$2s12345 in Summary view + Renderer @@ -430,4 +433,4 @@ Total Size (bytes) - \ No newline at end of file +