-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbreakpoint
72 lines (43 loc) · 1.92 KB
/
breakpoint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
Copyright (C) 2018-2024 Geoffrey Daniels. https://gpdaniels.com/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License only.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef GTL_DEBUG_BREAKPOINT_HPP
#define GTL_DEBUG_BREAKPOINT_HPP
// Summary: Macro for creating a breakpoint.
namespace gtl {
namespace breakpoint {
#if defined(_MSC_VER)
#define GTL_BREAKPOINT() __debugbreak()
#elif defined(__clang__)
#define GTL_BREAKPOINT() __builtin_debugtrap()
#elif (defined(__GNUC__) || defined(__GNUG__)) && (!defined(__clang__) && (!defined(__INTEL_COMPILER)))
#if (defined(__i386__) || defined(_M_IX86))
#define GTL_BREAKPOINT() ([](){ asm volatile("int $0x03"); }())
#elif (defined(__x86_64__) || defined(_M_X64))
#define GTL_BREAKPOINT() ([](){ asm volatile("int $0x03"); }())
#elif (defined(__arm__) || defined(_M_ARM))
#if defined(__thumb__)
#define GTL_BREAKPOINT() ([](){ asm volatile(".inst 0xde01"); }())
#else
#define GTL_BREAKPOINT() ([](){ asm volatile(".inst 0xe7f001f0"); }())
#endif
#elif (defined(__aarch64__))
#define GTL_BREAKPOINT() ([](){ asm volatile(".inst 0xd4200000"); }())
#else
#define GTL_BREAKPOINT() ([](){}())
#endif
#else
#define GTL_BREAKPOINT() static_cast<void>(0)
#endif
}}
#endif // GTL_DEBUG_BREAKPOINT_HPP