1e41f4b71Sopenharmony_ci# FaultLogger Development
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci### Function Introduction
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ciFaultLogger is a maintenance and debugging log framework provided by OpenHarmony. It enables unified detection, log collection, log storage, and log reporting for application, ability, and system service process crashes. It is available for the standard system and the Linux kernel-based small system.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciFaultLogger is responsible for fault recording of OpenHarmony. It runs on the following two components based on the service object:
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci- Hiview: serves functional modules at the application layer and native layer. It manages various fault information in the system and provides APIs for modules to query faults.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci- Faultloggerd: serves the crash process. It collects information about the abnormal daemon process in C/C++ and obtains call stack information of the process.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciThe following figure shows the process of handling a process crash based on the FaultLogger service.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci  **Figure 1** Process crash handling flowchart
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci![Process crash handling flowchart](figures/process_crash_handling_flowchart.png)
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci1. After the signal processor is installed, SignalHandler uses the **DFX_SignalHandler** function to detect and respond to the process crash exception signal thrown by the kernel.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci2. When detecting a process crash exception signal, SignalHandler forks a child process and runs ProcessDump to dump the stack information of the crashed process and thread.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci3. ProcessDump applies to Faultloggerd for a file handle for storing fault logs. After reading the exception stack information, ProcessDump writes the information to the file to generate a complete crash log.
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci4. After collecting the complete crash log, ProcessDump reports the log to Hiview by using the **AddFaultLog()** API. Hiview generates a simplified crash log and reports a system event through HiSysEvent.
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ciWith this design, a small-system with limited resources can obtain logs for locating crash faults as long as Faultloggerd is deployed.
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci### Use Cases
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ciFaultloggerd provides a lightweight approach for you to locate crash or suspension problems during development and testing.
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ciThe following table describes the application scenarios.
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci  **Table 1** Application scenarios of the Faultloggerd module
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci| Scenario| Tool| Usage|
43e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
44e41f4b71Sopenharmony_ci| Understanding of the function call sequence| DumpCatcher API |  See [Using DumpCatcher APIs to Obtain Call Stack Information](#using-dumpcatcher-apis-to-obtain-call-stack-information).|
45e41f4b71Sopenharmony_ci| Application suspension or high CPU usage| DumpCatcher Command Tool |  See [Using DumpCatcher Commands to Obtain Call Stack Information](#using-dumpcatcher-commands-to-obtain-call-stack-information).|
46e41f4b71Sopenharmony_ci| Crash fault location| Crash log and addr2line tool| For details, see [Locating Faults Based on the Crash Log](#locating-faults-based-on-the-crash-log).|
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci## Using DumpCatcher APIs to Obtain Call Stack Information
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci### Available APIs
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ciDumpCatcher can capture the call stack information of the specified process (thread) on OpenHarmony.
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci  **Table 2** DumpCatcher APIs
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci| Class| API| Description|
59e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
60e41f4b71Sopenharmony_ci| DfxDumpCatcher | bool DumpCatch(const int pid, const int tid, std::string&amp; msg) |   Return value:<br>- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.<br>- **false**: Dumping of stack information has failed.<br>  Input arguments:<br>- **pid**: target process ID.<br>- **tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.<br>  Output arguments:<br>- **msg**: If back trace is successful, call stack information is returned through **msg**.|
61e41f4b71Sopenharmony_ci| DfxDumpCatcher | bool DumpCatchMix(const int pid, const int tid, std::string&amp; msg) |   Return value:<br>- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.<br>- **false**: Dumping of stack information has failed.<br>  Input arguments:<br>**pid**: target process ID.<br>- **tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.<br>  Output arguments:<br>- **msg**: If back trace is successful, hybrid stack information is returned through **msg**.|
62e41f4b71Sopenharmony_ci| DfxDumpCatcher | bool DumpCatchFd(const int pid, const int tid, std::string&amp; msg, int fd) |   Return value:<br>- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.<br>- **false**: Dumping of stack information has failed.<br>  Input arguments:<br>**pid**: target process ID.<br>- **tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.<br>- **fd**: handle of the file to be written.<br>  Output parameters:<br>- **msg**: If back trace is successful, call stack information is returned through **msg**.|
63e41f4b71Sopenharmony_ci| DfxDumpCatcher | bool DumpCatchMultiPid(const std::vector\<int> pidV, std::string&amp; msg) |   Return value:<br>- **true**: Dumping of stack information is successful. Related information is stored in the msg string object.<br>- **false**: Dumping of stack information has failed.<br>  Input arguments:<br>- **pidV**: target process ID list.<br>  Output arguments:<br>- **msg**: If back trace is successful, call stack information is returned through **msg**.|
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci> **NOTE**
66e41f4b71Sopenharmony_ci> If the PID that calls this API is different from the target PID, the caller must be the **system** or **root** user.
67e41f4b71Sopenharmony_ci
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci### How to Develop
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ciYou can use DumpCatcher to obtain call stack information for the specified process (thread) of an application. The following uses the **dumpcatcherdemo** module as an example to describe how to use the DumpCatcher APIs to obtain the call stack information.
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci1. Add the DumpCatcher dependency to the build file. Take /base/hiviewdfx/faultloggerd/example/BUILD.gn as an example. Add the **dump_catcher.h** file path to **include_dirs** and add the required **//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher** module to **deps**.
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci   ```
78e41f4b71Sopenharmony_ci   import("//base/hiviewdfx/faultloggerd/faultloggerd.gni")
79e41f4b71Sopenharmony_ci   import("//build/ohos.gni")
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci   config("dumpcatcherdemo_config") {
82e41f4b71Sopenharmony_ci     visibility = [ ":*" ]
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci     include_dirs = [
85e41f4b71Sopenharmony_ci       ".",
86e41f4b71Sopenharmony_ci       "//utils/native/base/include",
87e41f4b71Sopenharmony_ci       "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher/include/",  # Add the path of the dump_catcher header file.
88e41f4b71Sopenharmony_ci     ]
89e41f4b71Sopenharmony_ci   }
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci   ohos_executable("dumpcatcherdemo") {
92e41f4b71Sopenharmony_ci    sources = [ "dump_catcher_demo.cpp" ]
93e41f4b71Sopenharmony_ci    configs = [ ":dumpcatcherdemo_config" ]
94e41f4b71Sopenharmony_ci    deps = [
95e41f4b71Sopenharmony_ci      "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher", # Add the DumpCatcher module dependency.
96e41f4b71Sopenharmony_ci      "//utils/native/base:utils",
97e41f4b71Sopenharmony_ci    ]
98e41f4b71Sopenharmony_ci    external_deps = [ "hilog_native:libhilog" ]
99e41f4b71Sopenharmony_ci    install_enable = true
100e41f4b71Sopenharmony_ci    part_name = "faultloggerd"
101e41f4b71Sopenharmony_ci    subsystem_name = "hiviewdfx"
102e41f4b71Sopenharmony_ci   }
103e41f4b71Sopenharmony_ci   ```
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci2. Define the header file. Take **/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.h** as an example. In the sample code, the function of the stack depth test is called to construct a call stack with a specified depth.
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci   ```
108e41f4b71Sopenharmony_ci   #ifndef DUMP_CATCHER_DEMO_H
109e41f4b71Sopenharmony_ci   #define DUMP_CATCHER_DEMO_H
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci   #include <inttypes.h>
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci   #define NOINLINE __attribute__((noinline))
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci   // Define the macro function to automatically generate a function call chain.
116e41f4b71Sopenharmony_ci   #define GEN_TEST_FUNCTION(FuncNumA, FuncNumB)          \
117e41f4b71Sopenharmony_ci       __attribute__((noinline)) int TestFunc##FuncNumA() \
118e41f4b71Sopenharmony_ci       {                                                  \
119e41f4b71Sopenharmony_ci           return TestFunc##FuncNumB();                   \
120e41f4b71Sopenharmony_ci       }
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci   // Call the function of the stack depth test.
123e41f4b71Sopenharmony_ci   int TestFunc0(void);
124e41f4b71Sopenharmony_ci   int TestFunc1(void);
125e41f4b71Sopenharmony_ci   int TestFunc2(void);
126e41f4b71Sopenharmony_ci   int TestFunc3(void);
127e41f4b71Sopenharmony_ci   int TestFunc4(void);
128e41f4b71Sopenharmony_ci   int TestFunc5(void);
129e41f4b71Sopenharmony_ci   int TestFunc6(void);
130e41f4b71Sopenharmony_ci   int TestFunc7(void);
131e41f4b71Sopenharmony_ci   int TestFunc8(void);
132e41f4b71Sopenharmony_ci   int TestFunc9(void);
133e41f4b71Sopenharmony_ci   int TestFunc10(void);
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci   #endif // DUMP_CATCHER_DEMO_H
136e41f4b71Sopenharmony_ci   ```
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci3. Call the **DumpCatch** API in the source file. Take **/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.cpp** as an example. Include the **dfx_dump_catcher.h** file, declare the **DfxDumpCatcher** object, use the macro function to construct a function call chain, call the **DumpCatch** method, and pass the required process ID and thread ID of the call stack into this method.
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci   ```
141e41f4b71Sopenharmony_ci   #include "dump_catcher_demo.h"
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci   #include <iostream>
144e41f4b71Sopenharmony_ci   #include <string>
145e41f4b71Sopenharmony_ci   #include <unistd.h>
146e41f4b71Sopenharmony_ci   // Include the dfx_dump_catcher.h file.
147e41f4b71Sopenharmony_ci   #include "dfx_dump_catcher.h"
148e41f4b71Sopenharmony_ci   using namespace std;
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci   NOINLINE int TestFunc10(void)
151e41f4b71Sopenharmony_ci   {
152e41f4b71Sopenharmony_ci       OHOS::HiviewDFX::DfxDumpCatcher dumplog;
153e41f4b71Sopenharmony_ci       string msg = "";
154e41f4b71Sopenharmony_ci       bool ret = dumplog.DumpCatch(getpid(), gettid(), msg);  // Call the DumpCatch API to obtain the call stack information.
155e41f4b71Sopenharmony_ci       if (ret) {
156e41f4b71Sopenharmony_ci           cout << msg << endl;
157e41f4b71Sopenharmony_ci       }
158e41f4b71Sopenharmony_ci       return 0;
159e41f4b71Sopenharmony_ci   }
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci   // Use the macro function to automatically generate a function call chain.
162e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(0, 1)
163e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(1, 2)
164e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(2, 3)
165e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(3, 4)
166e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(4, 5)
167e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(5, 6)
168e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(6, 7)
169e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(7, 8)
170e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(8, 9)
171e41f4b71Sopenharmony_ci   GEN_TEST_FUNCTION(9, 10)
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci   int main(int argc, char *argv[])
174e41f4b71Sopenharmony_ci   {
175e41f4b71Sopenharmony_ci       TestFunc0();
176e41f4b71Sopenharmony_ci       return 0;
177e41f4b71Sopenharmony_ci   }
178e41f4b71Sopenharmony_ci   ```
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci## Using DumpCatcher Commands to Obtain Call Stack Information
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci### Tool Description
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ciDumpCatcher Command Tool is a command line interface (CLI)-based tool for capturing call stack information on OpenHarmony. It uses the **-p** and **-t** parameters to specify the process and thread. After the command is executed, the thread stack information of the specified process is displayed in the CLI window. By specifying the **-m** parameter, you can also capture the JS and Native hybrid stack information of an application process.
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci  **Table 3** Usage of the DumpCatcher Command Tool
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci| Tool| Path| Command| Description|
191e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
192e41f4b71Sopenharmony_ci| dumpcatcher | /system/bin | - dumpcatcher -p [pid]<br>- dumpcatcher -p [pid] -t [tid]<br>- dumpcatcher -m -p [pid]<br>- dumpcatcher -m -p [pid] -t [tid]<br>| **Description:**<br>- **-p [pid]**: prints all thread stack information of the specified process.<br>- **-p [pid] -t [tid]**: prints stack information for the specified thread of the specified process.<br>- **-m -p [pid]**: prints hybrid stack information for all threads of the specified process.<br>- **-m -p [pid] -t [tid]**: prints hybrid stack information for the specified thread of the specified process.<br>**Return value:**<br>If the stack information is parsed successfully, the information is displayed in the standard output. If the stack information fails to be parsed, error information is displayed.|
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci### Development Example
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ciPrint call stack information of the **hiview** process.
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci```
201e41f4b71Sopenharmony_ci# ps -ef |grep hiview
202e41f4b71Sopenharmony_cihiview         240     1 0 17:01:49 ?     00:00:14 hiview
203e41f4b71Sopenharmony_ciroot          1822  1560 7 20:56:36 pts/0 00:00:00 grep hiview
204e41f4b71Sopenharmony_ci# dumpcatcher -p 240 -t 240
205e41f4b71Sopenharmony_ciResult: 0 ( no error )
206e41f4b71Sopenharmony_ciTimestamp:2017-08-05 20:56:43.000
207e41f4b71Sopenharmony_ciPid:240
208e41f4b71Sopenharmony_ciUid:1201
209e41f4b71Sopenharmony_ciProcess name:/system/bin/hiview
210e41f4b71Sopenharmony_ciTid:240, Name:hiview
211e41f4b71Sopenharmony_ci#00 pc 00098f8c /system/lib/ld-musl-arm.so.1(ioctl+68)
212e41f4b71Sopenharmony_ci#01 pc 0000e2a1 /system/lib/chipset-pub-sdk/libipc_single.z.so
213e41f4b71Sopenharmony_ci#02 pc 0000ed59 /system/lib/chipset-pub-sdk/libipc_single.z.so
214e41f4b71Sopenharmony_ci#03 pc 0000ee1f /system/lib/chipset-pub-sdk/libipc_single.z.so
215e41f4b71Sopenharmony_ci#04 pc 0000f745 /system/lib/chipset-pub-sdk/libipc_single.z.so
216e41f4b71Sopenharmony_ci#05 pc 00037577 /system/bin/hiview
217e41f4b71Sopenharmony_ci#06 pc 00025973 /system/bin/hiview
218e41f4b71Sopenharmony_ci#07 pc 000db210 /system/lib/ld-musl-arm.so.1
219e41f4b71Sopenharmony_ci#08 pc 000258d8 /system/bin/hiview
220e41f4b71Sopenharmony_ci#09 pc 0002587c /system/bin/hiview
221e41f4b71Sopenharmony_ci```
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci## Locating Faults Based on the Crash Log
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ciYou can locate faults based on the crash stack logs generated by Faultloggerd. This section describes how to use the addr2line tool to locate a crash fault.
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci1. Find a program crash or construct a crash.
229e41f4b71Sopenharmony_ci   For example, insert the following code into your code to trigger an invalid memory access fault (SIGSEGV).
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci   ```
233e41f4b71Sopenharmony_ci   NOINLINE int TriggerSegmentFaultException()
234e41f4b71Sopenharmony_ci   {
235e41f4b71Sopenharmony_ci       printf("test TriggerSegmentFaultException \n");
236e41f4b71Sopenharmony_ci       // Forcibly convert the type to construct a crash.
237e41f4b71Sopenharmony_ci       int *a = (int *)(&RaiseAbort);
238e41f4b71Sopenharmony_ci       *a = SIGSEGV;
239e41f4b71Sopenharmony_ci       return 0;
240e41f4b71Sopenharmony_ci   }
241e41f4b71Sopenharmony_ci   ```
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ci2. Obtain the crash function call stack log.
244e41f4b71Sopenharmony_ci   The process generates a temporary log file in the** /data/log/faultlog/temp** directory due to an exception that is not handled. The naming rule of the temporary log file is as follows:
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci   ```
248e41f4b71Sopenharmony_ci   cppcrash-pid-time
249e41f4b71Sopenharmony_ci   ```
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci   The generated call stack information is as follows:
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci   ```
255e41f4b71Sopenharmony_ci   Timestamp:2017-08-05 17:35:03.000
256e41f4b71Sopenharmony_ci   Pid:816
257e41f4b71Sopenharmony_ci   Uid:0
258e41f4b71Sopenharmony_ci   Process name:./crasher_c
259e41f4b71Sopenharmony_ci   Reason:Signal:SIGSEGV(SEGV_ACCERR)@0x0042d33d
260e41f4b71Sopenharmony_ci   Fault thread Info:
261e41f4b71Sopenharmony_ci   Tid:816, Name:crasher
262e41f4b71Sopenharmony_ci   #00 pc 0000332c /data/crasher(TriggerSegmentFaultException+15)(8bc37ceb8d6169e919d178fdc7f5449e)
263e41f4b71Sopenharmony_ci   #01 pc 000035c7 /data/crasher(ParseAndDoCrash+277)(8bc37ceb8d6169e919d178fdc7f5449e)
264e41f4b71Sopenharmony_ci   #02 pc 00003689 /data/crasher(main+39)(8bc37ceb8d6169e919d178fdc7f5449e)
265e41f4b71Sopenharmony_ci   #03 pc 000c3b08 /system/lib/ld-musl-arm.so.1(__libc_start_main+116)
266e41f4b71Sopenharmony_ci   #04 pc 000032f8 /data/crasher(_start_c+112)(8bc37ceb8d6169e919d178fdc7f5449e)
267e41f4b71Sopenharmony_ci   #05 pc 00003284 /data/crasher(_start+32)(8bc37ceb8d6169e919d178fdc7f5449e)
268e41f4b71Sopenharmony_ci   Registers:
269e41f4b71Sopenharmony_ci   r0:0042d33d r1:0000000b r2:1725d4c4 r3:b6f9fa84
270e41f4b71Sopenharmony_ci   r4:bec97e69 r5:b6fc0268 r6:0042d661 r7:bec97d60
271e41f4b71Sopenharmony_ci   r8:00000000 r9:00000000 r10:00000000
272e41f4b71Sopenharmony_ci   fp:bec97d20 ip:00000020 sp:bec97cd0 lr:b6f9fae4 pc:0042d32c
273e41f4b71Sopenharmony_ci   ```
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci3. Use the addr2line tool to analyze the call stack information.
276e41f4b71Sopenharmony_ci   Then, parse the line number based on the offset address.
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci   ```
280e41f4b71Sopenharmony_ci   root:~/OpenHarmony/out/hi3516dv300/exe.unstripped/hiviewdfx/faultloggerd$ addr2line -e crasher 0000332c
281e41f4b71Sopenharmony_ci   base/hiviewdfx/faultloggerd/tools/crasher/dfx_crasher.c:57
282e41f4b71Sopenharmony_ci   ```
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci   The crash is caused by assigning a value to an unwritable area. It is in code line 57 in the **dfx_crasher.c** file. You can modify it to avoid the crash.
285