Brian Hamrick | d57e133 | 2019-04-24 11:25:36 -0700 | [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 | |
Eric Seckler | 67e15a9 | 2020-01-03 13:20:46 +0000 | [diff] [blame] | 17 | #ifndef SRC_TRACE_PROCESSOR_IMPORTERS_FUCHSIA_FUCHSIA_RECORD_H_ |
| 18 | #define SRC_TRACE_PROCESSOR_IMPORTERS_FUCHSIA_FUCHSIA_RECORD_H_ |
Brian Hamrick | d57e133 | 2019-04-24 11:25:36 -0700 | [diff] [blame] | 19 | |
Eric Seckler | d8b5208 | 2019-10-17 15:58:38 +0100 | [diff] [blame] | 20 | #include "src/trace_processor/importers/fuchsia/fuchsia_trace_utils.h" |
Lalit Maganti | 7010b33 | 2020-02-07 10:51:15 +0000 | [diff] [blame] | 21 | #include "src/trace_processor/storage/trace_storage.h" |
Eric Seckler | 67e15a9 | 2020-01-03 13:20:46 +0000 | [diff] [blame] | 22 | #include "src/trace_processor/trace_blob_view.h" |
Brian Hamrick | d57e133 | 2019-04-24 11:25:36 -0700 | [diff] [blame] | 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 |
Eric Seckler | 67e15a9 | 2020-01-03 13:20:46 +0000 | [diff] [blame] | 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 { |
Brian Hamrick | d57e133 | 2019-04-24 11:25:36 -0700 | [diff] [blame] | 34 | public: |
Eric Seckler | 67e15a9 | 2020-01-03 13:20:46 +0000 | [diff] [blame] | 35 | FuchsiaRecord(TraceBlobView record_view) |
| 36 | : record_view_(std::move(record_view)) {} |
| 37 | |
Brian Hamrick | d57e133 | 2019-04-24 11:25:36 -0700 | [diff] [blame] | 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 | |
| 54 | void set_ticks_per_second(uint64_t ticks_per_second) { |
| 55 | ticks_per_second_ = ticks_per_second; |
| 56 | } |
| 57 | |
| 58 | uint64_t get_ticks_per_second() { return ticks_per_second_; } |
| 59 | |
Eric Seckler | 67e15a9 | 2020-01-03 13:20:46 +0000 | [diff] [blame] | 60 | TraceBlobView* record_view() { return &record_view_; } |
| 61 | |
Brian Hamrick | d57e133 | 2019-04-24 11:25:36 -0700 | [diff] [blame] | 62 | private: |
Eric Seckler | 67e15a9 | 2020-01-03 13:20:46 +0000 | [diff] [blame] | 63 | TraceBlobView record_view_; |
| 64 | |
Brian Hamrick | d57e133 | 2019-04-24 11:25:36 -0700 | [diff] [blame] | 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 | |
Eric Seckler | 67e15a9 | 2020-01-03 13:20:46 +0000 | [diff] [blame] | 74 | #endif // SRC_TRACE_PROCESSOR_IMPORTERS_FUCHSIA_FUCHSIA_RECORD_H_ |