1 /*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #pragma once
18
19 #include <string>
20 #include <vector>
21
22 #include "RecordFilter.h"
23 #include "command.h"
24
25 namespace simpleperf {
26
27 struct AddrFilter;
28
29 std::vector<AddrFilter> ParseAddrFilterOption(const std::string& s);
30
GetRecordCmdOptionFormats()31 inline const OptionFormatMap& GetRecordCmdOptionFormats() {
32 static OptionFormatMap option_formats;
33 if (option_formats.empty()) {
34 option_formats = {
35 {"-a", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::NOT_ALLOWED}},
36 {"--add-meta-info",
37 {OptionValueType::STRING, OptionType::MULTIPLE, AppRunnerType::ALLOWED}},
38 {"--addr-filter", {OptionValueType::STRING, OptionType::SINGLE, AppRunnerType::ALLOWED}},
39 {"--app", {OptionValueType::STRING, OptionType::SINGLE, AppRunnerType::NOT_ALLOWED}},
40 {"--aux-buffer-size", {OptionValueType::UINT, OptionType::SINGLE, AppRunnerType::ALLOWED}},
41 {"-b", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
42 {"-c", {OptionValueType::UINT, OptionType::ORDERED, AppRunnerType::ALLOWED}},
43 {"--call-graph", {OptionValueType::STRING, OptionType::ORDERED, AppRunnerType::ALLOWED}},
44 {"--callchain-joiner-min-matching-nodes",
45 {OptionValueType::UINT, OptionType::SINGLE, AppRunnerType::ALLOWED}},
46 {"--clockid", {OptionValueType::STRING, OptionType::SINGLE, AppRunnerType::ALLOWED}},
47 {"--cpu", {OptionValueType::STRING, OptionType::SINGLE, AppRunnerType::ALLOWED}},
48 {"--cpu-percent", {OptionValueType::UINT, OptionType::SINGLE, AppRunnerType::ALLOWED}},
49 {"--duration", {OptionValueType::DOUBLE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
50 {"-e", {OptionValueType::STRING, OptionType::ORDERED, AppRunnerType::ALLOWED}},
51 {"--exclude-perf", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
52 {"--exit-with-parent", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
53 {"-f", {OptionValueType::UINT, OptionType::ORDERED, AppRunnerType::ALLOWED}},
54 {"-g", {OptionValueType::NONE, OptionType::ORDERED, AppRunnerType::ALLOWED}},
55 {"--group", {OptionValueType::STRING, OptionType::ORDERED, AppRunnerType::ALLOWED}},
56 {"--in-app", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
57 {"-j", {OptionValueType::STRING, OptionType::MULTIPLE, AppRunnerType::ALLOWED}},
58 {"--keep-failed-unwinding-result",
59 {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
60 {"--keep-failed-unwinding-debug-info",
61 {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::NOT_ALLOWED}},
62 {"--kprobe", {OptionValueType::STRING, OptionType::MULTIPLE, AppRunnerType::NOT_ALLOWED}},
63 {"-m", {OptionValueType::UINT, OptionType::SINGLE, AppRunnerType::ALLOWED}},
64 {"--no-callchain-joiner",
65 {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
66 {"--no-cut-samples", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
67 {"--no-dump-kernel-symbols",
68 {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
69 {"--no-dump-symbols", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
70 {"--no-inherit", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
71 {"--no-unwind", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::NOT_ALLOWED}},
72 {"-o", {OptionValueType::STRING, OptionType::SINGLE, AppRunnerType::NOT_ALLOWED}},
73 {"--out-fd", {OptionValueType::UINT, OptionType::SINGLE, AppRunnerType::CHECK_FD}},
74 {"-p", {OptionValueType::STRING, OptionType::MULTIPLE, AppRunnerType::ALLOWED}},
75 {"--post-unwind", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
76 {"--post-unwind=no", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
77 {"--post-unwind=yes", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
78 {"--size-limit", {OptionValueType::UINT, OptionType::SINGLE, AppRunnerType::ALLOWED}},
79 {"--start_profiling_fd",
80 {OptionValueType::UINT, OptionType::SINGLE, AppRunnerType::CHECK_FD}},
81 {"--stdio-controls-profiling",
82 {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
83 {"--stop-signal-fd", {OptionValueType::UINT, OptionType::SINGLE, AppRunnerType::CHECK_FD}},
84 {"--symfs", {OptionValueType::STRING, OptionType::SINGLE, AppRunnerType::CHECK_PATH}},
85 {"-t", {OptionValueType::STRING, OptionType::MULTIPLE, AppRunnerType::ALLOWED}},
86 {"--tp-filter", {OptionValueType::STRING, OptionType::ORDERED, AppRunnerType::ALLOWED}},
87 {"--trace-offcpu", {OptionValueType::NONE, OptionType::SINGLE, AppRunnerType::ALLOWED}},
88 {"--tracepoint-events",
89 {OptionValueType::STRING, OptionType::SINGLE, AppRunnerType::CHECK_PATH}},
90 };
91 const OptionFormatMap& record_filter_options = GetRecordFilterOptionFormats();
92 option_formats.insert(record_filter_options.begin(), record_filter_options.end());
93 }
94 return option_formats;
95 }
96
97 } // namespace simpleperf
98