mirror of
https://gitee.com/openharmony/startup_appspawn
synced 2024-11-23 07:00:17 +00:00
新增isDebuggable字段
Signed-off-by: 王达 <wangda20@huawei.com>
This commit is contained in:
parent
6fb5078405
commit
1a36e473ac
@ -137,7 +137,7 @@ static int AppInfoCompareProc(ListNode *node, ListNode *newNode)
|
||||
return node1->pid - node2->pid;
|
||||
}
|
||||
|
||||
AppSpawnedProcess *AddSpawnedProcess(pid_t pid, const char *processName)
|
||||
AppSpawnedProcess *AddSpawnedProcess(pid_t pid, const char *processName, bool isDebuggable)
|
||||
{
|
||||
APPSPAWN_CHECK(g_appSpawnMgr != NULL && processName != NULL, return NULL, "Invalid mgr or process name");
|
||||
APPSPAWN_CHECK(pid > 0, return NULL, "Invalid pid for %{public}s", processName);
|
||||
@ -150,6 +150,7 @@ AppSpawnedProcess *AddSpawnedProcess(pid_t pid, const char *processName)
|
||||
node->max = 0;
|
||||
node->uid = 0;
|
||||
node->exitStatus = 0;
|
||||
node->isDebuggable = isDebuggable;
|
||||
int ret = strcpy_s(node->name, len, processName);
|
||||
APPSPAWN_CHECK(ret == 0, free(node);
|
||||
return NULL, "Failed to strcpy process name");
|
||||
|
@ -97,6 +97,7 @@ typedef struct TagAppSpawnedProcess {
|
||||
#ifdef DEBUG_BEGETCTL_BOOT
|
||||
AppSpawnMsgNode *message;
|
||||
#endif
|
||||
bool isDebuggable;
|
||||
char name[0];
|
||||
} AppSpawnedProcess;
|
||||
|
||||
@ -136,7 +137,7 @@ AppSpawnContent *GetAppSpawnContent(void);
|
||||
*/
|
||||
typedef void (*AppTraversal)(const AppSpawnMgr *mgr, AppSpawnedProcess *appInfo, void *data);
|
||||
void TraversalSpawnedProcess(AppTraversal traversal, void *data);
|
||||
AppSpawnedProcess *AddSpawnedProcess(pid_t pid, const char *processName);
|
||||
AppSpawnedProcess *AddSpawnedProcess(pid_t pid, const char *processName, bool isDebuggable);
|
||||
AppSpawnedProcess *GetSpawnedProcess(pid_t pid);
|
||||
AppSpawnedProcess *GetSpawnedProcessByName(const char *name);
|
||||
void TerminateSpawnedProcess(AppSpawnedProcess *node);
|
||||
|
@ -887,7 +887,8 @@ static void ProcessChildResponse(const WatcherHandle taskHandle, int fd, uint32_
|
||||
return;
|
||||
}
|
||||
// success
|
||||
AppSpawnedProcess *appInfo = AddSpawnedProcess(property->pid, GetBundleName(property));
|
||||
bool isDebuggable = CheckAppMsgFlagsSet(property, APP_FLAGS_DEBUGGABLE) == 1 ? true : false;
|
||||
AppSpawnedProcess *appInfo = AddSpawnedProcess(property->pid, GetBundleName(property), isDebuggable);
|
||||
uint32_t len = 0;
|
||||
char *pidMaxStr = NULL;
|
||||
pidMaxStr = GetAppPropertyExt(property, MSG_EXT_NAME_MAX_CHILD_PROCCESS_MAX, &len);
|
||||
@ -1224,7 +1225,7 @@ AppSpawnContent *StartSpawnService(const AppSpawnStartArg *startArg, uint32_t ar
|
||||
#endif
|
||||
AddAppSpawnHook(STAGE_CHILD_PRE_RUN, HOOK_PRIO_LOWEST, AppSpawnClearEnv);
|
||||
if (arg->mode == MODE_FOR_APP_SPAWN) {
|
||||
AddSpawnedProcess(pid, NWEBSPAWN_SERVER_NAME);
|
||||
AddSpawnedProcess(pid, NWEBSPAWN_SERVER_NAME, false);
|
||||
SetParameter("bootevent.appspawn.started", "true");
|
||||
}
|
||||
return content;
|
||||
@ -1394,20 +1395,20 @@ static int ProcessAppSpawnDeviceDebugMsg(AppSpawnMsgNode *message)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int signal = atoi((char *)GetAppSpawnMsgExtInfo(message, "signal", &len));
|
||||
int signal = atoi((char *)GetAppSpawnMsgExtInfo(message, "signal", &len) + 1);
|
||||
if (signal == 0) {
|
||||
APPSPAWN_LOGE("appspawn devicedebug get pid fail");
|
||||
return -1;
|
||||
}
|
||||
|
||||
AppSpawningCtx *property = GetAppSpawningCtxByPid(pid);
|
||||
if (property == NULL) {
|
||||
APPSPAWN_LOGE("appspawn devicedebug get property unsuccess, pid=%{public}d", pid);
|
||||
AppSpawnedProcess *appInfo = GetSpawnedProcess(pid);
|
||||
if (appInfo == NULL) {
|
||||
APPSPAWN_LOGE("appspawn devicedebug get app info unsuccess, pid=%{public}d", pid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
APPSPAWN_LOGI("appspawn devicedebug debugable=%{public}d, pid=%{public}d, signal=%{public}d",
|
||||
CheckAppMsgFlagsSet(property, APP_FLAGS_DEBUGGABLE), pid, signal);
|
||||
appInfo->isDebuggable, pid, signal);
|
||||
|
||||
if (kill(pid, signal) != 0) {
|
||||
APPSPAWN_LOGE("appspawn devicedebug unable to kill process, pid: %{public}d ret %{public}d", pid, errno);
|
||||
|
@ -124,7 +124,7 @@ HWTEST_F(AppSpawnAppMgrTest, App_Spawn_AppSpawnedProcess_001, TestSize.Level0)
|
||||
int result[resultCount] = {0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0};
|
||||
for (size_t i = 0; i < processNameCount; i++) {
|
||||
for (size_t j = 0; j < pidCount; j++) {
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(pidInput[j], processNameInput[i]);
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(pidInput[j], processNameInput[i], false);
|
||||
EXPECT_EQ(app != nullptr, result[i * pidCount + j]);
|
||||
}
|
||||
}
|
||||
@ -167,7 +167,7 @@ HWTEST_F(AppSpawnAppMgrTest, App_Spawn_AppSpawnedProcess_002, TestSize.Level0)
|
||||
int result[resultCount] = {0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0};
|
||||
for (size_t i = 0; i < processNameCount; i++) {
|
||||
for (size_t j = 0; j < pidCount; j++) {
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(pidInput[j], processNameInput[i]);
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(pidInput[j], processNameInput[i], false);
|
||||
EXPECT_EQ(app != nullptr, result[i * pidCount + j]);
|
||||
}
|
||||
}
|
||||
@ -205,7 +205,7 @@ HWTEST_F(AppSpawnAppMgrTest, App_Spawn_AppSpawnedProcess_003, TestSize.Level0)
|
||||
// GetSpawnedProcessByName
|
||||
size_t processNameCount = ARRAY_LENGTH(processNameInput);
|
||||
for (size_t i = 0; i < processNameCount; i++) {
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(1000, processNameInput[i]); // 10000
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(1000, processNameInput[i], false); // 10000
|
||||
EXPECT_EQ(app != nullptr, 1);
|
||||
}
|
||||
for (size_t i = 0; i < processNameCount; i++) {
|
||||
@ -492,7 +492,7 @@ HWTEST_F(AppSpawnAppMgrTest, App_Spawn_AppSpawnMsgNode_005, TestSize.Level0)
|
||||
EXPECT_EQ(memcmp(buffer.data() + sizeof(AppSpawnMsg), outMsg->buffer, msgLen - sizeof(AppSpawnMsg)), 0);
|
||||
EXPECT_EQ(0, reminder);
|
||||
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(9999999, "aaaa"); // 9999999 test
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(9999999, "aaaa", false); // 9999999 test
|
||||
EXPECT_EQ(app != nullptr, 1);
|
||||
TerminateSpawnedProcess(app);
|
||||
AppSpawnExtData extData;
|
||||
@ -540,7 +540,7 @@ HWTEST_F(AppSpawnAppMgrTest, App_Spawn_AppSpawnMsgNode_006, TestSize.Level0)
|
||||
EXPECT_EQ(memcmp(buffer.data() + sizeof(AppSpawnMsg), outMsg->buffer, msgLen - sizeof(AppSpawnMsg)), 0);
|
||||
EXPECT_EQ(0, reminder);
|
||||
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(9999999, "aaaa"); // 9999999 test
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(9999999, "aaaa", false); // 9999999 test
|
||||
EXPECT_EQ(app != nullptr, 1);
|
||||
|
||||
ret = DecodeAppSpawnMsg(outMsg);
|
||||
|
@ -188,7 +188,7 @@ HWTEST_F(AppSpawnModuleInterfaceTest, App_Spawn_Process_Hook_001, TestSize.Level
|
||||
{
|
||||
AppSpawnMgr *mgr = CreateAppSpawnMgr(MODE_FOR_NWEB_SPAWN);
|
||||
EXPECT_EQ(mgr != nullptr, 1);
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(1000, "test-001");
|
||||
AppSpawnedProcess *app = AddSpawnedProcess(1000, "test-001", false);
|
||||
EXPECT_EQ(app != nullptr, 1);
|
||||
|
||||
int ret = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user