From 731015a0e5aab0469c7e05516c77a8bb304e4fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=8D=9A=E6=96=AF?= Date: Mon, 23 Jun 2025 17:38:51 +0800 Subject: [PATCH] supplement errorcode in dumpcatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 董博斯 --- .../innerkits/dump_catcher/dfx_dump_catcher.cpp | 12 +++++++++--- .../dump_catcher/dfx_dump_catcher_errno.cpp | 4 ++++ .../innerkits/dump_catcher/dfx_dump_catcher_errno.h | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/dump_catcher/dfx_dump_catcher.cpp b/interfaces/innerkits/dump_catcher/dfx_dump_catcher.cpp index cfa53ed32..5ae66bd17 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 9b869d24a..217b0c821 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 427a94c59..a6a334231 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 */ -- Gitee