xref: /aosp_15_r20/external/perfetto/src/trace_processor/importers/instruments/row.h (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1 /*
2  * Copyright (C) 2024 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_INSTRUMENTS_ROW_H_
18 #define SRC_TRACE_PROCESSOR_IMPORTERS_INSTRUMENTS_ROW_H_
19 
20 #include "src/trace_processor/containers/string_pool.h"
21 #include "src/trace_processor/util/build_id.h"
22 
23 namespace perfetto::trace_processor::instruments_importer {
24 
25 // TODO(leszeks): Would be nice if these were strong type aliases, to be
26 // type safe.
27 using ThreadId = uint32_t;
28 using ProcessId = uint32_t;
29 using BacktraceId = uint32_t;
30 using BacktraceFrameId = uint32_t;
31 using BinaryId = uint32_t;
32 
33 constexpr uint32_t kNullId = 0u;
34 
35 struct Binary {
36   std::string path;
37   BuildId uuid = BuildId::FromRaw(std::string(""));
38   long long load_addr = 0;
39   long long max_addr = 0;
40 };
41 
42 struct Frame {
43   long long addr = 0;
44   BinaryId binary = kNullId;
45 };
46 
47 struct Process {
48   int pid = 0;
49   StringPool::Id fmt = StringPool::Id::Null();
50 };
51 
52 struct Thread {
53   int tid = 0;
54   StringPool::Id fmt = StringPool::Id::Null();
55   ProcessId process = kNullId;
56 };
57 
58 struct Backtrace {
59   std::vector<BacktraceFrameId> frames;
60 };
61 
62 struct alignas(8) Row {
63   int64_t timestamp_;
64   uint32_t core_id;
65   ThreadId thread = kNullId;
66   BacktraceId backtrace = kNullId;
67 };
68 
69 }  // namespace perfetto::trace_processor::instruments_importer
70 
71 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_INSTRUMENTS_ROW_H_
72