• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef DFX_DEFINE_H
16 #define DFX_DEFINE_H
17 
18 #include <inttypes.h>
19 #include <stdbool.h>
20 
21 #define SIGDUMP 35
22 #define SIGLOCAL_DUMP 36
23 #define SIGLEAK_STACK 42
24 #define PROCESSDUMP_TIMEOUT 8
25 #define DUMPCATCHER_TIMEOUT 15
26 
27 #ifndef NAME_MAX
28 #define NAME_MAX         255
29 #endif
30 #ifndef PATH_MAX
31 #define PATH_MAX        1024
32 #endif
33 #define NAME_BUF_LEN    128
34 #define PATH_LEN        512
35 #define LINE_BUF_SIZE   1024
36 #define MAX_FATAL_MSG_SIZE  1024
37 #define MAX_PIPE_SIZE (1024 * 1024)
38 static const int NUMBER_ONE_THOUSAND = 1000;
39 static const int NUMBER_ONE_MILLION = 1000000;
40 
41 static const int INVALID_FD = -1;
42 static const int DUMP_TYPE_NATIVE = -1;
43 static const int DUMP_TYPE_MIX = -2;
44 static const int DUMP_TYPE_KERNEL = -3;
45 static const int DUMP_TYPE_LOCAL = -4;
46 
47 static const int DEFAULT_MAX_FRAME_NUM = 256;
48 static const int DEFAULT_MAX_LOCAL_FRAME_NUM = 32;
49 static const int PIPE_NUM_SZ = 2;
50 static const int PIPE_READ = 0;
51 static const int PIPE_WRITE = 1;
52 static const int SOCKET_BUFFER_SIZE = 256;
53 static const char FAULTLOGGERD_SOCK_BASE_PATH[] = "/dev/unix/socket/";
54 static const char SERVER_SOCKET_NAME[] = "faultloggerd.server";
55 static const char SERVER_CRASH_SOCKET_NAME[] = "faultloggerd.crash.server";
56 
57 static const char PROC_SELF_STATUS_PATH[] = "/proc/self/status";
58 static const char PROC_SELF_TASK_PATH[] = "/proc/self/task";
59 static const char PROC_SELF_CMDLINE_PATH[] = "/proc/self/cmdline";
60 static const char PROC_SELF_COMM_PATH[] = "/proc/self/comm";
61 static const char PROC_SELF_MAPS_PATH[] = "/proc/self/maps";
62 static const char PROC_SELF_EXE_PATH[] = "/proc/self/exe";
63 
64 #define LIKELY(exp)       (__builtin_expect(!!(exp), true))
65 #define UNLIKELY(exp)     (__builtin_expect(!!(exp), false))
66 
67 #define AT_SYMBOL_DEFAULT       __attribute__ ((visibility("default")))
68 #define AT_SYMBOL_HIDDEN        __attribute__ ((visibility("hidden")))
69 #define AT_ALWAYS_INLINE        __attribute__((always_inline))
70 #define AT_WARN_UNUSED          __attribute__((warn_unused_result))
71 #define AT_UNUSED               __attribute__((unused))
72 #define MAYBE_UNUSED            [[maybe_unused]]
73 
74 #ifndef FALLTHROUGH_INTENDED
75 #define FALLTHROUGH_INTENDED [[clang::fallthrough]]  // NOLINT
76 #endif
77 
78 #define OHOS_TEMP_FAILURE_RETRY(exp)            \
79     ({                                          \
80     long int _rc;                               \
81     do {                                        \
82         _rc = (long int)(exp);                  \
83     } while ((_rc == -1) && (errno == EINTR));  \
84     _rc;                                        \
85     })
86 
87 #endif
88