2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef SIMPLE_PERF_TRACING_H_
18 #define SIMPLE_PERF_TRACING_H_
22 #include <android-base/logging.h>
24 #include "event_type.h"
35 struct TracingFieldPlace {
39 uint64_t ReadFromData(const char* raw_data) {
40 return ConvertBytesToValue(raw_data + offset, size);
44 struct TracingFormat {
45 std::string system_name;
48 std::vector<TracingField> fields;
50 void GetField(const std::string& name, TracingFieldPlace& place) {
51 const TracingField& field = GetField(name);
52 place.offset = field.offset;
53 place.size = field.elem_size;
57 const TracingField& GetField(const std::string& name) {
58 for (const auto& field : fields) {
59 if (field.name == name) {
63 LOG(FATAL) << "Couldn't find field " << name << "in TracingFormat of "
73 explicit Tracing(const std::vector<char>& data);
75 void Dump(size_t indent);
76 TracingFormat GetTracingFormatHavingId(uint64_t trace_event_id);
77 std::string GetTracingEventNameHavingId(uint64_t trace_event_id);
78 const std::string& GetKallsyms() const;
79 uint32_t GetPageSize() const;
82 TracingFile* tracing_file_;
83 std::vector<TracingFormat> tracing_formats_;
86 bool GetTracingData(const std::vector<const EventType*>& event_types,
87 std::vector<char>* data);
89 #endif // SIMPLE_PERF_TRACING_H_