Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/actions/profile-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import type {
KeyboardModifiers,
TableViewOptions,
SelectionContext,
BottomBoxInfo,
} from 'firefox-profiler/types';
import {
funcHasDirectRecursiveCall,
Expand Down Expand Up @@ -1948,11 +1949,35 @@ export function changeTableViewOptions(
};
}

export function openSourceView(file: string, currentTab: TabSlug): Action {
export function updateBottomBoxContentsAndMaybeOpen(
currentTab: TabSlug,
{ libIndex, sourceFile, nativeSymbols }: BottomBoxInfo
): Action {
// TODO: If the set has more than one element, pick the native symbol with
// the highest total sample count
const nativeSymbol = nativeSymbols.length !== 0 ? nativeSymbols[0] : null;

return {
type: 'OPEN_SOURCE_VIEW',
file,
type: 'UPDATE_BOTTOM_BOX',
libIndex,
sourceFile,
nativeSymbol,
allNativeSymbolsForInitiatingCallNode: nativeSymbols,
currentTab,
shouldOpenBottomBox: sourceFile !== null || nativeSymbol !== null,
shouldOpenAssemblyView: sourceFile === null && nativeSymbol !== null,
};
}

export function openAssemblyView(): Action {
return {
type: 'OPEN_ASSEMBLY_VIEW',
};
}

export function closeAssemblyView(): Action {
return {
type: 'CLOSE_ASSEMBLY_VIEW',
};
}

Expand Down
17 changes: 13 additions & 4 deletions src/app-logic/url-handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import type {
ThreadIndex,
TimelineType,
SourceViewState,
AssemblyViewState,
} from 'firefox-profiler/types';
import {
decodeUintArrayFromUrlComponent,
Expand Down Expand Up @@ -411,8 +412,8 @@ export function getQueryStringFromUrlState(urlState: UrlState): string {
: urlState.profileSpecific.lastSelectedCallTreeSummaryStrategy;
const { sourceView, isBottomBoxOpenPerPanel } = urlState.profileSpecific;
query.sourceView =
sourceView.file !== null && isBottomBoxOpenPerPanel[selectedTab]
? sourceView.file
sourceView.sourceFile !== null && isBottomBoxOpenPerPanel[selectedTab]
? sourceView.sourceFile
: undefined;
break;
}
Expand Down Expand Up @@ -576,12 +577,19 @@ export function stateFromLocation(
toValidTabSlug(pathParts[selectedTabPathPart]) || 'calltree';
const sourceView: SourceViewState = {
activationGeneration: 0,
file: null,
libIndex: null,
sourceFile: null,
};
const assemblyView: AssemblyViewState = {
isOpen: false,
activationGeneration: 0,
nativeSymbol: null,
allNativeSymbolsForInitiatingCallNode: [],
};
const isBottomBoxOpenPerPanel = {};
tabSlugs.forEach((tabSlug) => (isBottomBoxOpenPerPanel[tabSlug] = false));
if (query.sourceView) {
sourceView.file = query.sourceView;
sourceView.sourceFile = query.sourceView;
isBottomBoxOpenPerPanel[selectedTab] = true;
}

Expand Down Expand Up @@ -617,6 +625,7 @@ export function stateFromLocation(
networkSearchString: query.networkSearch || '',
transforms,
sourceView,
assemblyView,
isBottomBoxOpenPerPanel,
timelineType: validateTimelineType(query.timelineType),
full: {
Expand Down
15 changes: 6 additions & 9 deletions src/components/calltree/CallTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {
changeExpandedCallNodes,
addTransformToStack,
handleCallNodeTransformShortcut,
openSourceView,
changeTableViewOptions,
updateBottomBoxContentsAndMaybeOpen,
} from 'firefox-profiler/actions/profile-view';
import { assertExhaustiveCheck } from 'firefox-profiler/utils/flow';

Expand Down Expand Up @@ -82,7 +82,7 @@ type DispatchProps = {|
+changeExpandedCallNodes: typeof changeExpandedCallNodes,
+addTransformToStack: typeof addTransformToStack,
+handleCallNodeTransformShortcut: typeof handleCallNodeTransformShortcut,
+openSourceView: typeof openSourceView,
+updateBottomBoxContentsAndMaybeOpen: typeof updateBottomBoxContentsAndMaybeOpen,
+onTableViewOptionsChange: (TableViewOptions) => any,
|};

Expand Down Expand Up @@ -289,12 +289,9 @@ class CallTreeImpl extends PureComponent<Props> {
};

_onEnterOrDoubleClick = (nodeId: IndexIntoCallNodeTable) => {
const { tree, openSourceView } = this.props;
const file = tree.getRawFileNameForCallNode(nodeId);
if (file === null) {
return;
}
openSourceView(file, 'calltree');
const { tree, updateBottomBoxContentsAndMaybeOpen } = this.props;
const bottomBoxInfo = tree.getBottomBoxInfoForCallNode(nodeId);
updateBottomBoxContentsAndMaybeOpen('calltree', bottomBoxInfo);
};

maybeProcureInterestingInitialSelection() {
Expand Down Expand Up @@ -431,7 +428,7 @@ export const CallTree = explicitConnect<{||}, StateProps, DispatchProps>({
changeExpandedCallNodes,
addTransformToStack,
handleCallNodeTransformShortcut,
openSourceView,
updateBottomBoxContentsAndMaybeOpen,
onTableViewOptionsChange: (options: TableViewOptions) =>
changeTableViewOptions('calltree', options),
},
Expand Down
27 changes: 11 additions & 16 deletions src/components/flame-graph/FlameGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
changeSelectedCallNode,
changeRightClickedCallNode,
handleCallNodeTransformShortcut,
openSourceView,
updateBottomBoxContentsAndMaybeOpen,
} from 'firefox-profiler/actions/profile-view';

import type {
Expand Down Expand Up @@ -96,7 +96,7 @@ type DispatchProps = {|
+changeSelectedCallNode: typeof changeSelectedCallNode,
+changeRightClickedCallNode: typeof changeRightClickedCallNode,
+handleCallNodeTransformShortcut: typeof handleCallNodeTransformShortcut,
+openSourceView: typeof openSourceView,
+updateBottomBoxContentsAndMaybeOpen: typeof updateBottomBoxContentsAndMaybeOpen,
|};
type Props = ConnectedProps<{||}, StateProps, DispatchProps>;

Expand Down Expand Up @@ -131,16 +131,15 @@ class FlameGraphImpl extends React.PureComponent<Props> {
);
};

_onCallNodeDoubleClick = (callNodeIndex: IndexIntoCallNodeTable | null) => {
_onCallNodeEnterOrDoubleClick = (
callNodeIndex: IndexIntoCallNodeTable | null
) => {
if (callNodeIndex === null) {
return;
}
const { callTree, openSourceView } = this.props;
const file = callTree.getRawFileNameForCallNode(callNodeIndex);
if (file === null) {
return;
}
openSourceView(file, 'flame-graph');
const { callTree, updateBottomBoxContentsAndMaybeOpen } = this.props;
const bottomBoxInfo = callTree.getBottomBoxInfoForCallNode(callNodeIndex);
updateBottomBoxContentsAndMaybeOpen('flame-graph', bottomBoxInfo);
};

_shouldDisplayTooltips = () => this.props.rightClickedCallNodeIndex === null;
Expand Down Expand Up @@ -222,7 +221,6 @@ class FlameGraphImpl extends React.PureComponent<Props> {
rightClickedCallNodeIndex,
changeSelectedCallNode,
handleCallNodeTransformShortcut,
openSourceView,
} = this.props;

if (
Expand Down Expand Up @@ -298,10 +296,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
}

if (event.key === 'Enter') {
const file = callTree.getRawFileNameForCallNode(nodeIndex);
if (file !== null) {
openSourceView(file, 'flame-graph');
}
this._onCallNodeEnterOrDoubleClick(nodeIndex);
return;
}

Expand Down Expand Up @@ -398,7 +393,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
stackFrameHeight: STACK_FRAME_HEIGHT,
onSelectionChange: this._onSelectedCallNodeChange,
onRightClick: this._onRightClickedCallNodeChange,
onDoubleClick: this._onCallNodeDoubleClick,
onDoubleClick: this._onCallNodeEnterOrDoubleClick,
shouldDisplayTooltips: this._shouldDisplayTooltips,
interval,
isInverted,
Expand Down Expand Up @@ -462,7 +457,7 @@ export const FlameGraph = explicitConnect<{||}, StateProps, DispatchProps>({
changeSelectedCallNode,
changeRightClickedCallNode,
handleCallNodeTransformShortcut,
openSourceView,
updateBottomBoxContentsAndMaybeOpen,
},
options: { forwardRef: true },
component: FlameGraphImpl,
Expand Down
27 changes: 20 additions & 7 deletions src/components/shared/CallNodeContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import {
funcHasIndirectRecursiveCall,
} from 'firefox-profiler/profile-logic/transforms';
import { getFunctionName } from 'firefox-profiler/profile-logic/function-info';
import { getBottomBoxInfoForCallNode } from 'firefox-profiler/profile-logic/profile-data';
import { getCategories } from 'firefox-profiler/selectors';

import copy from 'copy-to-clipboard';
import {
addTransformToStack,
expandAllCallNodeDescendants,
openSourceView,
updateBottomBoxContentsAndMaybeOpen,
setContextMenuVisibility,
} from 'firefox-profiler/actions/profile-view';
import {
Expand Down Expand Up @@ -71,7 +72,7 @@ type StateProps = {|
type DispatchProps = {|
+addTransformToStack: typeof addTransformToStack,
+expandAllCallNodeDescendants: typeof expandAllCallNodeDescendants,
+openSourceView: typeof openSourceView,
+updateBottomBoxContentsAndMaybeOpen: typeof updateBottomBoxContentsAndMaybeOpen,
+setContextMenuVisibility: typeof setContextMenuVisibility,
|};

Expand Down Expand Up @@ -179,11 +180,23 @@ class CallNodeContextMenuImpl extends React.PureComponent<Props> {
}

showFile(): void {
const filePath = this._getFilePath();
if (filePath) {
const { openSourceView, selectedTab } = this.props;
openSourceView(filePath, selectedTab);
const { updateBottomBoxContentsAndMaybeOpen, selectedTab } = this.props;

const rightClickedCallNodeInfo = this.getRightClickedCallNodeInfo();

if (rightClickedCallNodeInfo === null) {
throw new Error(
"The context menu assumes there is a selected call node and there wasn't one."
);
}

const { callNodeIndex, thread, callNodeInfo } = rightClickedCallNodeInfo;
const bottomBoxInfo = getBottomBoxInfoForCallNode(
callNodeIndex,
callNodeInfo,
thread
);
updateBottomBoxContentsAndMaybeOpen(selectedTab, bottomBoxInfo);
}

copyUrl(): void {
Expand Down Expand Up @@ -808,7 +821,7 @@ export const CallNodeContextMenu = explicitConnect<
mapDispatchToProps: {
addTransformToStack,
expandAllCallNodeDescendants,
openSourceView,
updateBottomBoxContentsAndMaybeOpen,
setContextMenuVisibility,
},
component: CallNodeContextMenuImpl,
Expand Down
14 changes: 6 additions & 8 deletions src/components/stack-chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
changeSelectedCallNode,
changeRightClickedCallNode,
handleCallNodeTransformShortcut,
openSourceView,
updateBottomBoxContentsAndMaybeOpen,
} from '../../actions/profile-view';

import { getCallNodePathFromIndex } from '../../profile-logic/profile-data';
Expand Down Expand Up @@ -93,7 +93,7 @@ type DispatchProps = {|
+changeRightClickedCallNode: typeof changeRightClickedCallNode,
+updatePreviewSelection: typeof updatePreviewSelection,
+handleCallNodeTransformShortcut: typeof handleCallNodeTransformShortcut,
+openSourceView: typeof openSourceView,
+updateBottomBoxContentsAndMaybeOpen: typeof updateBottomBoxContentsAndMaybeOpen,
|};

type Props = ConnectedProps<{||}, StateProps, DispatchProps>;
Expand Down Expand Up @@ -152,7 +152,7 @@ class StackChartImpl extends React.PureComponent<Props> {
selectedCallNodeIndex,
rightClickedCallNodeIndex,
handleCallNodeTransformShortcut,
openSourceView,
updateBottomBoxContentsAndMaybeOpen,
} = this.props;

const nodeIndex =
Expand All @@ -164,10 +164,8 @@ class StackChartImpl extends React.PureComponent<Props> {
}

if (event.key === 'Enter') {
const file = callTree.getRawFileNameForCallNode(nodeIndex);
if (file !== null) {
openSourceView(file, 'stack-chart');
}
const bottomBoxInfo = callTree.getBottomBoxInfoForCallNode(nodeIndex);
updateBottomBoxContentsAndMaybeOpen('stack-chart', bottomBoxInfo);
return;
}

Expand Down Expand Up @@ -325,7 +323,7 @@ export const StackChart = explicitConnect<{||}, StateProps, DispatchProps>({
changeRightClickedCallNode,
updatePreviewSelection,
handleCallNodeTransformShortcut,
openSourceView,
updateBottomBoxContentsAndMaybeOpen,
},
component: StackChartImpl,
});
Expand Down
Loading