2021-03-11 11:22:59 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
import './stackTrace.css';
|
2022-09-20 18:41:51 -07:00
|
|
|
import type { ActionTraceEvent } from '@trace/trace';
|
2023-02-24 15:31:10 -08:00
|
|
|
import { ListView } from '@web/components/listView';
|
2023-03-08 17:33:27 -08:00
|
|
|
import type { StackFrame } from '@protocol/channels';
|
|
|
|
|
|
|
|
const StackFrameListView = ListView<StackFrame>;
|
2021-03-11 11:22:59 -08:00
|
|
|
|
|
|
|
export const StackTraceView: React.FunctionComponent<{
|
2021-05-13 20:41:32 -07:00
|
|
|
action: ActionTraceEvent | undefined,
|
2021-03-11 11:22:59 -08:00
|
|
|
selectedFrame: number,
|
|
|
|
setSelectedFrame: (index: number) => void
|
2021-05-13 20:41:32 -07:00
|
|
|
}> = ({ action, setSelectedFrame, selectedFrame }) => {
|
2023-02-27 15:29:20 -08:00
|
|
|
const frames = action?.stack || [];
|
2023-03-08 17:33:27 -08:00
|
|
|
return <StackFrameListView
|
2023-09-07 17:14:39 -07:00
|
|
|
name='stack-trace'
|
2023-02-24 15:31:10 -08:00
|
|
|
items={frames}
|
|
|
|
selectedItem={frames[selectedFrame]}
|
2023-03-08 17:33:27 -08:00
|
|
|
render={frame => {
|
2021-08-16 17:06:38 -07:00
|
|
|
const pathSep = frame.file[1] === ':' ? '\\' : '/';
|
2023-02-24 15:31:10 -08:00
|
|
|
return <>
|
2021-03-11 11:22:59 -08:00
|
|
|
<span className='stack-trace-frame-function'>
|
|
|
|
{frame.function || '(anonymous)'}
|
|
|
|
</span>
|
|
|
|
<span className='stack-trace-frame-location'>
|
2021-08-16 17:06:38 -07:00
|
|
|
{frame.file.split(pathSep).pop()}
|
2021-03-11 11:22:59 -08:00
|
|
|
</span>
|
|
|
|
<span className='stack-trace-frame-line'>
|
|
|
|
{':' + frame.line}
|
|
|
|
</span>
|
2023-02-24 15:31:10 -08:00
|
|
|
</>;
|
|
|
|
}}
|
|
|
|
onSelected={frame => setSelectedFrame(frames.indexOf(frame))} />;
|
2021-03-11 11:22:59 -08:00
|
|
|
};
|