1 //===-- lldb-defines.h ------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_LLDB_DEFINES_H
10 #define LLDB_LLDB_DEFINES_H
11 
12 #include "lldb/lldb-types.h"
13 
14 #if !defined(INT32_MAX)
15 #define INT32_MAX 2147483647
16 #endif
17 
18 #if !defined(UINT32_MAX)
19 #define UINT32_MAX 4294967295U
20 #endif
21 
22 #if !defined(UINT64_MAX)
23 #define UINT64_MAX 18446744073709551615ULL
24 #endif
25 
26 // LLDB version
27 //
28 // A build script phase can modify this version number if needed.
29 //#define LLDB_VERSION
30 //#define LLDB_REVISION
31 //#define LLDB_VERSION_STRING
32 
33 // LLDB defines
34 #define LLDB_GENERIC_ERROR UINT32_MAX
35 
36 // Breakpoints
37 #define LLDB_INVALID_BREAK_ID 0
38 #define LLDB_DEFAULT_BREAK_SIZE 0
39 #define LLDB_BREAK_ID_IS_VALID(bid) ((bid) != (LLDB_INVALID_BREAK_ID))
40 #define LLDB_BREAK_ID_IS_INTERNAL(bid) ((bid) < 0)
41 
42 // Watchpoints
43 #define LLDB_INVALID_WATCH_ID 0
44 #define LLDB_WATCH_ID_IS_VALID(uid) ((uid) != (LLDB_INVALID_WATCH_ID))
45 #define LLDB_WATCH_TYPE_READ (1u << 0)
46 #define LLDB_WATCH_TYPE_WRITE (1u << 1)
47 #define LLDB_WATCH_TYPE_IS_VALID(type)                                         \
48   ((type & LLDB_WATCH_TYPE_READ) || (type & LLDB_WATCH_TYPE_WRITE))
49 
50 // Generic Register Numbers
51 #define LLDB_REGNUM_GENERIC_PC 0    // Program Counter
52 #define LLDB_REGNUM_GENERIC_SP 1    // Stack Pointer
53 #define LLDB_REGNUM_GENERIC_FP 2    // Frame Pointer
54 #define LLDB_REGNUM_GENERIC_RA 3    // Return Address
55 #define LLDB_REGNUM_GENERIC_FLAGS 4 // Processor flags register
56 #define LLDB_REGNUM_GENERIC_ARG1                                               \
57   5 // The register that would contain pointer size or less argument 1 (if any)
58 #define LLDB_REGNUM_GENERIC_ARG2                                               \
59   6 // The register that would contain pointer size or less argument 2 (if any)
60 #define LLDB_REGNUM_GENERIC_ARG3                                               \
61   7 // The register that would contain pointer size or less argument 3 (if any)
62 #define LLDB_REGNUM_GENERIC_ARG4                                               \
63   8 // The register that would contain pointer size or less argument 4 (if any)
64 #define LLDB_REGNUM_GENERIC_ARG5                                               \
65   9 // The register that would contain pointer size or less argument 5 (if any)
66 #define LLDB_REGNUM_GENERIC_ARG6                                               \
67   10 // The register that would contain pointer size or less argument 6 (if any)
68 #define LLDB_REGNUM_GENERIC_ARG7                                               \
69   11 // The register that would contain pointer size or less argument 7 (if any)
70 #define LLDB_REGNUM_GENERIC_ARG8                                               \
71   12 // The register that would contain pointer size or less argument 8 (if any)
72 /// Invalid value definitions
73 #define LLDB_INVALID_STOP_ID 0
74 #define LLDB_INVALID_ADDRESS UINT64_MAX
75 #define LLDB_INVALID_INDEX32 UINT32_MAX
76 #define LLDB_INVALID_IVAR_OFFSET UINT32_MAX
77 #define LLDB_INVALID_IMAGE_TOKEN UINT32_MAX
78 #define LLDB_INVALID_MODULE_VERSION UINT32_MAX
79 #define LLDB_INVALID_REGNUM UINT32_MAX
80 #define LLDB_INVALID_UID UINT64_MAX
81 #define LLDB_INVALID_PROCESS_ID 0
82 #define LLDB_INVALID_THREAD_ID 0
83 #define LLDB_INVALID_FRAME_ID UINT32_MAX
84 #define LLDB_INVALID_SIGNAL_NUMBER INT32_MAX
85 #define LLDB_INVALID_OFFSET UINT64_MAX // Must match max of lldb::offset_t
86 #define LLDB_INVALID_LINE_NUMBER UINT32_MAX
87 #define LLDB_INVALID_COLUMN_NUMBER 0
88 #define LLDB_INVALID_QUEUE_ID 0
89 #define LLDB_INVALID_CPU_ID UINT32_MAX
90 
91 /// CPU Type definitions
92 #define LLDB_ARCH_DEFAULT "systemArch"
93 #define LLDB_ARCH_DEFAULT_32BIT "systemArch32"
94 #define LLDB_ARCH_DEFAULT_64BIT "systemArch64"
95 #define LLDB_INVALID_CPUTYPE (0xFFFFFFFEu)
96 
97 /// Option Set definitions
98 // FIXME: I'm sure there's some #define magic that can create all 32 sets on the
99 // fly.  That would have the added benefit of making this unreadable.
100 #define LLDB_MAX_NUM_OPTION_SETS 32
101 #define LLDB_OPT_SET_ALL 0xFFFFFFFFU
102 #define LLDB_OPT_SET_1 (1U << 0)
103 #define LLDB_OPT_SET_2 (1U << 1)
104 #define LLDB_OPT_SET_3 (1U << 2)
105 #define LLDB_OPT_SET_4 (1U << 3)
106 #define LLDB_OPT_SET_5 (1U << 4)
107 #define LLDB_OPT_SET_6 (1U << 5)
108 #define LLDB_OPT_SET_7 (1U << 6)
109 #define LLDB_OPT_SET_8 (1U << 7)
110 #define LLDB_OPT_SET_9 (1U << 8)
111 #define LLDB_OPT_SET_10 (1U << 9)
112 #define LLDB_OPT_SET_11 (1U << 10)
113 #define LLDB_OPT_SET_12 (1U << 11)
114 #define LLDB_OPT_SET_FROM_TO(A, B)                                             \
115   (((1U << (B)) - 1) ^ (((1U << (A)) - 1) >> 1))
116 
117 #if defined(_WIN32) && !defined(MAX_PATH)
118 #define MAX_PATH 260
119 #endif
120 
121 // ignore GCC function attributes
122 #if defined(_MSC_VER) && !defined(__clang__)
123 #define __attribute__(X)
124 #endif
125 
126 #define UNUSED_IF_ASSERT_DISABLED(x) ((void)(x))
127 
128 #endif // LLDB_LLDB_DEFINES_H
129