blob: 71e58d08ac431c9e8829094cfe93f05040b4a2b7 [file] [log] [blame]
Isabelle Taylorcfc8eba2018-12-16 21:02:56 +00001/*
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
23namespace perfetto {
24namespace trace_processor {
25
26using protozero::proto_utils::ProtoSchemaType;
27
Primiano Tuccic1678872019-03-20 11:30:54 +000028// We assume that no ftrace event (e.g. SchedSwitchFtraceEvent) has a proto
29// field which id is >= this.
30static constexpr size_t kMaxFtraceEventFields = 32;
31
Isabelle Taylorcfc8eba2018-12-16 21:02:56 +000032// 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.
38struct FieldDescriptor {
39 const char* name;
40 ProtoSchemaType type;
41};
42
43struct MessageDescriptor {
44 const char* name;
Lalit Magantid86161a2019-02-06 15:07:13 +000045 size_t max_field_id;
Primiano Tuccic1678872019-03-20 11:30:54 +000046 FieldDescriptor fields[kMaxFtraceEventFields];
Isabelle Taylorcfc8eba2018-12-16 21:02:56 +000047};
48
49MessageDescriptor* GetMessageDescriptorForId(size_t id);
50size_t GetDescriptorsSize();
51
52} // namespace trace_processor
53} // namespace perfetto
54#endif // SRC_TRACE_PROCESSOR_FTRACE_DESCRIPTORS_H_