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_FUCHSIA_FUCHSIA_RECORD_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_FUCHSIA_FUCHSIA_RECORD_H_ 19 20 #include "src/trace_processor/importers/common/trace_blob_view.h" 21 #include "src/trace_processor/importers/fuchsia/fuchsia_trace_utils.h" 22 #include "src/trace_processor/storage/trace_storage.h" 23 24 #include <vector> 25 26 namespace perfetto { 27 namespace trace_processor { 28 29 // Data from a trace provider that is necessary for interpreting a binary 30 // record. Namely, the record itself and the entries of the string table and the 31 // thread table that are referenced by the record. This enables understanding 32 // the binary record after arbitrary reordering. 33 class FuchsiaRecord { 34 public: FuchsiaRecord(TraceBlobView record_view)35 FuchsiaRecord(TraceBlobView record_view) 36 : record_view_(std::move(record_view)) {} 37 38 struct StringTableEntry { 39 uint32_t index; 40 StringId string_id; 41 }; 42 43 struct ThreadTableEntry { 44 uint32_t index; 45 fuchsia_trace_utils::ThreadInfo info; 46 }; 47 48 void InsertString(uint32_t, StringId); 49 StringId GetString(uint32_t); 50 51 void InsertThread(uint32_t, fuchsia_trace_utils::ThreadInfo); 52 fuchsia_trace_utils::ThreadInfo GetThread(uint32_t); 53 set_ticks_per_second(uint64_t ticks_per_second)54 void set_ticks_per_second(uint64_t ticks_per_second) { 55 ticks_per_second_ = ticks_per_second; 56 } 57 get_ticks_per_second()58 uint64_t get_ticks_per_second() { return ticks_per_second_; } 59 record_view()60 TraceBlobView* record_view() { return &record_view_; } 61 62 private: 63 TraceBlobView record_view_; 64 65 std::vector<StringTableEntry> string_entries_; 66 std::vector<ThreadTableEntry> thread_entries_; 67 68 uint64_t ticks_per_second_ = 1000000000; 69 }; 70 71 } // namespace trace_processor 72 } // namespace perfetto 73 74 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_FUCHSIA_FUCHSIA_RECORD_H_ 75