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