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 <map> 23 #include <stdexcept> 24 #include <string> 25 #include <vector> 26 #include "trace_stdtype.h" 27 namespace SysTuning { 28 namespace TraceStreamer { 29 using namespace TraceStdtype; 30 class TraceDataCacheBase { 31 public: 32 TraceDataCacheBase(); 33 TraceDataCacheBase(const TraceDataCacheBase&) = delete; 34 TraceDataCacheBase& operator=(const TraceDataCacheBase&) = delete; 35 virtual ~TraceDataCacheBase() = default; 36 37 public: ThreadSize()38 size_t ThreadSize() const 39 { 40 return internalThreadsData_.size(); 41 } ProcessSize()42 size_t ProcessSize() const 43 { 44 return internalProcessesData_.size(); 45 } 46 DataDictSize()47 size_t DataDictSize() const 48 { 49 return dataDict_.Size(); 50 } UpdateTraceRange()51 void UpdateTraceRange() 52 { 53 metaData_.SetTraceDuration((traceEndTime_ - traceStartTime_) / SEC_TO_NS); 54 } 55 DataIndex GetDataIndex(std::string_view str); 56 std::map<uint64_t, std::string> statusString_ = {{TASK_RUNNABLE, "R"}, 57 {TASK_INTERRUPTIBLE, "S"}, 58 {TASK_UNINTERRUPTIBLE, "D"}, 59 {TASK_RUNNING, "Running"}, 60 {TASK_INTERRUPTED, "I"}, 61 {TASK_TRACED, "T"}, 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 callstackData_; 90 CallStack irqData_; 91 LogInfo hilogData_; 92 HeapInfo heapData_; 93 HeapFrameInfo heapFrameData_; 94 Hidump hidumpData_; 95 96 std::deque<Process> internalProcessesData_ = {}; 97 std::deque<Thread> internalThreadsData_ = {}; 98 99 Measure measureData_; 100 CpuMeasureFilter cpuMeasureData_; 101 102 StatAndInfo stat_; 103 MetaData metaData_; 104 SymbolsData symbolsData_; 105 SysCall sysCallData_; 106 ArgSet argSet_; 107 DataType dataType_; 108 SysMeasureFilter sysEvent_; 109 }; 110 } // namespace TraceStreamer 111 } // namespace SysTuning 112 113 #endif // TRACE_DATA_CACHE_BASE_H 114