Lines Matching defs:std

107 bool IsLogNameValid(const std::string& name)
114 std::vector<std::string> out;
120 std::regex reType("^[a-z]+$");
121 if (!std::regex_match(out[0], reType)) { // 0 : type section
131 std::regex reDigits("^[0-9]*$");
132 if (!std::regex_match(out[2], reDigits)) { // 2 : uid section
137 if (!std::regex_match(out[3], reDigits)) { // 3 : time section
144 bool FillDumpRequest(DumpRequest &request, int status, const std::string &item)
173 std::string GetSummaryFromSectionMap(int32_t type, const std::map<std::string, std::string>& maps)
175 std::string key = "";
195 void ParseJsErrorSummary(std::string& summary, std::string& name, std::string& message, std::string& stack)
197 std::string leftStr = StringUtil::GetLeftSubstr(summary, "Error message:");
198 std::string rightStr = StringUtil::GetRightSubstr(summary, "Error message:");
203 if (leftStr.find("Error code:") != std::string::npos) {
207 if (leftStr.find("SourceCode:") != std::string::npos) {
215 void FillJsErrorParams(std::string summary, Json::Value &params)
218 std::string name = "";
219 std::string message = "";
220 std::string stack = "";
242 static bool IsSystemProcess(const std::string &processName, int32_t uid)
244 std::string sysBin = "/system/bin";
245 std::string venBin = "/vendor/bin";
258 info.sectionMap["UID"] = std::to_string(info.id);
259 info.sectionMap["PID"] = std::to_string(info.pid);
266 info.sectionMap["VERSION_CODE"] = std::to_string(bundleInfo.versionCode);
318 std::string log;
333 void Faultlogger::Dump(int fd, const std::vector<std::string> &cmds)
386 std::string content;
404 std::string fileName = FileUtil::ExtractFileName(file);
407 std::string content;
419 bool Faultlogger::JudgmentRateLimiting(std::shared_ptr<Event> event)
422 auto sysEvent = std::static_pointer_cast<SysEvent>(event);
424 std::string eventPid = std::to_string(pid);
426 std::time_t now = std::time(0);
451 bool Faultlogger::IsInterestedPipelineEvent(std::shared_ptr<Event> event)
492 sysEvent.SetEventValue("FAULT_TYPE", std::to_string(info.faultLogType));
500 std::map<std::string, std::string> eventInfos;
518 bool Faultlogger::OnEvent(std::shared_ptr<Event> &event)
530 auto sysEvent = std::static_pointer_cast<SysEvent>(event);
548 bool Faultlogger::CanProcessEvent(std::shared_ptr<Event> event)
553 void Faultlogger::FillHilog(const std::string &hilogStr, Json::Value &hilog) const
559 std::stringstream logStream(hilogStr);
560 std::string oneLine;
566 void Faultlogger::ReportJsErrorToAppEvent(std::shared_ptr<SysEvent> sysEvent) const
568 std::string summary = StringUtil::UnescapeJsonStringValue(sysEvent->GetEventValue("SUMMARY"));
574 std::string foreground = sysEvent->GetEventValue("FOREGROUND");
581 std::string logPath = sysEvent->GetEventValue("LOG_PATH");
593 std::string log;
598 std::string paramsStr = Json::FastWriter().write(params);
602 std::string outputFilePath = "/data/test_jsError_info";
615 void Faultlogger::ReportSanitizerToAppEvent(std::shared_ptr<SysEvent> sysEvent) const
617 std::string summary = StringUtil::UnescapeJsonStringValue(sysEvent->GetEventValue("SUMMARY"));
624 std::string logPath = sysEvent->GetEventValue("LOG_PATH");
634 std::string paramsStr = Json::FastWriter().write(params);
648 mgr_ = std::make_unique<FaultLogManager>(GetHiviewContext()->GetSharedWorkLoop());
674 std::unique_ptr<FaultLogInfo> Faultlogger::GetFaultLogInfo(const std::string &logPath)
680 auto info = std::make_unique<FaultLogInfo>(FaultLogger::ParseFaultLogInfoFromFile(logPath));
685 std::unique_ptr<FaultLogQueryResultInner> Faultlogger::QuerySelfFaultLog(int32_t id,
701 std::string name = "";
709 return std::make_unique<FaultLogQueryResultInner>(mgr_->GetFaultInfoList(name, id, faultType, maxNum));
712 void Faultlogger::RemoveHilogFromFaultlog(const std::string &logPath, int32_t faultType) const
714 std::ifstream logReadFile(logPath);
715 std::string readContent(std::istreambuf_iterator<char>(logReadFile), (std::istreambuf_iterator<char>()));
718 if (pos == std::string::npos) {
726 if (posStart == std::string::npos || posEnd == std::string::npos) {
732 std::ofstream logWriteFile(logPath);
737 void Faultlogger::AddFaultLogIfNeed(FaultLogInfo& info, std::shared_ptr<Event> event)
749 std::string appName = GetApplicationNameById(info.id);
799 std::string Faultlogger::GetListenerName()
806 std::vector<std::string> files;
811 if (file.find("cppcrash") == std::string::npos) {
821 if (info.summary.find("#00") == std::string::npos) {
827 "HAPPEN_TIME", std::to_string(info.time)
844 std::string stackInfo;
852 std::string outputFilePath = "/data/test_cppcrash_info_" + std::to_string(info.pid);
853 std::ofstream outFile(outputFilePath);
854 outFile << stackInfo << std::endl;
860 void Faultlogger::GetStackInfo(const FaultLogInfo& info, std::string& stackInfo) const
874 std::string stackInfoOriginal(buffer, nread);
914 ret = execl("/system/bin/hilog", "hilog", "-z", "1000", "-P", std::to_string(pid).c_str(), nullptr);
922 bool Faultlogger::GetHilog(int32_t pid, std::string& log) const
962 std::list<std::string> GetDightStrArr(const std::string& target)
964 std::list<std::string> ret;
965 std::string temp = "";
983 std::string Faultlogger::GetMemoryStrByPid(long pid) const
993 std::ifstream statmStream("/proc/" + std::to_string(pid) + "/statm");
995 std::string statmLine;
996 std::getline(statmStream, statmLine);
999 std::list<std::string> numStrArr = GetDightStrArr(statmLine);
1002 vss = multiples * std::stoull(*it);
1004 rss = multiples * std::stoull(*it);
1010 std::ifstream meminfoStream("/proc/meminfo");
1012 std::string meminfoLine;
1013 std::getline(meminfoStream, meminfoLine);
1014 sysTotalMem = std::stoull(GetDightStrArr(meminfoLine).front());
1015 std::getline(meminfoStream, meminfoLine);
1016 sysFreeMem = std::stoull(GetDightStrArr(meminfoLine).front());
1017 std::getline(meminfoStream, meminfoLine);
1018 sysAvailMem = std::stoull(GetDightStrArr(meminfoLine).front());
1039 std::string jsonFilePath = FreezeJsonUtil::GetFilePath(info.pid, info.id, info.time);
1054 std::list<std::string> hilogList;
1055 std::string hilogStr;
1060 std::stringstream hilogStream(hilogStr);
1061 std::string oneLine;
1063 while (++count <= REPORT_HILOG_LINE && std::getline(hilogStream, oneLine)) {
1072 std::string foreground = info.sectionMap.at("FOREGROUND");
1092 std::list<std::string> externalLogList;
1094 std::string externalLog = FreezeJsonUtil::GetStrByList(externalLogList);