1 /* 2 * Copyright (C) 2019 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_IMPORTERS_COMMON_PARSER_TYPES_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_PARSER_TYPES_H_ 19 20 #include <stdint.h> 21 22 #include "perfetto/trace_processor/trace_blob_view.h" 23 #include "src/trace_processor/containers/string_pool.h" 24 #include "src/trace_processor/importers/proto/packet_sequence_state_generation.h" 25 26 namespace perfetto { 27 namespace trace_processor { 28 29 struct alignas(8) InlineSchedSwitch { 30 int64_t prev_state; 31 int32_t next_pid; 32 int32_t next_prio; 33 StringPool::Id next_comm; 34 }; 35 36 struct alignas(8) InlineSchedWaking { 37 int32_t pid; 38 uint16_t target_cpu; 39 uint16_t prio; 40 StringPool::Id comm; 41 uint16_t common_flags; 42 }; 43 static_assert(sizeof(InlineSchedWaking) == 16); 44 45 struct alignas(8) JsonEvent { 46 std::string value; 47 }; 48 49 struct TracePacketData { 50 TraceBlobView packet; 51 RefPtr<PacketSequenceStateGeneration> sequence_state; 52 }; 53 54 struct TrackEventData { TrackEventDataTrackEventData55 TrackEventData(TraceBlobView pv, 56 RefPtr<PacketSequenceStateGeneration> generation) 57 : trace_packet_data{std::move(pv), std::move(generation)} {} 58 TrackEventDataTrackEventData59 explicit TrackEventData(TracePacketData tpd) 60 : trace_packet_data(std::move(tpd)) {} 61 62 static constexpr uint8_t kMaxNumExtraCounters = 8; 63 CountExtraCounterValuesTrackEventData64 uint8_t CountExtraCounterValues() const { 65 for (uint8_t i = 0; i < TrackEventData::kMaxNumExtraCounters; ++i) { 66 if (std::equal_to<double>()(extra_counter_values[i], 0)) 67 return i; 68 } 69 return TrackEventData::kMaxNumExtraCounters; 70 } 71 72 TracePacketData trace_packet_data; 73 std::optional<int64_t> thread_timestamp; 74 std::optional<int64_t> thread_instruction_count; 75 double counter_value = 0; 76 std::array<double, kMaxNumExtraCounters> extra_counter_values = {}; 77 }; 78 79 } // namespace trace_processor 80 } // namespace perfetto 81 82 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_PARSER_TYPES_H_ 83