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