• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "dfx_dump_catcher_errno.h"
17 
18 namespace OHOS {
19 namespace HiviewDFX {
20 
21 const std::map<int32_t, std::string> ERROR_CODE_MAP = {
22     { DUMPCATCH_ESUCCESS, std::string("success") },
23     { DUMPCATCH_EPARAM, std::string("param error") },
24     { DUMPCATCH_NO_PROCESS, std::string("process has exited") },
25     { DUMPCATCH_IS_DUMPING, std::string("process is dumping") },
26     { DUMPCATCH_EPERMISSION, std::string("check permission error") },
27     { DUMPCATCH_HAS_CRASHED, std::string("process has been crashed") },
28     { DUMPCATCH_ECONNECT, std::string("failed to connect to faultloggerd") },
29     { DUMPCATCH_EWRITE, std::string("failed to write data to faultloggerd") },
30     { DUMPCATCH_EFD, std::string("buf or res fd error") },
31     { DUMPCATCH_EPOLL, std::string("poll error") },
32     { DUMPCATCH_DUMP_EPTRACE, std::string("failed to ptrace thread") },
33     { DUMPCATCH_DUMP_EUNWIND, std::string("failed to unwind") },
34     { DUMPCATCH_DUMP_EMAP, std::string("failed to find map") },
35     { DUMPCATCH_TIMEOUT_SIGNAL_BLOCK, std::string("signal has been block by target process") },
36     { DUMPCATCH_TIMEOUT_KERNEL_FROZEN, std::string("target process has been frozen in kernel") },
37     { DUMPCATCH_TIMEOUT_PROCESS_KILLED, std::string("target process has been killed during dumping") },
38     { DUMPCATCH_TIMEOUT_DUMP_SLOW, std::string("failed to fully dump due to timeout") },
39     { DUMPCATCH_KERNELSTACK_ECREATE, std::string("kernelstack fail due to create hstackval fail") },
40     { DUMPCATCH_KERNELSTACK_EOPEN, std::string("kernelstack fail due to open bbox fail") },
41     { DUMPCATCH_KERNELSTACK_EIOCTL, std::string("kernelstack fail due to ioctl fail") },
42     { DUMPCATCH_KERNELSTACK_NONEED, std::string("no need to dump kernelstack") },
43     { DUMPCATCH_UNKNOWN, std::string("unknown reason") }
44 };
45 
ToString(const int32_t res)46 std::string DfxDumpCatchError::ToString(const int32_t res)
47 {
48     auto it = ERROR_CODE_MAP.find(res);
49     if (it != ERROR_CODE_MAP.end()) {
50         return it->second;
51     }
52     return std::string("invalid error code");
53 }
54 } // namespace HiviewDFX
55 } // namespace OHOS