• 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 #include "hiperf_stdtype.h"
16 
17 namespace SysTuning {
18 namespace TraceStdtype {
AppendNewPerfCallChain(uint32_t callChainId,uint32_t depth,uint64_t ip,uint64_t vaddrInFile,uint64_t fileId,uint64_t symbolId)19 size_t PerfCallChain::AppendNewPerfCallChain(uint32_t callChainId,
20                                              uint32_t depth,
21                                              uint64_t ip,
22                                              uint64_t vaddrInFile,
23                                              uint64_t fileId,
24                                              uint64_t symbolId)
25 {
26     ids_.emplace_back(Size());
27     callChainIds_.emplace_back(callChainId);
28     depths_.emplace_back(depth);
29     ips_.emplace_back(ip);
30     vaddrInFiles_.emplace_back(vaddrInFile);
31     fileIds_.emplace_back(fileId);
32     symbolIds_.emplace_back(symbolId);
33     names_.emplace_back(INVALID_UINT64);
34     return Size() - 1;
35 }
CallChainIds() const36 const std::deque<uint32_t>& PerfCallChain::CallChainIds() const
37 {
38     return callChainIds_;
39 }
Depths() const40 const std::deque<uint32_t>& PerfCallChain::Depths() const
41 {
42     return depths_;
43 }
Ips() const44 const std::deque<uint64_t>& PerfCallChain::Ips() const
45 {
46     return ips_;
47 }
VaddrInFiles() const48 const std::deque<uint64_t>& PerfCallChain::VaddrInFiles() const
49 {
50     return vaddrInFiles_;
51 }
FileIds() const52 const std::deque<uint64_t>& PerfCallChain::FileIds() const
53 {
54     return fileIds_;
55 }
SymbolIds() const56 const std::deque<uint64_t>& PerfCallChain::SymbolIds() const
57 {
58     return symbolIds_;
59 }
60 
Names() const61 const std::deque<DataIndex>& PerfCallChain::Names() const
62 {
63     return names_;
64 }
SetName(uint64_t index,DataIndex name)65 void PerfCallChain::SetName(uint64_t index, DataIndex name)
66 {
67     names_[index] = name;
68 }
Clear()69 void PerfCallChain::Clear()
70 {
71     CacheBase::Clear();
72     callChainIds_.clear();
73     depths_.clear();
74     ips_.clear();
75     vaddrInFiles_.clear();
76     fileIds_.clear();
77     symbolIds_.clear();
78     names_.clear();
79 }
UpdateSymbolId(size_t index,DataIndex symbolId)80 void PerfCallChain::UpdateSymbolId(size_t index, DataIndex symbolId)
81 {
82     if (index < Size()) {
83         symbolIds_[index] = symbolId;
84     }
85 }
AppendNewPerfFiles(uint64_t fileIds,uint32_t serial,DataIndex symbols,DataIndex filePath)86 size_t PerfFiles::AppendNewPerfFiles(uint64_t fileIds, uint32_t serial, DataIndex symbols, DataIndex filePath)
87 {
88     ids_.emplace_back(Size());
89     fileIds_.emplace_back(fileIds);
90     serials_.emplace_back(serial);
91     symbols_.emplace_back(symbols);
92     filePaths_.emplace_back(filePath);
93     return Size() - 1;
94 }
FileIds() const95 const std::deque<uint64_t>& PerfFiles::FileIds() const
96 {
97     return fileIds_;
98 }
99 
Serials() const100 const std::deque<uint32_t>& PerfFiles::Serials() const
101 {
102     return serials_;
103 }
Symbols() const104 const std::deque<DataIndex>& PerfFiles::Symbols() const
105 {
106     return symbols_;
107 }
FilePaths() const108 const std::deque<DataIndex>& PerfFiles::FilePaths() const
109 {
110     return filePaths_;
111 }
112 
Clear()113 void PerfFiles::Clear()
114 {
115     CacheBase::Clear();
116     fileIds_.clear();
117     serials_.clear();
118     symbols_.clear();
119     filePaths_.clear();
120 }
121 
AppendNewPerfSample(uint32_t sampleId,uint64_t timeStamp,uint32_t tid,uint64_t eventCount,uint64_t eventTypeId,uint64_t timestampTrace,uint64_t cpuId,uint64_t threadState)122 size_t PerfSample::AppendNewPerfSample(uint32_t sampleId,
123                                        uint64_t timeStamp,
124                                        uint32_t tid,
125                                        uint64_t eventCount,
126                                        uint64_t eventTypeId,
127                                        uint64_t timestampTrace,
128                                        uint64_t cpuId,
129                                        uint64_t threadState)
130 {
131     ids_.emplace_back(Size());
132     sampleIds_.emplace_back(sampleId);
133     timeStamps_.emplace_back(timeStamp);
134     tids_.emplace_back(tid);
135     eventCounts_.emplace_back(eventCount);
136     eventTypeIds_.emplace_back(eventTypeId);
137     timestampTraces_.emplace_back(timestampTrace);
138     cpuIds_.emplace_back(cpuId);
139     threadStates_.emplace_back(threadState);
140     return Size() - 1;
141 }
SampleIds() const142 const std::deque<uint32_t>& PerfSample::SampleIds() const
143 {
144     return sampleIds_;
145 }
Tids() const146 const std::deque<uint32_t>& PerfSample::Tids() const
147 {
148     return tids_;
149 }
EventCounts() const150 const std::deque<uint64_t>& PerfSample::EventCounts() const
151 {
152     return eventCounts_;
153 }
EventTypeIds() const154 const std::deque<uint64_t>& PerfSample::EventTypeIds() const
155 {
156     return eventTypeIds_;
157 }
TimestampTraces() const158 const std::deque<uint64_t>& PerfSample::TimestampTraces() const
159 {
160     return timestampTraces_;
161 }
CpuIds() const162 const std::deque<uint64_t>& PerfSample::CpuIds() const
163 {
164     return cpuIds_;
165 }
ThreadStates() const166 const std::deque<DataIndex>& PerfSample::ThreadStates() const
167 {
168     return threadStates_;
169 }
170 
Clear()171 void PerfSample::Clear()
172 {
173     CacheBase::Clear();
174     sampleIds_.clear();
175     tids_.clear();
176     eventCounts_.clear();
177     eventTypeIds_.clear();
178     timestampTraces_.clear();
179     cpuIds_.clear();
180     threadStates_.clear();
181 }
182 
AppendNewPerfThread(uint32_t pid,uint32_t tid,DataIndex threadName)183 size_t PerfThread::AppendNewPerfThread(uint32_t pid, uint32_t tid, DataIndex threadName)
184 {
185     ids_.emplace_back(Size());
186     pids_.emplace_back(pid);
187     tids_.emplace_back(tid);
188     threadNames_.emplace_back(threadName);
189     return Size() - 1;
190 }
Pids() const191 const std::deque<uint32_t>& PerfThread::Pids() const
192 {
193     return pids_;
194 }
Tids() const195 const std::deque<uint32_t>& PerfThread::Tids() const
196 {
197     return tids_;
198 }
ThreadNames() const199 const std::deque<DataIndex>& PerfThread::ThreadNames() const
200 {
201     return threadNames_;
202 }
Clear()203 void PerfThread::Clear()
204 {
205     CacheBase::Clear();
206     tids_.clear();
207     pids_.clear();
208     threadNames_.clear();
209 }
AppendNewPerfReport(DataIndex type,DataIndex value)210 size_t PerfReport::AppendNewPerfReport(DataIndex type, DataIndex value)
211 {
212     ids_.emplace_back(Size());
213     types_.emplace_back(type);
214     values_.emplace_back(value);
215     return Size() - 1;
216 }
Types() const217 const std::deque<DataIndex>& PerfReport::Types() const
218 {
219     return types_;
220 }
Values() const221 const std::deque<DataIndex>& PerfReport::Values() const
222 {
223     return values_;
224 }
225 } // namespace TraceStdtype
226 } // namespace SysTuning
227