xref: /aosp_15_r20/external/perfetto/src/trace_processor/importers/etm/mapping_version.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_ETM_MAPPING_VERSION_H_
18 #define SRC_TRACE_PROCESSOR_IMPORTERS_ETM_MAPPING_VERSION_H_
19 
20 #include <cstdint>
21 
22 #include "src/trace_processor/importers/common/address_range.h"
23 #include "src/trace_processor/storage/trace_storage.h"
24 #include "src/trace_processor/tables/profiler_tables_py.h"
25 
26 namespace perfetto::trace_processor::etm {
27 class MappingVersion {
28  public:
MappingVersion(int64_t create_ts,tables::StackProfileMappingTable::ConstRowReference mapping)29   MappingVersion(int64_t create_ts,
30                  tables::StackProfileMappingTable::ConstRowReference mapping)
31       : id_(mapping.id()),
32         create_ts_(create_ts),
33         range_(static_cast<uint64_t>(mapping.start()),
34                static_cast<uint64_t>(mapping.end())) {}
Contains(uint64_t address)35   bool Contains(uint64_t address) const { return range_.Contains(address); }
Contains(const AddressRange & range)36   bool Contains(const AddressRange& range) const {
37     return range_.Contains(range);
38   }
start()39   uint64_t start() const { return range_.start(); }
end()40   uint64_t end() const { return range_.end(); }
create_ts()41   int64_t create_ts() const { return create_ts_; }
id()42   MappingId id() const { return id_; }
43 
44   MappingVersion SplitFront(uint64_t mid);
45 
46  private:
MappingVersion(MappingId id,int64_t create_ts,AddressRange alive_range)47   MappingVersion(MappingId id, int64_t create_ts, AddressRange alive_range)
48       : id_(id), create_ts_(create_ts), range_(alive_range) {}
49   MappingId id_;
50   int64_t create_ts_;
51   AddressRange range_;
52 };
53 
54 }  // namespace perfetto::trace_processor::etm
55 
56 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_ETM_MAPPING_VERSION_H_
57