• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 CRASHHANDLER_H
17 #define CRASHHANDLER_H
18 
19 #include <string>
20 #include <cstdint>
21 
22 #ifdef _WIN32
23 #include <windows.h>
24 #endif // _WIN32
25 
26 class CrashHandler {
27 public:
28     CrashHandler() = default;
29     virtual ~CrashHandler() = default;
30     CrashHandler& operator=(const CrashHandler&) = delete;
31     CrashHandler(const CrashHandler&) = delete;
32 
33     void InitExceptionHandler();
34 private:
35 #ifdef _WIN32
36     static void RecordCallStack(const CONTEXT *pContext);
37     static LONG ApplicationCrashHandler(EXCEPTION_POINTERS *pException);
38 #else
39     static void ApplicationCrashHandler(int signal);
40 #endif // _WIN32
41 };
42 
43 #endif // LOCALSOCKET_H
44