Isabelle Taylor | cfc8eba | 2018-12-16 21:02:56 +0000 | [diff] [blame] | 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 SRC_TRACE_PROCESSOR_FTRACE_DESCRIPTORS_H_ |
| 18 | #define SRC_TRACE_PROCESSOR_FTRACE_DESCRIPTORS_H_ |
| 19 | |
| 20 | #include <array> |
| 21 | #include "perfetto/protozero/proto_utils.h" |
| 22 | |
| 23 | namespace perfetto { |
| 24 | namespace trace_processor { |
| 25 | |
| 26 | using protozero::proto_utils::ProtoSchemaType; |
| 27 | |
Primiano Tucci | c167887 | 2019-03-20 11:30:54 +0000 | [diff] [blame] | 28 | // We assume that no ftrace event (e.g. SchedSwitchFtraceEvent) has a proto |
| 29 | // field which id is >= this. |
| 30 | static constexpr size_t kMaxFtraceEventFields = 32; |
| 31 | |
Isabelle Taylor | cfc8eba | 2018-12-16 21:02:56 +0000 | [diff] [blame] | 32 | // This file is the header for the generated descriptors for all ftrace event |
| 33 | // protos. These descriptors can be used to parse ftrace event protos without |
| 34 | // needing individual parsing logic for every event. (In proto_trace_parser.cc) |
| 35 | // By generating these descriptors we avoid having to build the full proto |
| 36 | // library. These structs deliberately don't have a ctor (nor are initialized) |
| 37 | // because they are used to define linker-initialized dicts in the .cc file. |
| 38 | struct FieldDescriptor { |
| 39 | const char* name; |
| 40 | ProtoSchemaType type; |
| 41 | }; |
| 42 | |
| 43 | struct MessageDescriptor { |
| 44 | const char* name; |
Lalit Maganti | d86161a | 2019-02-06 15:07:13 +0000 | [diff] [blame] | 45 | size_t max_field_id; |
Primiano Tucci | c167887 | 2019-03-20 11:30:54 +0000 | [diff] [blame] | 46 | FieldDescriptor fields[kMaxFtraceEventFields]; |
Isabelle Taylor | cfc8eba | 2018-12-16 21:02:56 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | MessageDescriptor* GetMessageDescriptorForId(size_t id); |
| 50 | size_t GetDescriptorsSize(); |
| 51 | |
| 52 | } // namespace trace_processor |
| 53 | } // namespace perfetto |
| 54 | #endif // SRC_TRACE_PROCESSOR_FTRACE_DESCRIPTORS_H_ |