• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cstddef>
21 #include <cstdint>
22 
23 #include "perfetto/trace_processor/trace_blob_view.h"
24 #include "src/trace_processor/importers/common/address_range.h"
25 #include "src/trace_processor/storage/trace_storage.h"
26 
27 namespace perfetto::trace_processor::etm {
28 
29 class MappingVersion {
30  public:
31   MappingVersion(MappingId id,
32                  int64_t create_ts,
33                  AddressRange range,
34                  std::optional<TraceBlobView> content);
35 
Contains(uint64_t address)36   bool Contains(uint64_t address) const { return range_.Contains(address); }
Contains(const AddressRange & range)37   bool Contains(const AddressRange& range) const {
38     return range_.Contains(range);
39   }
start()40   uint64_t start() const { return range_.start(); }
end()41   uint64_t end() const { return range_.end(); }
length()42   uint64_t length() const { return range_.length(); }
create_ts()43   int64_t create_ts() const { return create_ts_; }
id()44   MappingId id() const { return id_; }
45   // Returns a valid pointer if data is available or nullptr otherwise
data()46   const uint8_t* data() const {
47     // We make sure in the constructor that if content_ length is 0 the pointer
48     // will be null.
49     return content_.data();
50   }
51 
52   MappingVersion SplitFront(uint64_t mid);
53 
54  private:
55   MappingId id_;
56   int64_t create_ts_;
57   AddressRange range_;
58   // Content is either empty and points to nullptr, or has the same length as
59   // `range_`. This is CHECKED in the constructor.
60   TraceBlobView content_;
61 };
62 
63 }  // namespace perfetto::trace_processor::etm
64 
65 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_ETM_MAPPING_VERSION_H_
66