add exit reason when process exit

Signed-off-by: sunjiakun <sunjiakun5@huawei.com>
This commit is contained in:
sunjiakun 2024-10-22 20:00:07 +08:00
parent d240d5a3d2
commit 38ddd0a684
5 changed files with 20 additions and 1 deletions

View File

@ -325,6 +325,7 @@ PROCESS_EXIT:
EXIT_PID: {type: INT32, desc: pid}
PROCESS_NAME: {type: STRING, desc: process name}
EXTENSION_TYPE: {type: INT32, desc: process exit extension type}
EXIT_REASON: {type: INT32, desc: process exit reason}
PROCESS_START_FAILED:
__BASE: {type: FAULT, level: CRITICAL, tag: app, desc: process start failed, preserve: true}

View File

@ -1524,6 +1524,7 @@ void AppMgrServiceInner::SendProcessExitEventTask(
eventInfo.pid = pid;
eventInfo.processName = appRecord->GetProcessName();
eventInfo.extensionType = static_cast<int32_t>(appRecord->GetExtensionType());
eventInfo.exitReason = appRecord->GetExitReason();
if (exitResult) {
eventInfo.exitResult = EXIT_SUCESS;

View File

@ -55,6 +55,7 @@ struct EventInfo {
int64_t duration = 0;
int32_t reason = -1;
int32_t subReason = -1;
int32_t exitReason = -1;
};
enum class EventName {

View File

@ -43,6 +43,7 @@ constexpr const char *EVENT_KEY_CALLER_PROCESS_ID = "CALLER_PROCESS_ID";
constexpr const char *EVENT_KEY_EXIT_TIME = "EXIT_TIME";
constexpr const char *EVENT_KEY_EXIT_RESULT = "EXIT_RESULT";
constexpr const char *EVENT_KEY_EXIT_PID = "EXIT_PID";
constexpr const char *EVENT_KEY_EXIT_REASON = "EXIT_REASON";
constexpr const char *EVENT_KEY_BUNDLE_TYPE = "BUNDLE_TYPE";
constexpr const char *EVENT_KEY_START_TYPE = "START_TYPE";
constexpr const char *EVENT_KEY_CALLER_STATE = "CALLER_STATE";
@ -555,7 +556,8 @@ void EventReport::SendProcessExitEvent(const EventName &eventName, const EventIn
EVENT_KEY_EXIT_RESULT, eventInfo.exitResult,
EVENT_KEY_EXIT_PID, eventInfo.pid,
EVENT_KEY_PROCESS_NAME, eventInfo.processName,
EVENT_KEY_EXTENSION_TYPE, eventInfo.extensionType);
EVENT_KEY_EXTENSION_TYPE, eventInfo.extensionType,
EVENT_KEY_EXIT_REASON, eventInfo.exitReason);
}
void EventReport::SendStartServiceEvent(const EventName &eventName, const EventInfo &eventInfo)

View File

@ -613,6 +613,20 @@ HWTEST_F(EventReportTest, SendProcessExitEvent_0100, TestSize.Level0)
EventReport::SendProcessExitEvent(eventName, eventInfo);
}
/**
* @tc.name: SendProcessExitEvent_0200
* @tc.desc: Check SendProcessExitEvent Test
* @tc.type: FUNC
*/
HWTEST_F(EventReportTest, SendProcessExitEvent_0200, TestSize.Level1)
{
EventInfo eventInfo;
EventName eventName = EventName::PROCESS_EXIT;
eventInfo.exitReason = 0;
EventReport::SendProcessExitEvent(eventName, eventInfo);
EXPECT_EQ(EventReport::ConvertEventName(eventName), "PROCESS_EXIT");
}
/**
* @tc.name: SendStartServiceEvent_0100
* @tc.desc: Check SendStartServiceEvent Test