diff --git a/services/appdfr/src/appfreeze_manager.cpp b/services/appdfr/src/appfreeze_manager.cpp index e6327098e7..01ffe17946 100644 --- a/services/appdfr/src/appfreeze_manager.cpp +++ b/services/appdfr/src/appfreeze_manager.cpp @@ -91,20 +91,20 @@ static constexpr int SYSLOAD_GET_KILL_INFO_MAGIC = 0xE5AC02; #define SYSLOAD_GET_KILL_INFO_MAGIC 0xE5AC02 struct KillEventInfo { - int id; - int adj; - bool processed; - bool foreground; - pid_t pid; - int uid; - int64_t timestamp; - int64_t eventParamFirst; - int64_t eventParamSecond; - int64_t eventParamThird; - int64_t eventParamFourth; - int64_t eventParamFifth; - int64_t eventParamSixth; - int64_t eventParamSeventh; + int id = 0; + int adj = 0; + bool processed = false; + bool foreground = false; + pid_t pid = 0; + int uid = 0; + int64_t timestamp = 0; + int64_t eventParamFirst = 0; + int64_t eventParamSecond = 0; + int64_t eventParamThird = 0; + int64_t eventParamFourth = 0; + int64_t eventParamFifth = 0; + int64_t eventParamSixth = 0; + int64_t eventParamSeventh = 0; }; struct KillInfo { @@ -1276,6 +1276,13 @@ AppfreezeManager::ProcessKillInfo AppfreezeManager::GetProcessKillReason( .adj = 0, .timestamp = 0, .killId = killId, + .eventParamFirst = 0, + .eventParamSecond = 0, + .eventParamThird = 0, + .eventParamFourth = 0, + .eventParamFifth = 0, + .eventParamSixth = 0, + .eventParamSeventh = 0, }; if (killId == INVALID_KILL_ID) { killInfo.killReason = INVALID_KILL_REASON; @@ -1330,6 +1337,7 @@ void AppfreezeManager::GetExitKernelReason(int32_t pid, ProcessKillInfo& killInf killInfo.eventParamFirst, killInfo.eventParamSecond, killInfo.eventParamThird, killInfo.eventParamFourth, killInfo.eventParamFifth, killInfo.eventParamSixth, killInfo.eventParamSeventh); } else { + killInfo.killReason = INVALID_KILL_REASON; TAG_LOGW(AAFwkTag::APPDFR, "Get killReason ioctl failed, errno:%{public}d", errno); } } diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index a89c485b70..33a3a65f8c 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -8125,8 +8125,9 @@ int32_t AppMgrServiceInner::TransformedNotifyAppFault(const AppFaultDataBySA &fa } record->NotifyAppFault(transformedFaultData); TAG_LOGW(AAFwkTag::APPMGR, "FaultDataBySA is: name: %{public}s, faultType: %{public}s, uid: %{public}d," - "pid: %{public}d, bundleName: %{public}s, eventId: %{public}d", faultData.errorObject.name.c_str(), - FaultTypeToString(faultData.faultType).c_str(), uid, pid, bundleName.c_str(), faultData.eventId); + "pid: %{public}d, bundleName: %{public}s, eventId: %{public}d, foreground: %{public}d", + faultData.errorObject.name.c_str(), FaultTypeToString(faultData.faultType).c_str(), uid, pid, + bundleName.c_str(), faultData.eventId, transformedFaultData.isInForeground); return ERR_OK; } diff --git a/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp b/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp index c1e2a08522..481db7e994 100644 --- a/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp +++ b/test/unittest/dfr_test/appfreeze_manager_test/appfreeze_manager_test.cpp @@ -776,6 +776,8 @@ HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_GetProcessKillReason_Test001 printf("killInfo killId: %d", killInfo.killId); killId = 0; appfreezeManager->GetProcessKillReason(killId, pid, killMsg); + killId = 4000; + appfreezeManager->GetProcessKillReason(killId, pid, killMsg); } /** @@ -805,6 +807,9 @@ HWTEST_F(AppfreezeManagerTest, AppfreezeManagerTest_GetExitKernelReason_Test001, pid = -1; appfreezeManager->GetExitKernelReason(pid, killInfo); printf("killInfo killId: %d", killInfo.killId); + killInfo.killId = 4000; + appfreezeManager->GetExitKernelReason(pid, killInfo); + printf("killInfo killId: %d", killInfo.killId); } /**