!10781 add timestamp

Merge pull request !10781 from hhl/master
This commit is contained in:
openharmony_ci 2024-09-27 11:07:31 +00:00 committed by Gitee
commit b46e7db17f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 14 additions and 10 deletions

View File

@ -78,7 +78,7 @@ public:
int LifecycleTimeoutHandle(const ParamInfo& info, FreezeUtil::LifecycleFlow flow = FreezeUtil::LifecycleFlow());
std::string WriteToFile(const std::string& fileName, std::string& content);
bool IsHandleAppfreeze(const std::string& bundleName);
bool IsProcessDebug(int32_t pid, std::string processName);
bool IsProcessDebug(int32_t pid, std::string bundleName);
bool IsNeedIgnoreFreezeEvent(int32_t pid);
void DeleteStack(int pid);
bool CancelAppFreezeDetect(int32_t pid, const std::string& bundleName);

View File

@ -168,7 +168,8 @@ int AppfreezeManager::AppfreezeHandleWithStack(const FaultData& faultData, const
std::string memoryContent = "";
CollectFreezeSysMemory(memoryContent);
std::string fileName = faultData.errorObject.name + "_" + std::to_string(appInfo.pid) + "_stack";
std::string fileName = faultData.errorObject.name + "_" +
AbilityRuntime::TimeUtil::FormatTime("%Y%m%d%H%M%S") + "_" + std::to_string(appInfo.pid) + "_stack";
std::string catcherStack = "";
std::string catchJsonStack = "";
std::string fullStackPath = "";
@ -278,7 +279,8 @@ int AppfreezeManager::AcquireStack(const FaultData& faultData,
}
}
std::string fileName = faultData.errorObject.name + "_" + std::to_string(appInfo.pid) + "_binder";
std::string fileName = faultData.errorObject.name + "_" +
AbilityRuntime::TimeUtil::FormatTime("%Y%m%d%H%M%S") + "_" + std::to_string(appInfo.pid) + "_binder";
std::string fullStackPath = WriteToFile(fileName, binderInfo);
binderInfo = fullStackPath;
@ -477,16 +479,16 @@ std::string AppfreezeManager::CatcherStacktrace(int pid) const
return ret;
}
bool AppfreezeManager::IsProcessDebug(int32_t pid, std::string processName)
bool AppfreezeManager::IsProcessDebug(int32_t pid, std::string bundleName)
{
std::lock_guard<ffrt::mutex> lock(freezeFilterMutex_);
auto it = appfreezeFilterMap_.find(processName);
auto it = appfreezeFilterMap_.find(bundleName);
if (it != appfreezeFilterMap_.end() && it->second.pid == pid) {
if (it->second.state == AppFreezeState::APPFREEZE_STATE_CANCELED) {
TAG_LOGI(AAFwkTag::APPDFR, "filtration only once");
return false;
} else {
TAG_LOGI(AAFwkTag::APPDFR, "filtration %{public}s", processName.c_str());
TAG_LOGI(AAFwkTag::APPDFR, "filtration %{public}s", bundleName.c_str());
return true;
}
}
@ -496,9 +498,9 @@ bool AppfreezeManager::IsProcessDebug(int32_t pid, std::string processName)
GetParameter("hiviewdfx.appfreeze.filter_bundle_name", "", paramBundle, buffSize - 1);
std::string debugBundle(paramBundle);
if (processName.compare(debugBundle) == 0) {
if (bundleName.compare(debugBundle) == 0) {
TAG_LOGI(AAFwkTag::APPDFR, "filtration %{public}s_%{public}s not exit",
debugBundle.c_str(), processName.c_str());
debugBundle.c_str(), bundleName.c_str());
return true;
}
return false;
@ -592,6 +594,7 @@ bool AppfreezeManager::IsNeedIgnoreFreezeEvent(int32_t pid)
bool AppfreezeManager::CancelAppFreezeDetect(int32_t pid, const std::string& bundleName)
{
if (bundleName.empty()) {
TAG_LOGE(AAFwkTag::APPDFR, "SetAppFreezeFilter bundleName is empty.");
return false;
}
std::lock_guard<ffrt::mutex> lock(freezeFilterMutex_);
@ -607,8 +610,7 @@ void AppfreezeManager::RemoveDeathProcess(std::string bundleName)
std::lock_guard<ffrt::mutex> lock(freezeFilterMutex_);
auto it = appfreezeFilterMap_.find(bundleName);
if (it != appfreezeFilterMap_.end()) {
TAG_LOGD(AAFwkTag::APPDFR, "bundleName: %{public}s",
bundleName.c_str());
TAG_LOGI(AAFwkTag::APPDFR, "Remove bundleName: %{public}s", bundleName.c_str());
appfreezeFilterMap_.erase(it);
}
}

View File

@ -5954,6 +5954,8 @@ bool AppMgrServiceInner::SetAppFreezeFilter(int32_t pid)
taskHandler_->SubmitTask(resetAppfreezeTask, "resetAppfreezeTask", waitTime);
return cancelResult;
}
TAG_LOGE(AAFwkTag::APPDFR, "SetAppFreezeFilter failed, pid %{public}d calling pid %{public}d",
pid, callingPid);
return false;
}