Lines Matching defs:std

42 using namespace std;

53 std::vector<std::string> tags;
54 std::vector<std::string> tagGroups;
55 std::string bufferSize;
56 std::string clockType;
57 std::string isOverWrite;
58 std::string outputFile;
85 const std::string DEFAULT_OUTPUT_DIR = "/data/log/hitrace/";
86 const std::string SAVED_EVENTS_FORMAT = "saved_events_format";
125 std::atomic<bool> g_dumpFlag(false);
126 std::atomic<bool> g_dumpEnd(true);
127 std::mutex g_traceMutex;
132 std::string g_traceRootPath;
134 std::vector<std::pair<std::string, int>> g_traceFilesTable;
135 std::vector<std::string> g_outputFilesForCmd;
143 uint64_t g_traceEndTime = std::numeric_limits<uint64_t>::max(); // in nano seconds
144 std::atomic<uint8_t> g_dumpStatus(TraceErrorCode::UNSET);
148 std::string GetFilePath(const std::string &fileName)
153 std::vector<std::string> Split(const std::string &str, char delimiter)
155 std::vector<std::string> res;
171 const std::string debugfsPath = "/sys/kernel/debug/tracing/";
172 const std::string tracefsPath = "/sys/kernel/tracing/";
208 bool CheckTags(const std::vector<std::string> &tags, const std::map<std::string, TagCategory> &allTags)
219 bool CheckTagGroup(const std::vector<std::string> &tagGroups,
220 const std::map<std::string, std::vector<std::string>> &tagGroupTable)
231 bool WriteStrToFileInner(const std::string& filename, const std::string& str)
233 std::ofstream out;
234 out.open(filename, std::ios::out);
250 bool WriteStrToFile(const std::string& filename, const std::string& str)
260 void SetTraceNodeStatus(const std::string &path, bool enabled)
276 bool SetProperty(const std::string& property, const std::string& value)
288 void TraceInit(const std::map<std::string, TagCategory> &allTags)
300 SetProperty("debug.hitrace.tags.enableflags", std::to_string(0));
310 void SetAllTags(const TraceParams &traceParams, const std::map<std::string, TagCategory> &allTags,
311 const std::map<std::string, std::vector<std::string>> &tagGroupTable)
313 std::set<std::string> readyEnableTagList;
314 for (std::string tagName : traceParams.tags) {
330 for (std::string groupName : traceParams.tagGroups) {
335 for (std::string tag : iter->second) {
341 for (std::string tagName : readyEnableTagList) {
358 SetProperty("debug.hitrace.tags.enableflags", std::to_string(enabledUserTags));
361 std::string ReadFileInner(const std::string& filename)
363 std::string resolvedPath = CanonicalizeSpecPath(filename.c_str());
364 std::ifstream fileIn(resolvedPath.c_str());
370 std::string str((std::istreambuf_iterator<char>(fileIn)), std::istreambuf_iterator<char>());
375 std::string ReadFile(const std::string& filename)
377 std::string filePath = GetFilePath(filename);
381 void SetClock(const std::string& clockType)
383 const std::string traceClockPath = "trace_clock";
388 std::string allClocks = ReadFile(traceClockPath);
389 if (allClocks.find(clockType) == std::string::npos) {
398 std::set<std::string> allClockTypes;
407 std::string currentClockType;
430 bool SetTraceSetting(const TraceParams &traceParams, const std::map<std::string, TagCategory> &allTags,
431 const std::map<std::string, std::vector<std::string>> &tagGroupTable)
450 WriteStrToFile("saved_cmdlines_size", std::to_string(SAVED_CMDLINES_SIZE));
471 bool CheckFileExist(const std::string &outputFile)
497 g_traceEndTime = std::numeric_limits<uint64_t>::max();
501 g_traceEndTime = g_inputTraceEndTime > 0 ? g_inputTraceEndTime : std::numeric_limits<uint64_t>::max();
509 g_traceEndTime = std::numeric_limits<uint64_t>::max();
543 bool WriteFile(uint8_t contentType, const std::string &src, int outFd, const std::string &outputFile)
545 std::string srcPath = CanonicalizeSpecPath(src.c_str());
563 uint64_t traceEndTime = std::numeric_limits<uint64_t>::max();
652 void WriteEventFile(std::string &srcPath, int outFd)
655 std::string srcSpecPath = CanonicalizeSpecPath(srcPath.c_str());
675 bool WriteEventsFormat(int outFd, const std::string &outputFile)
677 const std::string savedEventsFormatPath = DEFAULT_OUTPUT_DIR + SAVED_EVENTS_FORMAT;
681 std::string filePath = CanonicalizeSpecPath(savedEventsFormatPath.c_str());
687 const std::vector<std::string> priorityTracingCategory = {
741 std::string srcPath = g_traceRootPath + priorityTracingCategory[i];
751 bool WriteHeaderPage(int outFd, const std::string &outputFile)
756 std::string headerPagePath = GetFilePath("events/header_page");
760 bool WritePrintkFormats(int outFd, const std::string &outputFile)
765 std::string printkFormatPath = GetFilePath("printk_formats");
779 bool HmWriteCpuRawInner(int outFd, const std::string &outputFile)
782 std::string src = g_traceRootPath + "/trace_pipe_raw";
796 bool WriteCpuRawInner(int outFd, const std::string &outputFile)
801 std::string src = g_traceRootPath + "per_cpu/cpu" + std::to_string(i) + "/trace_pipe_raw";
813 bool WriteCpuRaw(int outFd, const std::string &outputFile)
822 bool WriteCmdlines(int outFd, const std::string &outputFile)
824 std::string cmdlinesPath = GetFilePath("saved_cmdlines");
828 bool WriteTgids(int outFd, const std::string &outputFile)
830 std::string tgidsPath = GetFilePath("saved_tgids");
834 bool GenerateNewFile(int &outFd, std::string &outPath)
839 std::string outputFileName = GenerateTraceFileName(false);
854 bool DumpTraceLoop(const std::string &outputFileName, bool isLimited)
862 std::string outPath = CanonicalizeSpecPath(outputFileName.c_str());
915 const std::string threadName = "TraceDumpTask";
924 std::string outputFileName = g_currentTraceParams.outputFile.empty() ?
938 std::string outputFileName = GenerateTraceFileName(false);
949 void SearchFromTable(std::vector<std::string> &outputFiles, int nowSec)
972 bool ReadRawTrace(std::string &outputFileName)
975 std::string outPath = CanonicalizeSpecPath(outputFileName.c_str());
1002 void SetProcessName(std::string& processName)
1009 std::string setName;
1073 TraceErrorCode DumpTraceInner(std::vector<std::string> &outputFiles)
1081 std::string outputFileName = GenerateTraceFileName();
1082 std::string reOutPath = CanonicalizeSpecPath(outputFileName.c_str());
1091 std::string processName = "HitraceDump";
1145 const std::vector<std::string> tagGroups = {"scene_performance"};
1167 const std::string enable = "1";
1190 const std::string threadName = "TraceMonitor";
1205 std::vector<int> result;
1206 std::unique_ptr<DynamicBuffer> dynamicBuffer = std::make_unique<DynamicBuffer>(g_traceRootPath, cpuNums);
1216 std::string path = "per_cpu/cpu" + std::to_string(i) + "/buffer_size_kb";
1217 WriteStrToFile(path, std::to_string(result[i]));
1225 const std::map<std::string, TagCategory> &allTags,
1226 const std::map<std::string, std::vector<std::string>> &tagGroupTable)
1236 TraceErrorCode HandleServiceTraceOpen(const std::vector<std::string> &tagGroups,
1237 const std::map<std::string, TagCategory> &allTags,
1238 const std::map<std::string, std::vector<std::string>> &tagGroupTable)
1242 serviceTraceParams.bufferSize = std::to_string(DEFAULT_BUFFER_SIZE);
1244 serviceTraceParams.bufferSize = std::to_string(HM_DEFAULT_BUFFER_SIZE);
1252 void RemoveUnSpace(std::string str, std::string& args)
1257 std::string strSpace = str + " ";
1260 std::string::size_type index = args.find(strSpace);
1261 if (index != std::string::npos) {
1269 void SetCmdTraceIntParams(const std::string &traceParamsStr, int &traceParams)
1276 traceParams = std::stoi(traceParamsStr);
1287 bool ParseArgs(const std::string &args, TraceParams &cmdTraceParams, const std::map<std::string, TagCategory> &allTags,
1288 const std::map<std::string, std::vector<std::string>> &tagGroupTable)
1290 std::string userArgs = args;
1291 std::string str = ":";
1295 std::vector<std::string> argList = Split(userArgs, ' ');
1296 for (std::string item : argList) {
1298 if (pos == std::string::npos) {
1302 std::string itemName = item.substr(0, pos);
1316 std::string fileSizeStr = item.substr(pos + 1);
1319 std::string fileLimitStr = item.substr(pos + 1);
1322 std::string pidStr = item.substr(pos + 1);
1344 std::string freqsfmt = "cpu frequency: ";
1369 TraceErrorCode OpenTrace(const std::vector<std::string> &tagGroups)
1375 std::lock_guard<std::mutex> lock(g_traceMutex);
1381 std::map<std::string, TagCategory> allTags;
1382 std::map<std::string, std::vector<std::string>> tagGroupTable;
1406 std::thread auxiliaryTask(it);
1414 TraceErrorCode OpenTrace(const std::string &args)
1416 std::lock_guard<std::mutex> lock(g_traceMutex);
1427 std::map<std::string, TagCategory> allTags;
1428 std::map<std::string, std::vector<std::string>> tagGroupTable;
1465 std::lock_guard<std::mutex> lock(g_traceMutex);
1485 std::time_t now = std::time(nullptr);
1489 std::lock_guard<std::mutex> lock(g_traceMutex);
1500 std::time_t boot_time = now - info.uptime;
1518 std::lock_guard<std::mutex> lock(g_traceMutex);
1528 std::lock_guard<std::mutex> lock(g_traceMutex);
1544 std::thread task(it);
1553 std::lock_guard<std::mutex> lock(g_traceMutex);
1577 std::lock_guard<std::mutex> lock(g_traceMutex);
1592 std::map<std::string, TagCategory> allTags;
1593 std::map<std::string, std::vector<std::string>> tagGroupTable;
1604 std::vector<std::pair<std::string, int>> GetTraceFilesTable()
1609 void SetTraceFilesTable(const std::vector<std::pair<std::string, int>>& traceFilesTable)