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';
|
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 }) => {
|
|
|
|
const frames = action?.metadata.stack || [];
|
2021-03-11 11:22:59 -08:00
|
|
|
return <div className='stack-trace'>{
|
|
|
|
frames.map((frame, index) => {
|
2021-08-16 17:06:38 -07:00
|
|
|
// Windows frames are E:\path\to\file
|
|
|
|
const pathSep = frame.file[1] === ':' ? '\\' : '/';
|
2021-03-11 11:22:59 -08:00
|
|
|
return <div
|
|
|
|
key={index}
|
|
|
|
className={'stack-trace-frame' + (selectedFrame === index ? ' selected' : '')}
|
|
|
|
onClick={() => {
|
|
|
|
setSelectedFrame(index);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<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>
|
|
|
|
</div>;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</div>;
|
|
|
|
};
|