Signed-off-by: unknown <sijunjie@huawei.com>
This commit is contained in:
unknown 2022-08-26 16:35:23 +08:00
parent b86b4c5db0
commit e12ac1ff04
7 changed files with 0 additions and 84 deletions

View File

@ -1620,10 +1620,6 @@ void MainThread::Init(const std::shared_ptr<EventRunner> &runner, const std::sha
void MainThread::HandleSignal(int signal)
{
switch (signal) {
case SIGUSR1: {
dfxHandler_->PostTask(&MainThread::HandleScheduleANRProcess);
break;
}
case SIGNAL_JS_HEAP: {
auto heapFunc = std::bind(&MainThread::HandleDumpHeap, false);
dfxHandler_->PostTask(heapFunc);
@ -1648,35 +1644,6 @@ void MainThread::HandleDumpHeap(bool isPrivate)
}
}
void MainThread::HandleScheduleANRProcess()
{
HILOG_DEBUG("MainThread:HandleScheduleANRProcess start.");
int rFD = -1;
std::string mainThreadStackInfo;
if ((rFD = RequestFileDescriptor(int32_t(FaultLoggerType::JS_STACKTRACE))) < 0) {
HILOG_ERROR("MainThread::HandleScheduleANRProcess request file eescriptor failed");
return;
}
if (applicationForAnr_ != nullptr && applicationForAnr_->GetRuntime() != nullptr) {
mainThreadStackInfo = applicationForAnr_->GetRuntime()->BuildJsStackTrace();
if (write(rFD, mainThreadStackInfo.c_str(), mainThreadStackInfo.size()) !=
(ssize_t)mainThreadStackInfo.size()) {
HILOG_ERROR("MainThread::HandleScheduleANRProcess write main thread stack info failed");
}
}
OHOS::HiviewDFX::DfxDumpCatcher dumplog;
std::string proStackInfo;
if (dumplog.DumpCatch(getpid(), 0, proStackInfo) == false) {
HILOG_ERROR("MainThread::HandleScheduleANRProcess get process stack info failed");
}
if (write(rFD, proStackInfo.c_str(), proStackInfo.size()) != (ssize_t)proStackInfo.size()) {
HILOG_ERROR("MainThread::HandleScheduleANRProcess write process stack info failed");
}
if (rFD != -1) {
close(rFD);
}
}
void MainThread::Start()
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);

View File

@ -587,13 +587,6 @@ void JsRuntime::DumpHeapSnapshot(bool isPrivate)
nativeEngine_->DumpHeapSnapshot(true, DumpFormat::JSON, isPrivate);
}
std::string JsRuntime::BuildJsStackTrace()
{
std::string straceStr = "";
[[maybe_unused]]bool temp = nativeEngine_->BuildJsStackTrace(straceStr);
return straceStr;
}
void JsRuntime::NotifyApplicationState(bool isBackground)
{
if (nativeEngine_ == nullptr) {

View File

@ -62,7 +62,6 @@ public:
void PostTask(const std::function<void()>& task, const std::string& name, int64_t delayTime);
void RemoveTask(const std::string& name);
void DumpHeapSnapshot(bool isPrivate) override;
std::string BuildJsStackTrace() override;
void NotifyApplicationState(bool isBackground) override;
bool RunSandboxScript(const std::string& path);

View File

@ -49,7 +49,6 @@ public:
virtual Language GetLanguage() const = 0;
virtual void StartDebugMode(bool needBreakPoint) = 0;
virtual std::string BuildJsStackTrace() = 0;
virtual void DumpHeapSnapshot(bool isPrivate) = 0;
virtual void NotifyApplicationState(bool isBackground) = 0;
virtual void PreloadSystemModule(const std::string& moduleName) = 0;

View File

@ -419,14 +419,6 @@ private:
bool PrepareAbilityDelegator(const std::shared_ptr<UserTestRecord> &record, bool isStageBased,
BundleInfo& bundleInfo);
/**
*
* @brief The handle of application not response process.
*
* @param sigMessage Recieve the sig message.
*
*/
static void HandleScheduleANRProcess();
static void HandleDumpHeap(bool isPrivate);
static void HandleSignal(int signal);

View File

@ -43,7 +43,6 @@ public:
#endif
private:
int ExcuteANRSaveStackInfoTask(int pid, const SetMissionClosure &task) const;
int PostTimeoutTask(int pid, std::string bundleName = "") const;
private:

View File

@ -41,12 +41,6 @@ int AppNoResponseDisposer::DisposeAppNoResponse(int pid,
return ERR_INVALID_VALUE;
}
auto ret = ExcuteANRSaveStackInfoTask(pid, task);
if (ret != ERR_OK) {
HILOG_ERROR("excute anr save stack info task failed.");
return ret;
}
auto callback = [disposer = shared_from_this(), pid, bundleName = appInfo.bundleName]() {
CHECK_POINTER(disposer);
disposer->PostTimeoutTask(pid, bundleName);
@ -68,12 +62,6 @@ int AppNoResponseDisposer::DisposeAppNoResponse(int pid, const SetMissionClosure
return ret;
}
ret = ExcuteANRSaveStackInfoTask(pid, task);
if (ret != ERR_OK) {
HILOG_ERROR("excute anr save stack info task failed.");
return ret;
}
HILOG_INFO("DisposeAppNoResponse success.");
return ERR_OK;
}
@ -108,26 +96,5 @@ int AppNoResponseDisposer::PostTimeoutTask(int pid, std::string bundleName) cons
return ERR_OK;
}
int AppNoResponseDisposer::ExcuteANRSaveStackInfoTask(int pid, const SetMissionClosure &task) const
{
std::vector<sptr<IRemoteObject>> tokens;
auto appScheduler = DelayedSingleton<AppScheduler>::GetInstance();
CHECK_POINTER_AND_RETURN(appScheduler, ERR_INVALID_VALUE);
if (appScheduler->GetAbilityRecordsByProcessID(pid, tokens) != ERR_OK) {
HILOG_ERROR("Get ability record failed.");
return ERR_INVALID_VALUE;
}
task(tokens);
if (kill(pid, SIGUSR1) != ERR_OK) {
HILOG_ERROR("Send singal SIGUSR1 error.");
return SEND_USR1_SIG_FAIL;
}
return ERR_OK;
}
} // namespace AAFwk
} // namespace OHOS