• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #ifndef KERNEL_SNAPSHOT_DATA_H
17 #define KERNEL_SNAPSHOT_DATA_H
18 
19 #include <string>
20 #include <unordered_map>
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 constexpr int DECIMAL_BASE = 10;
25 
26 enum class CrashSection {
27     BUILD_INFO,
28     TIME_STAMP,
29     PID,
30     UID,
31     PROCESS_NAME,
32     REASON,
33     FAULT_THREAD_INFO,
34     CREGISTERS,
35     MEMORY_NEAR_REGISTERS,
36     FAULT_STACK,
37     MAPS,
38     EXCEPTION_REGISTERS,
39     INVALID_SECTION
40 };
41 
42 enum class SnapshotSection {
43     TRANSACTION_START,
44     EXCEPTION_REGISTERS,
45     ABORT_ADDRESS_PTE,
46     THREAD_INFO,
47     DUMP_REGISTERS,
48     DUMP_FPU_OR_SIMD_REGISTERS,
49     STACK_BACKTRACE,
50     ELF_LOAD_INFO,
51     DATA_ON_TARGET_OF_LAST_BL,
52     DATA_AROUND_REGS,
53     CONTENT_OF_USER_STACK,
54     BASE_ACTV_DUMPED,
55     PROCESS_STATISTICS,
56     TRANSACTION_END,
57     INVALID_SECTION
58 };
59 
60 struct SnapshotSectionKeyword {
61     SnapshotSection type;
62     const char* key;
63 };
64 
65 const SnapshotSectionKeyword SNAPSHOT_SECTION_KEYWORDS[] = {
66     {SnapshotSection::TRANSACTION_START,              "[transaction start] now mono_time"},
67     {SnapshotSection::EXCEPTION_REGISTERS,            "Exception registers:"},
68     {SnapshotSection::ABORT_ADDRESS_PTE,              "Abort address pte"},
69     {SnapshotSection::THREAD_INFO,                    "Thread info:"},
70     {SnapshotSection::DUMP_REGISTERS,                 "Dump registers:"},
71     {SnapshotSection::DUMP_FPU_OR_SIMD_REGISTERS,     "Dump fpu or simd registers:"},
72     {SnapshotSection::STACK_BACKTRACE,                "Stack backtrace"},
73     {SnapshotSection::ELF_LOAD_INFO,                  "Elf load info"},
74     {SnapshotSection::DATA_ON_TARGET_OF_LAST_BL,      "Data on target of last"},
75     {SnapshotSection::DATA_AROUND_REGS,               "Data around regs"},
76     {SnapshotSection::CONTENT_OF_USER_STACK,          "Contents of user stack"},
77     {SnapshotSection::BASE_ACTV_DUMPED,               "[base actv dumped]"},
78     {SnapshotSection::PROCESS_STATISTICS,             "Process statistics:"},
79     {SnapshotSection::TRANSACTION_END,                "[transaction end] now mono_time"}
80 };
81 
82 using CrashMap = std::unordered_map<CrashSection, std::string>;
83 } // namespace HiviewDFX
84 } // namespace OHOS
85 #endif
86