mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
[Bug]:异步栈相关修改
Issue:https://gitee.com/openharmony/ability_ability_runtime/issues/ICIU8L Signed-off-by: rentangyu <rentangyu@huawei.com>
This commit is contained in:
@@ -78,7 +78,6 @@ void NapiUncaughtExceptionCallback::operator()(panda::TryCatch& trycatch)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NapiUncaughtExceptionCallback::CallbackTask(napi_value& obj)
|
||||
{
|
||||
std::string errorMsg = GetNativeStrFromJsTaggedObj(obj, "message");
|
||||
@@ -103,6 +102,11 @@ void NapiUncaughtExceptionCallback::CallbackTask(napi_value& obj)
|
||||
}
|
||||
if (errorStack.find(BACKTRACE) != std::string::npos) {
|
||||
summary += "Stacktrace:\n" + GetFuncNameAndBuildId(errorStack);
|
||||
std::string submitterStack = GetSubmitterStackLocal();
|
||||
if (!submitterStack.empty()) {
|
||||
summary.append("========SubmitterStacktrace========\n");
|
||||
summary.append(submitterStack);
|
||||
}
|
||||
} else {
|
||||
summary += "Stacktrace:\n" + errorStack;
|
||||
}
|
||||
@@ -112,11 +116,6 @@ void NapiUncaughtExceptionCallback::CallbackTask(napi_value& obj)
|
||||
summary.append(str);
|
||||
}
|
||||
#endif // SUPPORT_GRAPHICS
|
||||
std::string submitterStack = GetSubmitterStackLocal();
|
||||
if (!submitterStack.empty()) {
|
||||
summary.append("========SubmitterStacktrace========\n");
|
||||
summary.append(submitterStack);
|
||||
}
|
||||
if (uncaughtTask_) {
|
||||
uncaughtTask_(summary, errorObj);
|
||||
}
|
||||
@@ -183,16 +182,19 @@ std::string NapiUncaughtExceptionCallback::GetSubmitterStackLocal()
|
||||
}
|
||||
sbmitterStack = reinterpret_cast<SubmitterStackFunc>(dlsym(handle, "DfxGetSubmitterStackLocal"));
|
||||
if (sbmitterStack == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSENV, "dlsym libasync_stack failed");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "dlsym libasync_stack failed, %{public}s", dlerror());
|
||||
dlclose(handle);
|
||||
return "";
|
||||
}
|
||||
const size_t bufferSize = 64 * 1024;
|
||||
char stackTrace[bufferSize] = {0};
|
||||
int result = sbmitterStack(stackTrace, bufferSize);
|
||||
if (result == 0) {
|
||||
dlclose(handle);
|
||||
return stackTrace;
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSENV, "submitterStack interface failed");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "submitterStack interface failed, result: %{public}d", result);
|
||||
dlclose(handle);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -327,6 +327,7 @@ HWTEST_F(NapiUncaughtExceptionCallbackTest, GetFuncNameAndBuildIdTest_0100, Test
|
||||
{
|
||||
GTEST_LOG_(INFO) << "GetFuncNameAndBuildIdTest_0100 start";
|
||||
std::ostringstream stack;
|
||||
stack << "Cannot get SourceMap info, dump raw stack:\n";
|
||||
Backtrace(stack);
|
||||
std::string stackinfo = NapiUncaughtExceptionCallback::GetFuncNameAndBuildId(stack.str());
|
||||
ASSERT_EQ(stackinfo.find("GetFuncNameAndBuildIdTest") != std::string::npos, true);
|
||||
@@ -363,6 +364,7 @@ HWTEST_F(NapiUncaughtExceptionCallbackTest, GetSubmitterStackLocal_0100, TestSiz
|
||||
{
|
||||
GTEST_LOG_(INFO) << "GetSubmitterStackLocal_0100 start";
|
||||
setenv("HAP_DEBUGGABLE", "true", 1);
|
||||
ASSERT_EQ(NapiUncaughtExceptionCallback::GetSubmitterStackLocal(), "");
|
||||
uv_timer_t timerHandle;
|
||||
uv_work_t work;
|
||||
uv_loop_t* loop = uv_default_loop();
|
||||
|
||||
Reference in New Issue
Block a user