debugbreak.c 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -17
- package/debugbreak.h +174 -174
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,32 +37,23 @@ And then include `debugbreak.h` as follows:
|
|
|
37
37
|
|
|
38
38
|
```c
|
|
39
39
|
// main.c
|
|
40
|
-
#include
|
|
40
|
+
#include <debugbreak.h>
|
|
41
41
|
|
|
42
42
|
int main() { /* ... */ }
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Finally, compile while adding the path `node_modules/debugbreak.c` to your compiler's include paths.
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
|
-
$ clang main.c # or, use gcc
|
|
49
|
-
$ gcc main.c
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
You may also use a simpler approach:
|
|
53
|
-
|
|
54
|
-
```c
|
|
55
|
-
// main.c
|
|
56
|
-
#include <debugbreak.h>
|
|
57
|
-
|
|
58
|
-
int main() { /* ... */ }
|
|
48
|
+
$ clang -I./node_modules/debugbreak.c main.c # or, use gcc
|
|
49
|
+
$ gcc -I./node_modules/debugbreak.c main.c
|
|
59
50
|
```
|
|
60
51
|
|
|
61
|
-
|
|
52
|
+
You may also use a simpler approach with the [cpoach](https://www.npmjs.com/package/cpoach.sh) tool, which automatically adds the necessary include paths of all the installed dependencies for your project.
|
|
62
53
|
|
|
63
54
|
```bash
|
|
64
|
-
$ clang
|
|
65
|
-
$ gcc
|
|
55
|
+
$ cpoach clang main.c # or, use gcc
|
|
56
|
+
$ cpoach gcc main.c
|
|
66
57
|
```
|
|
67
58
|
|
|
68
59
|
<br>
|
|
@@ -106,7 +97,7 @@ On ARM, **__builtin_trap()** generates a call to **abort()**, making it even les
|
|
|
106
97
|
**debug_break()** generates an **int3** instruction on i386 / x86-64 ([test/break.c](https://github.com/scottt/debugbreak/blob/master/test/break.c)):
|
|
107
98
|
```C
|
|
108
99
|
#include <stdio.h>
|
|
109
|
-
#include
|
|
100
|
+
#include <debugbreak.h>
|
|
110
101
|
|
|
111
102
|
int main()
|
|
112
103
|
{
|
|
@@ -175,6 +166,7 @@ Behavior on Different Architectures
|
|
|
175
166
|
<br>
|
|
176
167
|
|
|
177
168
|
|
|
169
|
+
[](https://wolfram77.github.io)<br>
|
|
178
170
|
[](https://github.com/scottt/debugbreak)
|
|
179
171
|
[](https://nodef.github.io)
|
|
180
172
|

|
package/debugbreak.h
CHANGED
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
/* Copyright (c) 2011-2021, Scott Tsai
|
|
2
|
-
*
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* Redistribution and use in source and binary forms, with or without
|
|
6
|
-
* modification, are permitted provided that the following conditions are met:
|
|
7
|
-
*
|
|
8
|
-
* 1. Redistributions of source code must retain the above copyright notice,
|
|
9
|
-
* this list of conditions and the following disclaimer.
|
|
10
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
-
* this list of conditions and the following disclaimer in the documentation
|
|
12
|
-
* and/or other materials provided with the distribution.
|
|
13
|
-
*
|
|
14
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
15
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
16
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
17
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
18
|
-
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
19
|
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
21
|
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
22
|
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
23
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
24
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
-
*/
|
|
26
|
-
#ifndef DEBUG_BREAK_H
|
|
27
|
-
#define DEBUG_BREAK_H
|
|
28
|
-
|
|
29
|
-
#ifdef _MSC_VER
|
|
30
|
-
|
|
31
|
-
#define debug_break __debugbreak
|
|
32
|
-
|
|
33
|
-
#else
|
|
34
|
-
|
|
35
|
-
#ifdef __cplusplus
|
|
36
|
-
extern "C" {
|
|
37
|
-
#endif
|
|
38
|
-
|
|
39
|
-
#define DEBUG_BREAK_USE_TRAP_INSTRUCTION 1
|
|
40
|
-
#define DEBUG_BREAK_USE_BULTIN_TRAP 2
|
|
41
|
-
#define DEBUG_BREAK_USE_SIGTRAP 3
|
|
42
|
-
|
|
43
|
-
#if defined(__i386__) || defined(__x86_64__)
|
|
44
|
-
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
45
|
-
__inline__ static void trap_instruction(void)
|
|
46
|
-
{
|
|
47
|
-
__asm__ volatile("int $0x03");
|
|
48
|
-
}
|
|
49
|
-
#elif defined(__thumb__)
|
|
50
|
-
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
51
|
-
/* FIXME: handle __THUMB_INTERWORK__ */
|
|
52
|
-
__attribute__((always_inline))
|
|
53
|
-
__inline__ static void trap_instruction(void)
|
|
54
|
-
{
|
|
55
|
-
/* See 'arm-linux-tdep.c' in GDB source.
|
|
56
|
-
* Both instruction sequences below work. */
|
|
57
|
-
#if 1
|
|
58
|
-
/* 'eabi_linux_thumb_le_breakpoint' */
|
|
59
|
-
__asm__ volatile(".inst 0xde01");
|
|
60
|
-
#else
|
|
61
|
-
/* 'eabi_linux_thumb2_le_breakpoint' */
|
|
62
|
-
__asm__ volatile(".inst.w 0xf7f0a000");
|
|
63
|
-
#endif
|
|
64
|
-
|
|
65
|
-
/* Known problem:
|
|
66
|
-
* After a breakpoint hit, can't 'stepi', 'step', or 'continue' in GDB.
|
|
67
|
-
* 'step' would keep getting stuck on the same instruction.
|
|
68
|
-
*
|
|
69
|
-
* Workaround: use the new GDB commands 'debugbreak-step' and
|
|
70
|
-
* 'debugbreak-continue' that become available
|
|
71
|
-
* after you source the script from GDB:
|
|
72
|
-
*
|
|
73
|
-
* $ gdb -x debugbreak-gdb.py <... USUAL ARGUMENTS ...>
|
|
74
|
-
*
|
|
75
|
-
* 'debugbreak-step' would jump over the breakpoint instruction with
|
|
76
|
-
* roughly equivalent of:
|
|
77
|
-
* (gdb) set $instruction_len = 2
|
|
78
|
-
* (gdb) tbreak *($pc + $instruction_len)
|
|
79
|
-
* (gdb) jump *($pc + $instruction_len)
|
|
80
|
-
*/
|
|
81
|
-
}
|
|
82
|
-
#elif defined(__arm__) && !defined(__thumb__)
|
|
83
|
-
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
84
|
-
__attribute__((always_inline))
|
|
85
|
-
__inline__ static void trap_instruction(void)
|
|
86
|
-
{
|
|
87
|
-
/* See 'arm-linux-tdep.c' in GDB source,
|
|
88
|
-
* 'eabi_linux_arm_le_breakpoint' */
|
|
89
|
-
__asm__ volatile(".inst 0xe7f001f0");
|
|
90
|
-
/* Known problem:
|
|
91
|
-
* Same problem and workaround as Thumb mode */
|
|
92
|
-
}
|
|
93
|
-
#elif defined(__aarch64__) && defined(__APPLE__)
|
|
94
|
-
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
|
|
95
|
-
#elif defined(__aarch64__)
|
|
96
|
-
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
97
|
-
__attribute__((always_inline))
|
|
98
|
-
__inline__ static void trap_instruction(void)
|
|
99
|
-
{
|
|
100
|
-
/* See 'aarch64-tdep.c' in GDB source,
|
|
101
|
-
* 'aarch64_default_breakpoint' */
|
|
102
|
-
__asm__ volatile(".inst 0xd4200000");
|
|
103
|
-
}
|
|
104
|
-
#elif defined(__powerpc__)
|
|
105
|
-
/* PPC 32 or 64-bit, big or little endian */
|
|
106
|
-
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
107
|
-
__attribute__((always_inline))
|
|
108
|
-
__inline__ static void trap_instruction(void)
|
|
109
|
-
{
|
|
110
|
-
/* See 'rs6000-tdep.c' in GDB source,
|
|
111
|
-
* 'rs6000_breakpoint' */
|
|
112
|
-
__asm__ volatile(".4byte 0x7d821008");
|
|
113
|
-
|
|
114
|
-
/* Known problem:
|
|
115
|
-
* After a breakpoint hit, can't 'stepi', 'step', or 'continue' in GDB.
|
|
116
|
-
* 'step' stuck on the same instruction ("twge r2,r2").
|
|
117
|
-
*
|
|
118
|
-
* The workaround is the same as ARM Thumb mode: use debugbreak-gdb.py
|
|
119
|
-
* or manually jump over the instruction. */
|
|
120
|
-
}
|
|
121
|
-
#elif defined(__riscv)
|
|
122
|
-
/* RISC-V 32 or 64-bit, whether the "C" extension
|
|
123
|
-
* for compressed, 16-bit instructions are supported or not */
|
|
124
|
-
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
125
|
-
__attribute__((always_inline))
|
|
126
|
-
__inline__ static void trap_instruction(void)
|
|
127
|
-
{
|
|
128
|
-
/* See 'riscv-tdep.c' in GDB source,
|
|
129
|
-
* 'riscv_sw_breakpoint_from_kind' */
|
|
130
|
-
__asm__ volatile(".4byte 0x00100073");
|
|
131
|
-
}
|
|
132
|
-
#else
|
|
133
|
-
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP
|
|
134
|
-
#endif
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
#ifndef DEBUG_BREAK_IMPL
|
|
138
|
-
#error "debugbreak.h is not supported on this target"
|
|
139
|
-
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
140
|
-
__attribute__((always_inline))
|
|
141
|
-
__inline__ static void debug_break(void)
|
|
142
|
-
{
|
|
143
|
-
trap_instruction();
|
|
144
|
-
}
|
|
145
|
-
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
|
|
146
|
-
__attribute__((always_inline))
|
|
147
|
-
__inline__ static void debug_break(void)
|
|
148
|
-
{
|
|
149
|
-
__builtin_debugtrap();
|
|
150
|
-
}
|
|
151
|
-
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP
|
|
152
|
-
__attribute__((always_inline))
|
|
153
|
-
__inline__ static void debug_break(void)
|
|
154
|
-
{
|
|
155
|
-
__builtin_trap();
|
|
156
|
-
}
|
|
157
|
-
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP
|
|
158
|
-
#include <signal.h>
|
|
159
|
-
__attribute__((always_inline))
|
|
160
|
-
__inline__ static void debug_break(void)
|
|
161
|
-
{
|
|
162
|
-
raise(SIGTRAP);
|
|
163
|
-
}
|
|
164
|
-
#else
|
|
165
|
-
#error "invalid DEBUG_BREAK_IMPL value"
|
|
166
|
-
#endif
|
|
167
|
-
|
|
168
|
-
#ifdef __cplusplus
|
|
169
|
-
}
|
|
170
|
-
#endif
|
|
171
|
-
|
|
172
|
-
#endif /* ifdef _MSC_VER */
|
|
173
|
-
|
|
174
|
-
#endif /* ifndef DEBUG_BREAK_H */
|
|
1
|
+
/* Copyright (c) 2011-2021, Scott Tsai
|
|
2
|
+
*
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
* this list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
* and/or other materials provided with the distribution.
|
|
13
|
+
*
|
|
14
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
15
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
16
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
17
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
18
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
19
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
21
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
22
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
23
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
24
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
*/
|
|
26
|
+
#ifndef DEBUG_BREAK_H
|
|
27
|
+
#define DEBUG_BREAK_H
|
|
28
|
+
|
|
29
|
+
#ifdef _MSC_VER
|
|
30
|
+
|
|
31
|
+
#define debug_break __debugbreak
|
|
32
|
+
|
|
33
|
+
#else
|
|
34
|
+
|
|
35
|
+
#ifdef __cplusplus
|
|
36
|
+
extern "C" {
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
#define DEBUG_BREAK_USE_TRAP_INSTRUCTION 1
|
|
40
|
+
#define DEBUG_BREAK_USE_BULTIN_TRAP 2
|
|
41
|
+
#define DEBUG_BREAK_USE_SIGTRAP 3
|
|
42
|
+
|
|
43
|
+
#if defined(__i386__) || defined(__x86_64__)
|
|
44
|
+
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
45
|
+
__inline__ static void trap_instruction(void)
|
|
46
|
+
{
|
|
47
|
+
__asm__ volatile("int $0x03");
|
|
48
|
+
}
|
|
49
|
+
#elif defined(__thumb__)
|
|
50
|
+
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
51
|
+
/* FIXME: handle __THUMB_INTERWORK__ */
|
|
52
|
+
__attribute__((always_inline))
|
|
53
|
+
__inline__ static void trap_instruction(void)
|
|
54
|
+
{
|
|
55
|
+
/* See 'arm-linux-tdep.c' in GDB source.
|
|
56
|
+
* Both instruction sequences below work. */
|
|
57
|
+
#if 1
|
|
58
|
+
/* 'eabi_linux_thumb_le_breakpoint' */
|
|
59
|
+
__asm__ volatile(".inst 0xde01");
|
|
60
|
+
#else
|
|
61
|
+
/* 'eabi_linux_thumb2_le_breakpoint' */
|
|
62
|
+
__asm__ volatile(".inst.w 0xf7f0a000");
|
|
63
|
+
#endif
|
|
64
|
+
|
|
65
|
+
/* Known problem:
|
|
66
|
+
* After a breakpoint hit, can't 'stepi', 'step', or 'continue' in GDB.
|
|
67
|
+
* 'step' would keep getting stuck on the same instruction.
|
|
68
|
+
*
|
|
69
|
+
* Workaround: use the new GDB commands 'debugbreak-step' and
|
|
70
|
+
* 'debugbreak-continue' that become available
|
|
71
|
+
* after you source the script from GDB:
|
|
72
|
+
*
|
|
73
|
+
* $ gdb -x debugbreak-gdb.py <... USUAL ARGUMENTS ...>
|
|
74
|
+
*
|
|
75
|
+
* 'debugbreak-step' would jump over the breakpoint instruction with
|
|
76
|
+
* roughly equivalent of:
|
|
77
|
+
* (gdb) set $instruction_len = 2
|
|
78
|
+
* (gdb) tbreak *($pc + $instruction_len)
|
|
79
|
+
* (gdb) jump *($pc + $instruction_len)
|
|
80
|
+
*/
|
|
81
|
+
}
|
|
82
|
+
#elif defined(__arm__) && !defined(__thumb__)
|
|
83
|
+
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
84
|
+
__attribute__((always_inline))
|
|
85
|
+
__inline__ static void trap_instruction(void)
|
|
86
|
+
{
|
|
87
|
+
/* See 'arm-linux-tdep.c' in GDB source,
|
|
88
|
+
* 'eabi_linux_arm_le_breakpoint' */
|
|
89
|
+
__asm__ volatile(".inst 0xe7f001f0");
|
|
90
|
+
/* Known problem:
|
|
91
|
+
* Same problem and workaround as Thumb mode */
|
|
92
|
+
}
|
|
93
|
+
#elif defined(__aarch64__) && defined(__APPLE__)
|
|
94
|
+
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
|
|
95
|
+
#elif defined(__aarch64__)
|
|
96
|
+
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
97
|
+
__attribute__((always_inline))
|
|
98
|
+
__inline__ static void trap_instruction(void)
|
|
99
|
+
{
|
|
100
|
+
/* See 'aarch64-tdep.c' in GDB source,
|
|
101
|
+
* 'aarch64_default_breakpoint' */
|
|
102
|
+
__asm__ volatile(".inst 0xd4200000");
|
|
103
|
+
}
|
|
104
|
+
#elif defined(__powerpc__)
|
|
105
|
+
/* PPC 32 or 64-bit, big or little endian */
|
|
106
|
+
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
107
|
+
__attribute__((always_inline))
|
|
108
|
+
__inline__ static void trap_instruction(void)
|
|
109
|
+
{
|
|
110
|
+
/* See 'rs6000-tdep.c' in GDB source,
|
|
111
|
+
* 'rs6000_breakpoint' */
|
|
112
|
+
__asm__ volatile(".4byte 0x7d821008");
|
|
113
|
+
|
|
114
|
+
/* Known problem:
|
|
115
|
+
* After a breakpoint hit, can't 'stepi', 'step', or 'continue' in GDB.
|
|
116
|
+
* 'step' stuck on the same instruction ("twge r2,r2").
|
|
117
|
+
*
|
|
118
|
+
* The workaround is the same as ARM Thumb mode: use debugbreak-gdb.py
|
|
119
|
+
* or manually jump over the instruction. */
|
|
120
|
+
}
|
|
121
|
+
#elif defined(__riscv)
|
|
122
|
+
/* RISC-V 32 or 64-bit, whether the "C" extension
|
|
123
|
+
* for compressed, 16-bit instructions are supported or not */
|
|
124
|
+
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
125
|
+
__attribute__((always_inline))
|
|
126
|
+
__inline__ static void trap_instruction(void)
|
|
127
|
+
{
|
|
128
|
+
/* See 'riscv-tdep.c' in GDB source,
|
|
129
|
+
* 'riscv_sw_breakpoint_from_kind' */
|
|
130
|
+
__asm__ volatile(".4byte 0x00100073");
|
|
131
|
+
}
|
|
132
|
+
#else
|
|
133
|
+
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP
|
|
134
|
+
#endif
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
#ifndef DEBUG_BREAK_IMPL
|
|
138
|
+
#error "debugbreak.h is not supported on this target"
|
|
139
|
+
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION
|
|
140
|
+
__attribute__((always_inline))
|
|
141
|
+
__inline__ static void debug_break(void)
|
|
142
|
+
{
|
|
143
|
+
trap_instruction();
|
|
144
|
+
}
|
|
145
|
+
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
|
|
146
|
+
__attribute__((always_inline))
|
|
147
|
+
__inline__ static void debug_break(void)
|
|
148
|
+
{
|
|
149
|
+
__builtin_debugtrap();
|
|
150
|
+
}
|
|
151
|
+
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP
|
|
152
|
+
__attribute__((always_inline))
|
|
153
|
+
__inline__ static void debug_break(void)
|
|
154
|
+
{
|
|
155
|
+
__builtin_trap();
|
|
156
|
+
}
|
|
157
|
+
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP
|
|
158
|
+
#include <signal.h>
|
|
159
|
+
__attribute__((always_inline))
|
|
160
|
+
__inline__ static void debug_break(void)
|
|
161
|
+
{
|
|
162
|
+
raise(SIGTRAP);
|
|
163
|
+
}
|
|
164
|
+
#else
|
|
165
|
+
#error "invalid DEBUG_BREAK_IMPL value"
|
|
166
|
+
#endif
|
|
167
|
+
|
|
168
|
+
#ifdef __cplusplus
|
|
169
|
+
}
|
|
170
|
+
#endif
|
|
171
|
+
|
|
172
|
+
#endif /* ifdef _MSC_VER */
|
|
173
|
+
|
|
174
|
+
#endif /* ifndef DEBUG_BREAK_H */
|