Eric Seckler | 771960c | 2019-10-22 15:37:12 +0100 | [diff] [blame] | 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_PROTO_TRACK_EVENT_PARSER_H_ |
| 18 | #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_PARSER_H_ |
| 19 | |
Eric Seckler | d2af989 | 2019-11-01 10:10:53 +0000 | [diff] [blame] | 20 | #include "perfetto/protozero/field.h" |
Eric Seckler | 771960c | 2019-10-22 15:37:12 +0100 | [diff] [blame] | 21 | #include "src/trace_processor/slice_tracker.h" |
| 22 | #include "src/trace_processor/trace_storage.h" |
| 23 | |
Eric Seckler | 771960c | 2019-10-22 15:37:12 +0100 | [diff] [blame] | 24 | namespace perfetto { |
Eric Seckler | d2af989 | 2019-11-01 10:10:53 +0000 | [diff] [blame] | 25 | |
| 26 | namespace protos { |
| 27 | namespace pbzero { |
| 28 | class TrackEvent_LegacyEvent_Decoder; |
| 29 | } // namespace pbzero |
| 30 | } // namespace protos |
| 31 | |
Eric Seckler | 771960c | 2019-10-22 15:37:12 +0100 | [diff] [blame] | 32 | namespace trace_processor { |
| 33 | |
| 34 | class PacketSequenceState; |
| 35 | class TraceProcessorContext; |
| 36 | |
| 37 | class TrackEventParser { |
| 38 | public: |
| 39 | explicit TrackEventParser(TraceProcessorContext* context); |
| 40 | |
| 41 | void ParseTrackEvent(int64_t ts, |
| 42 | int64_t tts, |
| 43 | int64_t ticount, |
| 44 | PacketSequenceState*, |
| 45 | size_t sequence_state_generation, |
| 46 | protozero::ConstBytes); |
| 47 | void ParseLegacyEventAsRawEvent( |
| 48 | int64_t ts, |
| 49 | int64_t tts, |
| 50 | int64_t ticount, |
| 51 | base::Optional<UniqueTid> utid, |
| 52 | StringId category_id, |
| 53 | StringId name_id, |
Eric Seckler | d2af989 | 2019-11-01 10:10:53 +0000 | [diff] [blame] | 54 | const protos::pbzero::TrackEvent_LegacyEvent_Decoder& legacy_event, |
Eric Seckler | 771960c | 2019-10-22 15:37:12 +0100 | [diff] [blame] | 55 | SliceTracker::SetArgsCallback args_callback); |
| 56 | void ParseDebugAnnotationArgs(protozero::ConstBytes debug_annotation, |
| 57 | PacketSequenceState*, |
| 58 | size_t sequence_state_generation, |
| 59 | ArgsTracker* args_tracker, |
| 60 | RowId row); |
| 61 | void ParseNestedValueArgs(protozero::ConstBytes nested_value, |
| 62 | base::StringView flat_key, |
| 63 | base::StringView key, |
| 64 | ArgsTracker* args_tracker, |
| 65 | RowId row); |
| 66 | void ParseTaskExecutionArgs(protozero::ConstBytes task_execution, |
| 67 | PacketSequenceState*, |
| 68 | size_t sequence_state_generation, |
| 69 | ArgsTracker* args_tracker, |
| 70 | RowId row); |
| 71 | void ParseLogMessage(protozero::ConstBytes, |
| 72 | PacketSequenceState*, |
| 73 | size_t sequence_state_generation, |
| 74 | int64_t, |
| 75 | base::Optional<UniqueTid>, |
| 76 | ArgsTracker*, |
| 77 | RowId); |
Stephen Nusko | bc76a6c | 2019-12-03 11:55:27 +0000 | [diff] [blame] | 78 | void ParseCcScheduler(protozero::ConstBytes cc_scheduler, |
| 79 | PacketSequenceState*, |
| 80 | size_t sequence_state_generation, |
Stephen Nusko | e3c3995 | 2019-12-03 15:49:55 +0000 | [diff] [blame] | 81 | ArgsTracker*, |
Stephen Nusko | bc76a6c | 2019-12-03 11:55:27 +0000 | [diff] [blame] | 82 | RowId row); |
Eric Seckler | e1e8ff4 | 2019-12-04 11:05:43 +0000 | [diff] [blame] | 83 | void ParseChromeUserEvent(protozero::ConstBytes chrome_user_event, |
| 84 | ArgsTracker*, |
| 85 | RowId); |
| 86 | void ParseChromeLegacyIpc(protozero::ConstBytes chrome_legacy_ipc, |
| 87 | ArgsTracker*, |
| 88 | RowId); |
| 89 | void ParseChromeKeyedService(protozero::ConstBytes chrome_keyed_service, |
| 90 | ArgsTracker*, |
| 91 | RowId); |
Eric Seckler | 771960c | 2019-10-22 15:37:12 +0100 | [diff] [blame] | 92 | |
| 93 | private: |
| 94 | TraceProcessorContext* context_; |
| 95 | |
| 96 | const StringId task_file_name_args_key_id_; |
| 97 | const StringId task_function_name_args_key_id_; |
| 98 | const StringId task_line_number_args_key_id_; |
| 99 | const StringId log_message_body_key_id_; |
| 100 | const StringId raw_legacy_event_id_; |
Eric Seckler | 9dc3446 | 2019-11-06 14:44:20 +0000 | [diff] [blame] | 101 | const StringId legacy_event_original_tid_id_; |
Eric Seckler | 771960c | 2019-10-22 15:37:12 +0100 | [diff] [blame] | 102 | const StringId legacy_event_category_key_id_; |
| 103 | const StringId legacy_event_name_key_id_; |
| 104 | const StringId legacy_event_phase_key_id_; |
| 105 | const StringId legacy_event_duration_ns_key_id_; |
| 106 | const StringId legacy_event_thread_timestamp_ns_key_id_; |
| 107 | const StringId legacy_event_thread_duration_ns_key_id_; |
| 108 | const StringId legacy_event_thread_instruction_count_key_id_; |
| 109 | const StringId legacy_event_thread_instruction_delta_key_id_; |
| 110 | const StringId legacy_event_use_async_tts_key_id_; |
| 111 | const StringId legacy_event_unscoped_id_key_id_; |
| 112 | const StringId legacy_event_global_id_key_id_; |
| 113 | const StringId legacy_event_local_id_key_id_; |
| 114 | const StringId legacy_event_id_scope_key_id_; |
| 115 | const StringId legacy_event_bind_id_key_id_; |
| 116 | const StringId legacy_event_bind_to_enclosing_key_id_; |
| 117 | const StringId legacy_event_flow_direction_key_id_; |
| 118 | const StringId flow_direction_value_in_id_; |
| 119 | const StringId flow_direction_value_out_id_; |
| 120 | const StringId flow_direction_value_inout_id_; |
Eric Seckler | e1e8ff4 | 2019-12-04 11:05:43 +0000 | [diff] [blame] | 121 | const StringId chrome_user_event_action_args_key_id_; |
| 122 | const StringId chrome_legacy_ipc_class_args_key_id_; |
| 123 | const StringId chrome_legacy_ipc_line_args_key_id_; |
| 124 | const StringId chrome_keyed_service_name_args_key_id_; |
| 125 | |
| 126 | std::array<StringId, 38> chrome_legacy_ipc_class_ids_; |
Eric Seckler | 771960c | 2019-10-22 15:37:12 +0100 | [diff] [blame] | 127 | }; |
| 128 | |
| 129 | } // namespace trace_processor |
| 130 | } // namespace perfetto |
| 131 | |
| 132 | #endif // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_TRACK_EVENT_PARSER_H_ |