• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   int32_t target_cpu;
39   int32_t prio;
40   StringPool::Id comm;
41 };
42 
43 struct alignas(8) JsonEvent {
44   std::string value;
45 };
46 
47 struct TracePacketData {
48   TraceBlobView packet;
49   RefPtr<PacketSequenceStateGeneration> sequence_state;
50 };
51 
52 struct TrackEventData {
TrackEventDataTrackEventData53   TrackEventData(TraceBlobView pv,
54                  RefPtr<PacketSequenceStateGeneration> generation)
55       : trace_packet_data{std::move(pv), std::move(generation)} {}
56 
TrackEventDataTrackEventData57   explicit TrackEventData(TracePacketData tpd)
58       : trace_packet_data(std::move(tpd)) {}
59 
60   static constexpr uint8_t kMaxNumExtraCounters = 8;
61 
CountExtraCounterValuesTrackEventData62   uint8_t CountExtraCounterValues() const {
63     for (uint8_t i = 0; i < TrackEventData::kMaxNumExtraCounters; ++i) {
64       if (std::equal_to<double>()(extra_counter_values[i], 0))
65         return i;
66     }
67     return TrackEventData::kMaxNumExtraCounters;
68   }
69 
70   TracePacketData trace_packet_data;
71   std::optional<int64_t> thread_timestamp;
72   std::optional<int64_t> thread_instruction_count;
73   double counter_value = 0;
74   std::array<double, kMaxNumExtraCounters> extra_counter_values = {};
75 };
76 
77 }  // namespace trace_processor
78 }  // namespace perfetto
79 
80 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_PARSER_TYPES_H_
81