diff --git a/src/libs/vmisc/debugbreak.h b/src/libs/vmisc/debugbreak.h index c40850901..89a4aebf8 100644 --- a/src/libs/vmisc/debugbreak.h +++ b/src/libs/vmisc/debugbreak.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2018, Scott Tsai +/* Copyright (c) 2011-2021, Scott Tsai * * All rights reserved. * @@ -23,7 +23,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - #ifndef DEBUG_BREAK_H #define DEBUG_BREAK_H @@ -50,7 +49,7 @@ __inline__ static void trap_instruction(void) #elif defined(__thumb__) #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION /* FIXME: handle __THUMB_INTERWORK__ */ -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void trap_instruction(void) { /* See 'arm-linux-tdep.c' in GDB source. @@ -82,7 +81,7 @@ __inline__ static void trap_instruction(void) } #elif defined(__arm__) && !defined(__thumb__) #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void trap_instruction(void) { /* 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 #elif defined(__aarch64__) #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void trap_instruction(void) { /* See 'aarch64-tdep.c' in GDB source, @@ -105,7 +104,7 @@ __inline__ static void trap_instruction(void) #elif defined(__powerpc__) /* PPC 32 or 64-bit, big or little endian */ #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void trap_instruction(void) { /* 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 * 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 #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_SIGTRAP #endif @@ -127,20 +137,20 @@ __inline__ static void trap_instruction(void) #ifndef DEBUG_BREAK_IMPL #error "debugbreak.h is not supported on this target" #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_TRAP_INSTRUCTION -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void debug_break(void) { trap_instruction(); } #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_BULTIN_TRAP -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void debug_break(void) { __builtin_trap(); } #elif DEBUG_BREAK_IMPL == DEBUG_BREAK_USE_SIGTRAP #include -__attribute__((gnu_inline, always_inline)) +__attribute__((always_inline)) __inline__ static void debug_break(void) { raise(SIGTRAP);