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 
16 #include <csignal>
17 #include <cstdint>
18 #include <unistd.h>
19 #include "dfx_log.h"
20 #include "dfx_dump_request.h"
21 #include "fault_logger_daemon.h"
22 #include "faultloggerd_client.h"
23 #include "securec.h"
24 
25 #if defined(DEBUG_CRASH_LOCAL_HANDLER)
26 #include "dfx_signal_local_handler.h"
27 #include "dfx_util.h"
28 
DoGetCrashFd(const struct ProcessDumpRequest * request)29 static int DoGetCrashFd(const struct ProcessDumpRequest* request)
30 {
31     OHOS::HiviewDFX::FaultLoggerDaemon daemon;
32     int32_t type = (int32_t)FaultLoggerType::CPP_CRASH;
33     int fd = daemon.CreateFileForRequest(type, request->pid, request->tid, request->timeStamp, false);
34     return fd;
35 }
36 #endif
37 
main(int argc,char * argv[])38 int main(int argc, char *argv[])
39 {
40 #if defined(DEBUG_CRASH_LOCAL_HANDLER)
41     DFX_GetCrashFdFunc(DoGetCrashFd);
42     DFX_InstallLocalSignalHandler();
43 #endif
44     OHOS::HiviewDFX::FaultLoggerDaemon daemon;
45     daemon.StartServer();
46     return 0;
47 }
48