blob: 211785d41e809ad97d060a50b7ce2142d61a3079 [file] [log] [blame]
Brian Hamrickd57e1332019-04-24 11:25:36 -07001/*
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 Seckler67e15a92020-01-03 13:20:46 +000017#ifndef SRC_TRACE_PROCESSOR_IMPORTERS_FUCHSIA_FUCHSIA_RECORD_H_
18#define SRC_TRACE_PROCESSOR_IMPORTERS_FUCHSIA_FUCHSIA_RECORD_H_
Brian Hamrickd57e1332019-04-24 11:25:36 -070019
Eric Secklerd8b52082019-10-17 15:58:38 +010020#include "src/trace_processor/importers/fuchsia/fuchsia_trace_utils.h"
Lalit Maganti7010b332020-02-07 10:51:15 +000021#include "src/trace_processor/storage/trace_storage.h"
Eric Seckler67e15a92020-01-03 13:20:46 +000022#include "src/trace_processor/trace_blob_view.h"
Brian Hamrickd57e1332019-04-24 11:25:36 -070023
24#include <vector>
25
26namespace perfetto {
27namespace trace_processor {
28
29// Data from a trace provider that is necessary for interpreting a binary
Eric Seckler67e15a92020-01-03 13:20:46 +000030// 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.
33class FuchsiaRecord {
Brian Hamrickd57e1332019-04-24 11:25:36 -070034 public:
Eric Seckler67e15a92020-01-03 13:20:46 +000035 FuchsiaRecord(TraceBlobView record_view)
36 : record_view_(std::move(record_view)) {}
37
Brian Hamrickd57e1332019-04-24 11:25:36 -070038 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 Seckler67e15a92020-01-03 13:20:46 +000060 TraceBlobView* record_view() { return &record_view_; }
61
Brian Hamrickd57e1332019-04-24 11:25:36 -070062 private:
Eric Seckler67e15a92020-01-03 13:20:46 +000063 TraceBlobView record_view_;
64
Brian Hamrickd57e1332019-04-24 11:25:36 -070065 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 Seckler67e15a92020-01-03 13:20:46 +000074#endif // SRC_TRACE_PROCESSOR_IMPORTERS_FUCHSIA_FUCHSIA_RECORD_H_