1// Copyright (C) 2020 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use size file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15import m from 'mithril'; 16 17import {globals} from './globals'; 18import {CallsiteInfo} from '../common/flamegraph_util'; 19 20interface CpuProfileDetailsPanelAttrs {} 21 22export class CpuProfileDetailsPanel 23 implements m.ClassComponent<CpuProfileDetailsPanelAttrs> 24{ 25 view() { 26 const sampleDetails = globals.cpuProfileDetails; 27 const header = m( 28 '.details-panel-heading', 29 m('h2', `CPU Profile Sample Details`), 30 ); 31 if (sampleDetails.id === undefined) { 32 return m('.details-panel', header); 33 } 34 35 return m( 36 '.details-panel', 37 header, 38 m('table', this.getStackText(sampleDetails.stack)), 39 ); 40 } 41 42 getStackText(stack?: CallsiteInfo[]): m.Vnode[] { 43 if (!stack) return []; 44 45 const result = []; 46 for (let i = stack.length - 1; i >= 0; --i) { 47 result.push(m('tr', m('td', stack[i].name), m('td', stack[i].mapping))); 48 } 49 50 return result; 51 } 52} 53