• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 './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  cpuSyscall: bool(),
38
39  gpuFreq: bool(),
40  gpuMemTotal: bool(),
41
42  ftrace: bool(),
43  atrace: bool(),
44  ftraceEvents: arrayOf(str()),
45  ftraceExtraEvents: str(),
46  atraceCats: arrayOf(str()),
47  allAtraceApps: bool(true),
48  atraceApps: str(),
49  ftraceBufferSizeKb: num(2 * 1024),
50  ftraceDrainPeriodMs: num(250),
51  androidLogs: bool(),
52  androidLogBuffers: arrayOf(str()),
53  androidFrameTimeline: bool(),
54
55  cpuCoarse: bool(),
56  cpuCoarsePollMs: num(1000),
57
58  batteryDrain: bool(),
59  batteryDrainPollMs: num(1000),
60
61  boardSensors: bool(),
62
63  memHiFreq: bool(),
64  meminfo: bool(),
65  meminfoPeriodMs: num(1000),
66  meminfoCounters: arrayOf(str()),
67
68  vmstat: bool(),
69  vmstatPeriodMs: num(1000),
70  vmstatCounters: arrayOf(str()),
71
72  heapProfiling: bool(),
73  hpSamplingIntervalBytes: num(4096),
74  hpProcesses: str(),
75  hpContinuousDumpsPhase: num(),
76  hpContinuousDumpsInterval: num(),
77  hpSharedMemoryBuffer: num(8 * 1048576),
78  hpBlockClient: bool(true),
79  hpAllHeaps: bool(),
80
81  javaHeapDump: bool(),
82  jpProcesses: str(),
83  jpContinuousDumpsPhase: num(),
84  jpContinuousDumpsInterval: num(),
85
86  memLmk: bool(),
87  procStats: bool(),
88  procStatsPeriodMs: num(1000),
89
90  chromeCategoriesSelected: arrayOf(str()),
91  chromeHighOverheadCategoriesSelected: arrayOf(str()),
92
93  chromeLogs: bool(),
94  taskScheduling: bool(),
95  ipcFlows: bool(),
96  jsExecution: bool(),
97  webContentRendering: bool(),
98  uiRendering: bool(),
99  inputEvents: bool(),
100  navigationAndLoading: bool(),
101
102  symbolizeKsyms: bool(),
103});
104export const namedRecordConfigValidator = record(
105    {title: requiredStr, key: requiredStr, config: recordConfigValidator});
106export type NamedRecordConfig =
107    ValidatedType<typeof namedRecordConfigValidator>;
108export type RecordConfig = ValidatedType<typeof recordConfigValidator>;
109
110export function createEmptyRecordConfig(): RecordConfig {
111  return runValidator(recordConfigValidator, {}).result;
112}
113