Feature: add Startup Debugging, add parameters -N for aa

Signed-off-by: hongtao <hongtao11@huawei.com>
Change-Id: I8de454acb3653eaeb87d9fc49af0fba7a8bf4134
This commit is contained in:
hongtao 2023-04-13 15:57:48 +08:00
parent 28ea2c57ec
commit c5e467d23e
7 changed files with 32 additions and 8 deletions

View File

@ -50,6 +50,7 @@ namespace OHOS {
namespace AAFwk { namespace AAFwk {
using namespace OHOS::Security; using namespace OHOS::Security;
const std::string DEBUG_APP = "debugApp"; const std::string DEBUG_APP = "debugApp";
const std::string NATIVE_DEBUG = "nativeDebug";
const std::string DMS_PROCESS_NAME = "distributedsched"; const std::string DMS_PROCESS_NAME = "distributedsched";
const std::string DMS_MISSION_ID = "dmsMissionId"; const std::string DMS_MISSION_ID = "dmsMissionId";
const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId"; const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
@ -673,7 +674,7 @@ void AbilityRecord::StartingWindowTask(bool isRecent, bool isCold, const Ability
void AbilityRecord::PostCancelStartingWindowHotTask() void AbilityRecord::PostCancelStartingWindowHotTask()
{ {
if (want_.GetBoolParam(DEBUG_APP, false)) { if (want_.GetBoolParam(DEBUG_APP, false) || want_.GetBoolParam(NATIVE_DEBUG, false)) {
HILOG_INFO("PostCancelStartingWindowHotTask was called, debug mode, just return."); HILOG_INFO("PostCancelStartingWindowHotTask was called, debug mode, just return.");
return; return;
} }
@ -701,7 +702,7 @@ void AbilityRecord::PostCancelStartingWindowHotTask()
void AbilityRecord::PostCancelStartingWindowColdTask() void AbilityRecord::PostCancelStartingWindowColdTask()
{ {
if (want_.GetBoolParam(DEBUG_APP, false)) { if (want_.GetBoolParam(DEBUG_APP, false) || want_.GetBoolParam(NATIVE_DEBUG, false)) {
HILOG_INFO("PostCancelStartingWindowColdTask was called, debug mode, just return."); HILOG_INFO("PostCancelStartingWindowColdTask was called, debug mode, just return.");
return; return;
} }
@ -985,7 +986,7 @@ void AbilityRecord::BackgroundAbility(const Closure &task)
} }
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler(); auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
if (handler && task) { if (handler && task) {
if (!want_.GetBoolParam(DEBUG_APP, false)) { if (!want_.GetBoolParam(DEBUG_APP, false) && !want_.GetBoolParam(NATIVE_DEBUG, false)) {
int backgroundTimeout = int backgroundTimeout =
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * BACKGROUND_TIMEOUT_MULTIPLE; AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * BACKGROUND_TIMEOUT_MULTIPLE;
handler->PostTask(task, "background_" + std::to_string(recordId_), backgroundTimeout); handler->PostTask(task, "background_" + std::to_string(recordId_), backgroundTimeout);
@ -1216,7 +1217,7 @@ void AbilityRecord::Terminate(const Closure &task)
CHECK_POINTER(lifecycleDeal_); CHECK_POINTER(lifecycleDeal_);
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler(); auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
if (handler && task) { if (handler && task) {
if (!want_.GetBoolParam(DEBUG_APP, false)) { if (!want_.GetBoolParam(DEBUG_APP, false) && !want_.GetBoolParam(NATIVE_DEBUG, false)) {
int terminateTimeout = int terminateTimeout =
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * TERMINATE_TIMEOUT_MULTIPLE; AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * TERMINATE_TIMEOUT_MULTIPLE;
handler->PostTask(task, "terminate_" + std::to_string(recordId_), terminateTimeout); handler->PostTask(task, "terminate_" + std::to_string(recordId_), terminateTimeout);
@ -1914,7 +1915,7 @@ bool AbilityRecord::IsActiveState() const
void AbilityRecord::SendEvent(uint32_t msg, uint32_t timeOut, int32_t param) void AbilityRecord::SendEvent(uint32_t msg, uint32_t timeOut, int32_t param)
{ {
if (want_.GetBoolParam(DEBUG_APP, false)) { if (want_.GetBoolParam(DEBUG_APP, false) || want_.GetBoolParam(NATIVE_DEBUG, false)) {
HILOG_INFO("Is debug mode, no need to handle time out."); HILOG_INFO("Is debug mode, no need to handle time out.");
return; return;
} }

View File

@ -550,6 +550,7 @@ public:
const AAFwk::Want &GetSpecifiedWant() const; const AAFwk::Want &GetSpecifiedWant() const;
void SetDebugApp(bool isDebugApp); void SetDebugApp(bool isDebugApp);
bool IsDebugApp(); bool IsDebugApp();
void SetNativeDebug(bool isNativeDebug);
void SetRenderRecord(const std::shared_ptr<RenderRecord> &record); void SetRenderRecord(const std::shared_ptr<RenderRecord> &record);
std::shared_ptr<RenderRecord> GetRenderRecord(); std::shared_ptr<RenderRecord> GetRenderRecord();
void SetStartMsg(const AppSpawnStartMsg &msg); void SetStartMsg(const AppSpawnStartMsg &msg);
@ -694,6 +695,7 @@ private:
AAFwk::Want SpecifiedWant_; AAFwk::Want SpecifiedWant_;
std::string moduleName_; std::string moduleName_;
bool isDebugApp_ = false; bool isDebugApp_ = false;
bool isNativeDebug_ = false;
int64_t startTimeMillis_ = 0; // The time of app start(CLOCK_MONOTONIC) int64_t startTimeMillis_ = 0; // The time of app start(CLOCK_MONOTONIC)
int64_t restartTimeMillis_ = 0; // The time of last trying app restart int64_t restartTimeMillis_ = 0; // The time of last trying app restart

View File

@ -59,6 +59,7 @@ struct StartFlags {
static const int DLP_MANAGER = 2; static const int DLP_MANAGER = 2;
static const int DEBUGGABLE = 3; static const int DEBUGGABLE = 3;
static const int ASANENABLED = 4; static const int ASANENABLED = 4;
static const int NATIVEDEBUG = 6;
}; };
union AppSpawnPidMsg { union AppSpawnPidMsg {

View File

@ -1051,6 +1051,7 @@ std::shared_ptr<AppRunningRecord> AppMgrServiceInner::CreateAppRunningRecord(con
appRecord->AddModule(appInfo, abilityInfo, token, hapModuleInfo, want); appRecord->AddModule(appInfo, abilityInfo, token, hapModuleInfo, want);
if (want) { if (want) {
appRecord->SetDebugApp(want->GetBoolParam("debugApp", false)); appRecord->SetDebugApp(want->GetBoolParam("debugApp", false));
appRecord->SetNativeDebug(want->GetBoolParam("nativeDebug", false));
if (want->GetBoolParam(COLD_START, false)) { if (want->GetBoolParam(COLD_START, false)) {
appRecord->SetDebugApp(true); appRecord->SetDebugApp(true);
} }
@ -3221,6 +3222,9 @@ uint32_t AppMgrServiceInner::BuildStartFlags(const AAFwk::Want &want, const Abil
if (abilityInfo.applicationInfo.asanEnabled) { if (abilityInfo.applicationInfo.asanEnabled) {
startFlags = startFlags | (AppSpawn::ClientSocket::APPSPAWN_COLD_BOOT << StartFlags::ASANENABLED); startFlags = startFlags | (AppSpawn::ClientSocket::APPSPAWN_COLD_BOOT << StartFlags::ASANENABLED);
} }
if (want.GetBoolParam("nativeDebug", false)) {
startFlags = startFlags | (AppSpawn::ClientSocket::APPSPAWN_COLD_BOOT << StartFlags::NATIVEDEBUG);
}
return startFlags; return startFlags;
} }

View File

@ -1053,7 +1053,7 @@ void AppRunningRecord::SendEvent(uint32_t msg, int64_t timeOut)
return; return;
} }
if (isDebugApp_) { if (isDebugApp_ || isNativeDebug_) {
HILOG_INFO("Is debug mode, no need to handle time out."); HILOG_INFO("Is debug mode, no need to handle time out.");
return; return;
} }
@ -1334,6 +1334,12 @@ bool AppRunningRecord::IsDebugApp()
return isDebugApp_; return isDebugApp_;
} }
void AppRunningRecord::SetNativeDebug(bool isNativeDebug)
{
HILOG_INFO("SetNativeDebug, value is %{public}d", isNativeDebug);
isNativeDebug_ = isNativeDebug;
}
void AppRunningRecord::SetAppIndex(const int32_t appIndex) void AppRunningRecord::SetAppIndex(const int32_t appIndex)
{ {
appIndex_ = appIndex; appIndex_ = appIndex;

View File

@ -58,7 +58,7 @@ const std::string HELP_MSG_START =
"usage: aa start <options>\n" "usage: aa start <options>\n"
"options list:\n" "options list:\n"
" -h, --help list available commands\n" " -h, --help list available commands\n"
" [-d <device-id>] -a <ability-name> -b <bundle-name> [-m <module-name>] [-p <perf-cmd>] [-D] [-S] " " [-d <device-id>] -a <ability-name> -b <bundle-name> [-m <module-name>] [-p <perf-cmd>] [-D] [-S] [-N] "
" start ability with an element name\n"; " start ability with an element name\n";
const std::string HELP_MSG_STOP_SERVICE = const std::string HELP_MSG_STOP_SERVICE =

View File

@ -35,7 +35,7 @@ namespace AAFwk {
namespace { namespace {
size_t paramLength = 1024; size_t paramLength = 1024;
const std::string SHORT_OPTIONS = "ch:d:a:b:p:s:m:CDS"; const std::string SHORT_OPTIONS = "ch:d:a:b:p:s:m:CDSN";
constexpr struct option LONG_OPTIONS[] = { constexpr struct option LONG_OPTIONS[] = {
{"help", no_argument, nullptr, 'h'}, {"help", no_argument, nullptr, 'h'},
{"device", required_argument, nullptr, 'd'}, {"device", required_argument, nullptr, 'd'},
@ -46,6 +46,7 @@ constexpr struct option LONG_OPTIONS[] = {
{"module", required_argument, nullptr, 'm'}, {"module", required_argument, nullptr, 'm'},
{"cold-start", no_argument, nullptr, 'C'}, {"cold-start", no_argument, nullptr, 'C'},
{"debug", no_argument, nullptr, 'D'}, {"debug", no_argument, nullptr, 'D'},
{"native-debug", no_argument, nullptr, 'N'},
{nullptr, 0, nullptr, 0}, {nullptr, 0, nullptr, 0},
}; };
const std::string SHORT_OPTIONS_APPLICATION_NOT_RESPONDING = "hp:"; const std::string SHORT_OPTIONS_APPLICATION_NOT_RESPONDING = "hp:";
@ -940,6 +941,7 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want& want, std::string& win
bool isDebugApp = false; bool isDebugApp = false;
bool isContinuation = false; bool isContinuation = false;
bool isSanboxApp = false; bool isSanboxApp = false;
bool isNativeDebug = false;
while (true) { while (true) {
counter++; counter++;
@ -1159,6 +1161,11 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want& want, std::string& win
isContinuation = true; isContinuation = true;
break; break;
} }
case 'N': {
// 'aa start -N'
// wait for debug in appspawn
isNativeDebug = true;
}
case 0: { case 0: {
break; break;
} }
@ -1202,6 +1209,9 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want& want, std::string& win
if (isSanboxApp) { if (isSanboxApp) {
want.SetParam("sanboxApp", isSanboxApp); want.SetParam("sanboxApp", isSanboxApp);
} }
if (isNativeDebug) {
want.SetParam("nativeDebug", isNativeDebug);
}
} }
} }