• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HIPERF_STDTYPE_H
17 #define HIPERF_STDTYPE_H
18 #include "base_stdtype.h"
19 
20 namespace SysTuning {
21 namespace TraceStdtype {
22 class PerfCallChain : public CacheBase {
23 public:
24     size_t AppendNewPerfCallChain(uint32_t callChainId,
25                                   uint32_t depth,
26                                   uint64_t ip,
27                                   uint64_t vaddrInFile,
28                                   uint64_t fileId,
29                                   uint64_t symbolId);
30     const std::deque<uint32_t>& CallChainIds() const;
31     const std::deque<uint32_t>& Depths() const;
32     const std::deque<uint64_t>& Ips() const;
33     const std::deque<uint64_t>& VaddrInFiles() const;
34     const std::deque<uint64_t>& FileIds() const;
35     const std::deque<uint64_t>& SymbolIds() const;
36     const std::deque<DataIndex>& Names() const;
37     void SetName(uint64_t index, DataIndex name);
38     void UpdateSymbolId(size_t index, DataIndex symbolId);
39     void Clear() override;
40 
41 private:
42     std::deque<uint32_t> callChainIds_ = {};
43     std::deque<uint32_t> depths_ = {};
44     std::deque<uint64_t> ips_ = {};
45     std::deque<uint64_t> vaddrInFiles_ = {};
46     std::deque<uint64_t> fileIds_ = {};
47     std::deque<uint64_t> symbolIds_ = {};
48     std::deque<DataIndex> names_ = {};
49 };
50 
51 class PerfFiles : public CacheBase {
52 public:
53     size_t AppendNewPerfFiles(uint64_t fileIds, uint32_t serial, DataIndex symbols, DataIndex filePath);
54     const std::deque<uint64_t>& FileIds() const;
55     const std::deque<DataIndex>& Symbols() const;
56     const std::deque<DataIndex>& FilePaths() const;
57     const std::deque<uint32_t>& Serials() const;
58     void Clear() override;
59 
60 private:
61     std::deque<uint64_t> fileIds_ = {};
62     std::deque<uint32_t> serials_ = {};
63     std::deque<DataIndex> symbols_ = {};
64     std::deque<DataIndex> filePaths_ = {};
65 };
66 
67 class PerfSample : public CacheBase {
68 public:
69     size_t AppendNewPerfSample(uint32_t sampleId,
70                                uint64_t timeStamp,
71                                uint32_t tid,
72                                uint64_t eventCount,
73                                uint64_t eventTypeId,
74                                uint64_t timestampTrace,
75                                uint64_t cpuId,
76                                uint64_t threadState);
77     const std::deque<uint32_t>& SampleIds() const;
78     const std::deque<uint32_t>& Tids() const;
79     const std::deque<uint64_t>& EventCounts() const;
80     const std::deque<uint64_t>& EventTypeIds() const;
81     const std::deque<uint64_t>& TimestampTraces() const;
82     const std::deque<uint64_t>& CpuIds() const;
83     const std::deque<DataIndex>& ThreadStates() const;
84     void Clear() override;
85 
86 private:
87     std::deque<uint32_t> sampleIds_ = {};
88     std::deque<uint32_t> tids_ = {};
89     std::deque<uint64_t> eventCounts_ = {};
90     std::deque<uint64_t> eventTypeIds_ = {};
91     std::deque<uint64_t> timestampTraces_ = {};
92     std::deque<uint64_t> cpuIds_ = {};
93     std::deque<DataIndex> threadStates_ = {};
94 };
95 
96 class PerfThread : public CacheBase {
97 public:
98     size_t AppendNewPerfThread(uint32_t pid, uint32_t tid, DataIndex threadName);
99     const std::deque<uint32_t>& Pids() const;
100     const std::deque<uint32_t>& Tids() const;
101     const std::deque<DataIndex>& ThreadNames() const;
102     void Clear() override;
103 
104 private:
105     std::deque<uint32_t> tids_ = {};
106     std::deque<uint32_t> pids_ = {};
107     std::deque<DataIndex> threadNames_ = {};
108 };
109 
110 class PerfReport : public CacheBase {
111 public:
112     size_t AppendNewPerfReport(DataIndex type, DataIndex value);
113     const std::deque<DataIndex>& Types() const;
114     const std::deque<DataIndex>& Values() const;
115 
116 private:
117     std::deque<DataIndex> types_ = {};
118     std::deque<DataIndex> values_ = {};
119 };
120 } // namespace TraceStdtype
121 } // namespace SysTuning
122 #endif // HIPERF_STDTYPE_H
123