• 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_TYPES_H_
18 #define SRC_TRACE_PROCESSOR_IMPORTERS_ETM_TYPES_H_
19 
20 #include <cstdint>
21 #include <memory>
22 #include <variant>
23 
24 #include "perfetto/ext/base/flat_hash_map.h"
25 #include "src/trace_processor/importers/etm/opencsd.h"
26 #include "src/trace_processor/types/destructible.h"
27 
28 namespace perfetto::trace_processor::etm {
29 
30 // Wrapper around open_csd library `EtmV4Config` or `ETEConfig` classes so
31 // instances can be stored in a `TraceStorage`.
32 class Configuration : public Destructible {
33  public:
Configuration(const ocsd_ete_cfg & cfg)34   explicit Configuration(const ocsd_ete_cfg& cfg) : config_(ETEConfig(&cfg)) {}
Configuration(const ocsd_etmv4_cfg & cfg)35   explicit Configuration(const ocsd_etmv4_cfg& cfg)
36       : config_(EtmV4Config(&cfg)) {}
37 
38   ~Configuration() override;
39 
etm_v4_config()40   const EtmV4Config& etm_v4_config() const {
41     return std::visit([](const auto& arg) -> const EtmV4Config& { return arg; },
42                       config_);
43   }
44 
45  private:
46   std::variant<EtmV4Config, ETEConfig> config_;
47 };
48 
49 }  // namespace perfetto::trace_processor::etm
50 
51 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_ETM_TYPES_H_
52