1// Copyright (C) 2021 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this 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 { 16 oneOf, 17 num, 18 bool, 19 arrayOf, 20 str, 21 requiredStr, 22 record, 23 runValidator, 24 ValidatedType, 25} from '../base/validators'; 26 27const recordModes = ['STOP_WHEN_FULL', 'RING_BUFFER', 'LONG_TRACE'] as const; 28export const recordConfigValidator = record({ 29 mode: oneOf(recordModes, 'STOP_WHEN_FULL'), 30 durationMs: num(10000.0), 31 maxFileSizeMb: num(100), 32 fileWritePeriodMs: num(2500), 33 bufferSizeMb: num(64.0), 34 35 cpuSched: bool(), 36 cpuFreq: bool(), 37 cpuFreqPollMs: num(1000), 38 cpuSyscall: bool(), 39 40 gpuFreq: bool(), 41 gpuMemTotal: bool(), 42 gpuWorkPeriod: bool(), 43 44 ftrace: bool(), 45 atrace: bool(), 46 ftraceEvents: arrayOf(str()), 47 ftraceExtraEvents: str(), 48 atraceCats: arrayOf(str()), 49 allAtraceApps: bool(true), 50 atraceApps: str(), 51 ftraceBufferSizeKb: num(0), 52 ftraceDrainPeriodMs: num(0), 53 androidLogs: bool(), 54 androidLogBuffers: arrayOf(str()), 55 androidFrameTimeline: bool(), 56 androidGameInterventionList: bool(), 57 androidNetworkTracing: bool(), 58 androidNetworkTracingPollMs: num(250), 59 60 cpuCoarse: bool(), 61 cpuCoarsePollMs: num(1000), 62 63 batteryDrain: bool(), 64 batteryDrainPollMs: num(1000), 65 66 boardSensors: bool(), 67 68 memHiFreq: bool(), 69 meminfo: bool(), 70 meminfoPeriodMs: num(1000), 71 meminfoCounters: arrayOf(str()), 72 73 vmstat: bool(), 74 vmstatPeriodMs: num(1000), 75 vmstatCounters: arrayOf(str()), 76 77 heapProfiling: bool(), 78 hpSamplingIntervalBytes: num(4096), 79 hpProcesses: str(), 80 hpContinuousDumpsPhase: num(), 81 hpContinuousDumpsInterval: num(), 82 hpSharedMemoryBuffer: num(8 * 1048576), 83 hpBlockClient: bool(true), 84 hpAllHeaps: bool(), 85 86 javaHeapDump: bool(), 87 jpProcesses: str(), 88 jpContinuousDumpsPhase: num(), 89 jpContinuousDumpsInterval: num(), 90 91 memLmk: bool(), 92 procStats: bool(), 93 procStatsPeriodMs: num(1000), 94 95 chromeCategoriesSelected: arrayOf(str()), 96 chromeHighOverheadCategoriesSelected: arrayOf(str()), 97 chromePrivacyFiltering: bool(), 98 99 chromeLogs: bool(), 100 taskScheduling: bool(), 101 ipcFlows: bool(), 102 jsExecution: bool(), 103 webContentRendering: bool(), 104 uiRendering: bool(), 105 inputEvents: bool(), 106 navigationAndLoading: bool(), 107 audio: bool(), 108 video: bool(), 109 110 etwCSwitch: bool(), 111 etwThreadState: bool(), 112 113 symbolizeKsyms: bool(), 114 115 // Enabling stack sampling 116 tracePerf: bool(), 117 timebaseFrequency: num(100), 118 targetCmdLine: arrayOf(str()), 119 120 linuxDeviceRpm: bool(), 121}); 122export const namedRecordConfigValidator = record({ 123 title: requiredStr, 124 key: requiredStr, 125 config: recordConfigValidator, 126}); 127export type NamedRecordConfig = ValidatedType< 128 typeof namedRecordConfigValidator 129>; 130export type RecordConfig = ValidatedType<typeof recordConfigValidator>; 131 132export function createEmptyRecordConfig(): RecordConfig { 133 return runValidator(recordConfigValidator, {}).result; 134} 135