• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 #ifndef TOOLS_FTRACE_PROTO_GEN_FTRACE_PROTO_GEN_H_
18 #define TOOLS_FTRACE_PROTO_GEN_FTRACE_PROTO_GEN_H_
19 
20 #include <set>
21 #include <string>
22 #include <vector>
23 
24 #include "perfetto/ftrace_reader/format_parser.h"
25 
26 namespace perfetto {
27 
28 struct Proto {
29   struct Field {
30     std::string type;
31     std::string name;
32     uint32_t number;
33   };
34   std::string name;
35   std::vector<Field> fields;
36 
37   std::string ToString();
38 };
39 
40 void PrintFtraceEventProtoAdditions(const std::set<std::string>& events);
41 void PrintEventFormatterMain(const std::set<std::string>& events);
42 void PrintEventFormatterUsingStatements(const std::set<std::string>& events);
43 void PrintEventFormatterFunctions(const std::set<std::string>& events);
44 void PrintInodeHandlerMain(const std::string& event_name,
45                            const perfetto::Proto& proto);
46 
47 bool GenerateProto(const FtraceEvent& format, Proto* proto_out);
48 std::string InferProtoType(const FtraceEvent::Field& field);
49 
50 std::set<std::string> GetWhitelistedEvents(const std::string& whitelist_path);
51 std::string SingleEventInfo(perfetto::FtraceEvent format,
52                             perfetto::Proto proto,
53                             const std::string& group,
54                             const std::string& proto_field_id);
55 void GenerateEventInfo(const std::vector<std::string>& events_info);
56 
57 }  // namespace perfetto
58 
59 #endif  // TOOLS_FTRACE_PROTO_GEN_FTRACE_PROTO_GEN_H_
60