• 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 #ifndef is_ohos_lite
17 #include "kernel_snapshot_manager.h"
18 #endif
19 #include "fault_logger_daemon.h"
20 
21 #if defined(DEBUG_CRASH_LOCAL_HANDLER) && !defined(DFX_ALLOCATE_ASAN)
22 #include "dfx_dump_request.h"
23 #include "dfx_signal_local_handler.h"
24 #include "dfx_util.h"
25 #include "temp_file_manager.h"
26 
DoGetCrashFd(const struct ProcessDumpRequest * request)27 static int DoGetCrashFd(const struct ProcessDumpRequest* request)
28 {
29     if (request == nullptr) {
30         return -1;
31     }
32     return OHOS::HiviewDFX::TempFileManager::CreateFileDescriptor(FaultLoggerType::CPP_CRASH,
33                                                                   request->pid, request->tid, request->timeStamp);
34 }
35 #endif
36 
main(int argc,char * argv[])37 int main(int argc, char *argv[])
38 {
39 #if defined(DEBUG_CRASH_LOCAL_HANDLER) && !defined(DFX_ALLOCATE_ASAN)
40     DFX_GetCrashFdFunc(DoGetCrashFd);
41     DFX_InstallLocalSignalHandler();
42 #endif
43 #ifndef is_ohos_lite
44     OHOS::HiviewDFX::KernelSnapshotManager::StartMonitor();
45 #endif
46     auto& faultLoggerDaemon = OHOS::HiviewDFX::FaultLoggerDaemon::GetInstance();
47     faultLoggerDaemon.StartServer();
48     return 0;
49 }
50