diff --git a/interfaces/innerkits/dump_catcher/dfx_dump_catcher.cpp b/interfaces/innerkits/dump_catcher/dfx_dump_catcher.cpp index cfa53ed32f7d636783124bb7238c14701c2e8bfa..5ae66bd17bdbe2f42765d95e7f11197994143408 100644 --- a/interfaces/innerkits/dump_catcher/dfx_dump_catcher.cpp +++ b/interfaces/innerkits/dump_catcher/dfx_dump_catcher.cpp @@ -367,7 +367,7 @@ static bool IsSignalBlocked(int pid, int32_t& ret) std::string threadStatusPath = StringPrintf("/proc/%d/task/%d/status", pid, targetTid); if (!LoadStringFromFile(threadStatusPath, content) || content.empty()) { DFXLOGE("the pid(%{public}d)thread(%{public}d) read status fail, errno(%{public}d)", pid, targetTid, errno); - ret = DUMPCATCH_UNKNOWN; + ret = DUMPCATCH_TIMEOUT_PARSE_FAIL_READ_ESTATUS; return true; } @@ -386,7 +386,7 @@ static bool IsFrozen(int pid, int32_t& ret) std::string cgroupPath = StringPrintf("/proc/%d/cgroup", pid); if (!LoadStringFromFile(cgroupPath, content)) { DFXLOGE("the pid (%{public}d) read cgroup fail, errno (%{public}d)", pid, errno); - ret = DUMPCATCH_UNKNOWN; + ret = DUMPCATCH_TIMEOUT_PARSE_FAIL_READ_ECGROUP; return true; } @@ -475,7 +475,7 @@ void DfxDumpCatcher::Impl::DealWithPollRet(int pollRet, int pid, int32_t& ret, s } else if (msg.find("mapinfo is not exist") != std::string::npos) { ret = DUMPCATCH_DUMP_EMAP; } else { - ret = DUMPCATCH_UNKNOWN; + ret = DUMPCATCH_DUMP_ERROR; } break; default: @@ -516,6 +516,12 @@ void DfxDumpCatcher::Impl::DealWithSdkDumpRet(int sdkdumpRet, int pid, int32_t& } msg.append("Result: pid(" + std::to_string(pid) + ") process fail to write to faultloggerd.\n"); ret = DUMPCATCH_EWRITE; + } else { + if (uid == HIVIEW_UID || uid == FOUNDATION_UID) { + stack_ = stackKit_.GetProcessStackWithTimeout(pid, WAIT_GET_KERNEL_STACK_TIMEOUT); + } + msg.append("Result: pid(" + std::to_string(pid) + ") faultloggerd maybe exception occurred.\n"); + ret = DUMPCATCH_EFAULTLOGGERD; } DFXLOGW("%{public}s :: %{public}s", __func__, msg.c_str()); } diff --git a/interfaces/innerkits/dump_catcher/dfx_dump_catcher_errno.cpp b/interfaces/innerkits/dump_catcher/dfx_dump_catcher_errno.cpp index 9b869d24a0c99a6d8a826c5d5842f3ed2a473cb3..217b0c821364bafa1a94b3b5164fcfaa3aa69c0f 100644 --- a/interfaces/innerkits/dump_catcher/dfx_dump_catcher_errno.cpp +++ b/interfaces/innerkits/dump_catcher/dfx_dump_catcher_errno.cpp @@ -33,14 +33,18 @@ const DumpCatchErrInfo ERROR_CODE_MAPS[] = { { DUMPCATCH_EWRITE, "failed to write data to faultloggerd" }, { DUMPCATCH_EFD, "buf or res fd error" }, { DUMPCATCH_EPOLL, "poll error" }, + { DUMPCATCH_EFAULTLOGGERD, "faultloggerd maybe exception occurred" }, { DUMPCATCH_DUMP_EPTRACE, "failed to ptrace thread" }, { DUMPCATCH_DUMP_EUNWIND, "failed to unwind" }, { DUMPCATCH_DUMP_EMAP, "failed to find map" }, + { DUMPCATCH_DUMP_ERROR, "exception occurred in processdump" }, { DUMPCATCH_TIMEOUT_SIGNAL_BLOCK, "signal has been block by target process" }, { DUMPCATCH_TIMEOUT_KERNEL_FROZEN, "target process has been frozen in kernel" }, { DUMPCATCH_TIMEOUT_PROCESS_KILLED, "target process has been killed during dumping" }, { DUMPCATCH_TIMEOUT_DUMP_SLOW, "failed to fully dump due to timeout" }, { DUMPCATCH_TIMEOUT_DUMP_IN_SLOWPERIOD, "in dump slow period and return kernel stack" }, + { DUMPCATCH_TIMEOUT_PARSE_FAIL_READ_ESTATUS, "dump timeout, parse reason fail for read status fail" }, + { DUMPCATCH_TIMEOUT_PARSE_FAIL_READ_ECGROUP, "dump timeout, parse reason fail for read cgroup fail" }, { DUMPCATCH_KERNELSTACK_ECREATE, "kernelstack fail due to create hstackval fail" }, { DUMPCATCH_KERNELSTACK_EOPEN, "kernelstack fail due to open bbox fail" }, { DUMPCATCH_KERNELSTACK_EIOCTL, "kernelstack fail due to ioctl fail" }, diff --git a/interfaces/innerkits/dump_catcher/dfx_dump_catcher_errno.h b/interfaces/innerkits/dump_catcher/dfx_dump_catcher_errno.h index 427a94c591eeec1443084eb5e86b56cec1027e53..a6a334231d7c7b44f89afcc98dcc7b60d675c824 100644 --- a/interfaces/innerkits/dump_catcher/dfx_dump_catcher_errno.h +++ b/interfaces/innerkits/dump_catcher/dfx_dump_catcher_errno.h @@ -38,6 +38,7 @@ enum DumpCatchErrorCode : int32_t { DUMPCATCH_EWRITE, /* failed to write data to faultloggerd */ DUMPCATCH_EFD, /* buf or res fd error */ DUMPCATCH_EPOLL, /* poll error */ + DUMPCATCH_EFAULTLOGGERD, /* faultloggerd maybe exception occurred */ DUMPCATCH_DUMP_EPTRACE = 201, /* failed to ptrace thread */ DUMPCATCH_DUMP_EUNWIND, /* failed to unwind */ @@ -45,12 +46,15 @@ enum DumpCatchErrorCode : int32_t { DUMPCATCH_DUMP_ESYMBOL_NO_PARSE, /* no enough time to parse symbol */ DUMPCATCH_DUMP_ESYMBOL_PARSE_TIMEOUT, /* parse symbol timeout */ DUMPCATCH_DUMP_SELF_FAIL, /* dump self fail */ + DUMPCATCH_DUMP_ERROR, /* exception occurred in processdump */ DUMPCATCH_TIMEOUT_SIGNAL_BLOCK = 301, /* signal has been block by target process */ DUMPCATCH_TIMEOUT_KERNEL_FROZEN, /* target process has been frozen in kernel */ DUMPCATCH_TIMEOUT_PROCESS_KILLED, /* target process has been killed during dumping */ DUMPCATCH_TIMEOUT_DUMP_SLOW, /* failed to fully dump due to timeout */ DUMPCATCH_TIMEOUT_DUMP_IN_SLOWPERIOD, /* check in dumpcatch slow period and return kernel stack*/ + DUMPCATCH_TIMEOUT_PARSE_FAIL_READ_ESTATUS, /* dump timeout, parse reason fail for read status fail*/ + DUMPCATCH_TIMEOUT_PARSE_FAIL_READ_ECGROUP, /* dump timeout, parse reason fail for read cgroup fail*/ DUMPCATCH_UNKNOWN = 400, /* unknown reason */