xref: /aosp_15_r20/external/perfetto/src/trace_processor/importers/etm/storage_handle.cc (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 #include "src/trace_processor/importers/etm/storage_handle.h"
18 #include <opencsd/etmv4/trc_cmp_cfg_etmv4.h>
19 
20 #include "perfetto/base/logging.h"
21 #include "perfetto/trace_processor/trace_blob_view.h"
22 #include "src/trace_processor/importers/etm/types.h"
23 #include "src/trace_processor/storage/trace_storage.h"
24 
25 namespace perfetto::trace_processor::etm {
26 
StoreEtmV4Config(tables::EtmV4ConfigurationTable::Id id,std::unique_ptr<Configuration> config)27 void StorageHandle::StoreEtmV4Config(tables::EtmV4ConfigurationTable::Id id,
28                                      std::unique_ptr<Configuration> config) {
29   PERFETTO_CHECK(id.value == storage_->etm_v4_configuration_data().size());
30   storage_->mutable_etm_v4_configuration_data()->push_back(std::move(config));
31 }
32 
GetEtmV4Config(tables::EtmV4ConfigurationTable::Id id) const33 const Configuration& StorageHandle::GetEtmV4Config(
34     tables::EtmV4ConfigurationTable::Id id) const {
35   PERFETTO_CHECK(id.value < storage_->etm_v4_configuration_data().size());
36   return *static_cast<const Configuration*>(
37       storage_->etm_v4_configuration_data()[id.value].get());
38 }
39 
StoreTrace(tables::EtmV4TraceTable::Id id,TraceBlobView trace)40 void StorageHandle::StoreTrace(tables::EtmV4TraceTable::Id id,
41                                TraceBlobView trace) {
42   PERFETTO_CHECK(id.value == storage_->etm_v4_trace_data().size());
43   storage_->mutable_etm_v4_trace_data()->push_back(std::move(trace));
44 }
45 
GetTrace(tables::EtmV4TraceTable::Id id) const46 const TraceBlobView& StorageHandle::GetTrace(
47     tables::EtmV4TraceTable::Id id) const {
48   PERFETTO_CHECK(id.value < storage_->etm_v4_trace_data().size());
49   return storage_->etm_v4_trace_data()[id.value];
50 }
51 
52 }  // namespace perfetto::trace_processor::etm
53