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