Update debugbreak to the latest version.

Since Clang 10 Clang doesn't like `gnu_inline` attribute.
This commit is contained in:
Roman Telezhynskyi 2021-05-13 11:13:20 +03:00
parent 8245aa907c
commit 8e94e4f0dc

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2011-2018, Scott Tsai /* Copyright (c) 2011-2021, Scott Tsai
* *
* All rights reserved. * All rights reserved.
* *
@ -23,7 +23,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef DEBUG_BREAK_H #ifndef DEBUG_BREAK_H
#define DEBUG_BREAK_H #define DEBUG_BREAK_H
@ -50,7 +49,7 @@ __inline__ static void trap_instruction(void)
#elif defined(__thumb__) #elif defined(__thumb__)
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
/* FIXME: handle __THUMB_INTERWORK__ */ /* FIXME: handle __THUMB_INTERWORK__ */
__attribute__((gnu_inline, always_inline)) __attribute__((always_inline))
__inline__ static void trap_instruction(void) __inline__ static void trap_instruction(void)
{ {
/* See 'arm-linux-tdep.c' in GDB source. /* See 'arm-linux-tdep.c' in GDB source.
@ -82,7 +81,7 @@ __inline__ static void trap_instruction(void)
} }
#elif defined(__arm__) && !defined(__thumb__) #elif defined(__arm__) && !defined(__thumb__)
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
__attribute__((gnu_inline, always_inline)) __attribute__((always_inline))
__inline__ static void trap_instruction(void) __inline__ static void trap_instruction(void)
{ {
/* See 'arm-linux-tdep.c' in GDB source, /* See 'arm-linux-tdep.c' in GDB source,
@ -95,7 +94,7 @@ __inline__ static void trap_instruction(void)
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_TRAP #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_TRAP
#elif defined(__aarch64__) #elif defined(__aarch64__)
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
__attribute__((gnu_inline, always_inline)) __attribute__((always_inline))
__inline__ static void trap_instruction(void) __inline__ static void trap_instruction(void)
{ {
/* See 'aarch64-tdep.c' in GDB source, /* See 'aarch64-tdep.c' in GDB source,
@ -105,7 +104,7 @@ __inline__ static void trap_instruction(void)
#elif defined(__powerpc__) #elif defined(__powerpc__)
/* PPC 32 or 64-bit, big or little endian */ /* PPC 32 or 64-bit, big or little endian */
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
__attribute__((gnu_inline, always_inline)) __attribute__((always_inline))
__inline__ static void trap_instruction(void) __inline__ static void trap_instruction(void)
{ {
/* See 'rs6000-tdep.c' in GDB source, /* See 'rs6000-tdep.c' in GDB source,
@ -119,6 +118,17 @@ __inline__ static void trap_instruction(void)
* The workaround is the same as ARM Thumb mode: use debugbreak-gdb.py * The workaround is the same as ARM Thumb mode: use debugbreak-gdb.py
* or manually jump over the instruction. */ * or manually jump over the instruction. */
} }
#elif defined(__riscv)
/* RISC-V 32 or 64-bit, whether the "C" extension
* for compressed, 16-bit instructions are supported or not */
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION
__attribute__((always_inline))
__inline__ static void trap_instruction(void)
{
/* See 'riscv-tdep.c' in GDB source,
* 'riscv_sw_breakpoint_from_kind' */
__asm__ volatile(".4byte 0x00100073");
}
#else #else
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP
#endif #endif
@ -127,20 +137,20 @@ __inline__ static void trap_instruction(void)
#ifndef DEBUG_BREAK_IMPL #ifndef DEBUG_BREAK_IMPL
#error "debugbreak.h is not supported on this target" #error "debugbreak.h is not supported on this target"
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION
__attribute__((gnu_inline, always_inline)) __attribute__((always_inline))
__inline__ static void debug_break(void) __inline__ static void debug_break(void)
{ {
trap_instruction(); trap_instruction();
} }
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP
__attribute__((gnu_inline, always_inline)) __attribute__((always_inline))
__inline__ static void debug_break(void) __inline__ static void debug_break(void)
{ {
__builtin_trap(); __builtin_trap();
} }
#elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP
#include <signal.h> #include <signal.h>
__attribute__((gnu_inline, always_inline)) __attribute__((always_inline))
__inline__ static void debug_break(void) __inline__ static void debug_break(void)
{ {
raise(SIGTRAP); raise(SIGTRAP);