• 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 TRACE_DATA_CACHE_BASE_H
17 #define TRACE_DATA_CACHE_BASE_H
18 
19 
20 #include <array>
21 #include <deque>
22 #include <limits>
23 #include <map>
24 #include <stdexcept>
25 #include <string>
26 #include <vector>
27 #include "trace_stdtype.h"
28 namespace SysTuning {
29 namespace TraceStreamer {
30 using namespace TraceStdtype;
31 class TraceDataCacheBase {
32 public:
33     TraceDataCacheBase();
34     TraceDataCacheBase(const TraceDataCacheBase&) = delete;
35     TraceDataCacheBase& operator=(const TraceDataCacheBase&) = delete;
36     virtual ~TraceDataCacheBase() = default;
37 
38 public:
ThreadSize()39     size_t ThreadSize() const
40     {
41         return internalThreadsData_.size();
42     }
ProcessSize()43     size_t ProcessSize() const
44     {
45         return internalProcessesData_.size();
46     }
47 
DataDictSize()48     size_t DataDictSize() const
49     {
50         return dataDict_.Size();
51     }
UpdateTraceRange()52     void UpdateTraceRange()
53     {
54         metaData_.SetTraceDuration((traceEndTime_ - traceStartTime_) / SEC_TO_NS);
55     }
56     DataIndex GetDataIndex(std::string_view str);
57     std::map<uint64_t, std::string> statusString_ = {{TASK_RUNNABLE, "R"},
58                                                      {TASK_INTERRUPTIBLE, "S"},
59                                                      {TASK_UNINTERRUPTIBLE, "D"},
60                                                      {TASK_RUNNING, "Running"},
61                                                      {TASK_INTERRUPTED, "I"},
62                                                      {TASK_EXIT_DEAD, "X"},
63                                                      {TASK_ZOMBIE, "Z"},
64                                                      {TASK_KILLED, "I"},
65                                                      {TASK_WAKEKILL, "R"},
66                                                      {TASK_INVALID, "U"},
67                                                      {TASK_CLONE, "I"},
68                                                      {TASK_DK, "DK"},
69                                                      {TASK_TRACED_KILL, "TK"},
70                                                      {TASK_FOREGROUND, "R+"},
71                                                      {TASK_MAX, "S"}};
72     uint64_t traceStartTime_ = std::numeric_limits<uint64_t>::max();
73     uint64_t traceEndTime_ = 0;
74 
75     Raw rawData_;
76     ThreadState threadStateData_;
77     Instants instantsData_;
78 
79     Filter filterData_;
80     ProcessMeasureFilter processMeasureFilterData_;
81     ClockEventData clockEventFilterData_;
82     ClkEventData clkEventFilterData_;
83     ProcessMeasureFilter processFilterData_;
84     ThreadMeasureFilter threadMeasureFilterData_;
85     ThreadMeasureFilter threadFilterData_;
86     DataDict dataDict_;
87 
88     SchedSlice schedSliceData_;
89     CallStack internalSlicesData_;
90     LogInfo hilogData_;
91 
92     std::deque<Process> internalProcessesData_ = {};
93     std::deque<Thread> internalThreadsData_ = {};
94 
95     Measure measureData_;
96     CpuMeasureFilter cpuMeasureData_;
97 
98     StatAndInfo stat_;
99     MetaData metaData_;
100     SymbolsData symbolsData_;
101     SysCall sysCallData_;
102     ArgSet argSet_;
103     DataType dataType_;
104     SysMeasureFilter sysEvent_;
105 };
106 } // namespace TraceStreamer
107 } // namespace SysTuning
108 
109 #endif // TRACE_DATA_CACHE_BASE_H
110