• 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 #include "trace_data_cache_base.h"
17 #include <string_view>
18 
19 namespace SysTuning {
20 namespace TraceStreamer {
TraceDataCacheBase()21 TraceDataCacheBase::TraceDataCacheBase()
22 {
23     internalProcessesData_.emplace_back(0);
24     internalThreadsData_.emplace_back(0);
25     internalThreadsData_.front().internalPid_ = 0;
26     GetDataIndex("");
27     for (auto it = statusString_.begin(); it != statusString_.end(); it++) {
28         threadStatus2Value_[it->second] = it->first;
29     }
30 }
GetDataIndex(std::string_view str)31 DataIndex TraceDataCacheBase::GetDataIndex(std::string_view str)
32 {
33     return dataDict_.GetStringIndex(str);
34 }
35 
GetConstDataIndex(std::string_view str) const36 DataIndex TraceDataCacheBase::GetConstDataIndex(std::string_view str) const
37 {
38     return dataDict_.GetStringIndexNoWrite(str);
39 }
UpdataZeroThreadInfo()40 void TraceDataCacheBase::UpdataZeroThreadInfo()
41 {
42     const std::string ZERO_THREAD_NAME = "swapper";
43     internalProcessesData_.front().cmdLine_ = ZERO_THREAD_NAME;
44     auto& thread = internalThreadsData_.front();
45     thread.internalPid_ = 0;
46     thread.nameIndex_ = dataDict_.GetStringIndex(ZERO_THREAD_NAME);
47 }
48 } // namespace TraceStreamer
49 } // namespace SysTuning
50