• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef DFX_DUMP_RES_H
16 #define DFX_DUMP_RES_H
17 
18 #include <string>
19 
20 namespace OHOS {
21 namespace HiviewDFX {
22 enum ProcessDumpRes {
23     DUMP_ESUCCESS = 0,  /* no error */
24     DUMP_EREADREQUEST,  /* read request error */
25     DUMP_EGETPPID,      /* ppid is crash */
26     DUMP_EATTACH,       /* ptrace attach thread failed */
27     DUMP_EGETFD,        /* get fd error */
28     DUMP_ENOMEM,        /* out of memory */
29     DUMP_EBADREG,       /* bad register number */
30     DUMP_EREADONLYREG,  /* attempt to write read-only register */
31     DUMP_ESTOPUNWIND,   /* stop unwinding */
32     DUMP_EINVALIDIP,    /* invalid IP */
33     DUMP_EBADFRAME,     /* bad frame */
34     DUMP_EINVAL,        /* unsupported operation or bad value */
35     DUMP_EBADVERSION,   /* unwind info has unsupported version */
36     DUMP_ENOINFO,       /* no unwind info found */
37 };
38 
39 struct DumpResMsg {
40     int32_t res;
41     char strRes[128];
42 } __attribute__((packed));
43 
44 class DfxDumpRes final {
45 public:
46     static DfxDumpRes &GetInstance();
47 
48     int32_t GetRes() const;
49     void SetRes(int32_t res);
50 
51     const char *GetResStr(const int res) const;
52 
53     std::string ToString() const;
54 private:
55     DfxDumpRes() = default;
56     ~DfxDumpRes() = default;
57 
58     DumpResMsg resMsg_;
59 };
60 } // namespace HiviewDFX
61 } // namespace OHOS
62 #endif
63