• 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 CALLSTACK_STDTYPE_H
17 #define CALLSTACK_STDTYPE_H
18 #include "base_stdtype.h"
19 
20 namespace SysTuning {
21 namespace TraceStdtype {
22 class CallStack : public CacheBase, public CpuCacheBase, public BatchCacheBase {
23 public:
24     size_t AppendInternalAsyncSlice(uint64_t startT,
25                                     uint64_t durationNs,
26                                     InternalTid internalTid,
27                                     DataIndex cat,
28                                     uint16_t nameIdentify,
29                                     DataIndex name,
30                                     uint8_t depth,
31                                     uint64_t cookid,
32                                     const std::optional<uint64_t>& parentId);
33     size_t AppendInternalSlice(uint64_t startT,
34                                uint64_t durationNs,
35                                InternalTid internalTid,
36                                DataIndex cat,
37                                uint16_t nameIdentify,
38                                DataIndex name,
39                                uint8_t depth,
40                                const std::optional<uint64_t>& parentId);
41     void SetDistributeInfo(size_t index,
42                            const std::string& chainId,
43                            const std::string& spanId,
44                            const std::string& parentSpanId,
45                            const std::string& flag,
46                            const std::string& args);
47     void AppendDistributeInfo(const std::string& chainId,
48                               const std::string& spanId,
49                               const std::string& parentSpanId,
50                               const std::string& flag,
51                               const std::string& args);
52     void AppendDistributeInfo();
53     void SetDuration(size_t index, uint64_t timeStamp);
54     void SetDurationWithFlag(size_t index, uint64_t timeStamp);
55     void SetFlag(size_t index, uint8_t flag);
56     void SetDurationEx(size_t index, uint32_t dur);
57     void SetIrqDurAndArg(size_t index, uint64_t timeStamp, uint32_t argSetId);
58     void SetTimeStamp(size_t index, uint64_t timeStamp);
59     void SetDepth(size_t index, uint8_t depth);
60     void SetArgSetId(size_t index, uint32_t argSetId);
Clear()61     void Clear() override
62     {
63         CacheBase::Clear();
64         CpuCacheBase::Clear();
65         cats_.clear();
66         cookies_.clear();
67         callIds_.clear();
68         names_.clear();
69         depths_.clear();
70         chainIds_.clear();
71         spanIds_.clear();
72         parentSpanIds_.clear();
73         flags_.clear();
74         args_.clear();
75         argSet_.clear();
76     }
ClearExportedData()77     void ClearExportedData() override
78     {
79         EraseElements(timeStamps_, ids_, durs_, cats_, cookies_, callIds_, names_, depths_, chainIds_, spanIds_,
80                       parentSpanIds_, flags_, args_, argSet_);
81     }
82     const std::deque<std::optional<uint64_t>>& ParentIdData() const;
83     const std::deque<DataIndex>& CatsData() const;
84     const std::deque<DataIndex>& NamesData() const;
85     const std::deque<uint8_t>& Depths() const;
86     const std::deque<uint64_t>& Cookies() const;
87     const std::deque<uint32_t>& CallIds() const;
88     const std::deque<uint16_t>& IdentifysData() const;
89     const std::deque<std::string>& ChainIds() const;
90     const std::deque<std::string>& SpanIds() const;
91     const std::deque<std::string>& ParentSpanIds() const;
92     const std::deque<std::string>& Flags() const;
93     const std::deque<std::string>& ArgsData() const;
94     const std::deque<uint32_t>& ArgSetIdsData() const;
95 
96 private:
97     void AppendCommonInfo(uint64_t startT, uint64_t durationNs, InternalTid internalTid);
98     void AppendCallStack(DataIndex cat, DataIndex name, uint8_t depth, std::optional<uint64_t> parentId);
99 
100 private:
101     std::deque<std::optional<uint64_t>> parentIds_;
102     std::deque<DataIndex> cats_ = {};
103     std::deque<uint64_t> cookies_ = {};
104     std::deque<uint32_t> callIds_ = {};
105     std::deque<uint16_t> identifys_ = {};
106     std::deque<DataIndex> names_ = {};
107     std::deque<uint8_t> depths_ = {};
108 
109     std::deque<std::string> chainIds_ = {};
110     std::deque<std::string> spanIds_ = {};
111     std::deque<std::string> parentSpanIds_ = {};
112     std::deque<std::string> flags_ = {};
113     std::deque<std::string> args_ = {};
114     std::deque<uint32_t> argSet_ = {};
115 };
116 } // namespace TraceStdtype
117 } // namespace SysTuning
118 #endif // CALLSTACK_STDTYPE_H
119