From af60a1ef46d2c4aca22868b0f2819234b949018e Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Mon, 3 Aug 2015 11:39:52 -0700 Subject: Nios II R2 support for GDB. 2015-08-03 Sandra Loosemore gdb/ * nios2-tdep.h: Include opcode/nios2.h here. (NIOS2_CDX_OPCODE_SIZE): New. (struct gdbarch_tdep): Add OP parameter to syscall_next_pc. * nios2-tdep.c: Don't include opcode/nios2.h here. (nios2_fetch_insn): For R2, try reading 2-byte instruction if 4-byte read fails. (nios2_match_add, nios2_match_sub): Add cases for R2 encodings. (nios2_match_addi, nios2_match_orhi): Likewise. (nios2_match_stw, nios2_match_ldw): Likewise. (nios2_match_rdctl): Likewise. (nios2_match_stwm, nios2_match_ldwm): New. (nios2_match_branch): Add cases for R2 encodings. (nios2_match_jmpi, nios2_match_calli): Likewise. (nios2_match_jmpr, nios2_match_callr): Likewise. (nios2_match_break, nios2_match_trap): Likewise. (nios2_in_epilogue_p): Add R2 support. (nios2_analyze_prologue): Update comments. Recognize R2 CDX prologues. (nios2_breakpoint_from_pc): Handle R2 instructions. (nios2_get_next_pc): Likewise. Adjust call to tdep->syscall_next_pc. * nios2-linux-tdep.c (nios2_r1_linux_rt_sigreturn_tramp_frame): Renamed from nios2_linux_rt_sigreturn_tramp_frame. Use instruction field macros instead of literal hex values. (nios2_r2_linux_rt_sigreturn_tramp_frame): New. (nios2_linux_syscall_next_pc): Adjust signature to pass OP. Use size field from OP instead of assuming all instructions are the same size. (nios2_linux_init_abi): Register appropriate unwinder for mach. gdb/gdbserver/ * linux-nios2-low.c (NIOS2_BREAKPOINT): Conditionalize for arch variant. (CDX_BREAKPOINT): Define for R2. (nios2_breakpoint_at): Check for CDX_BREAKPOINT when R2. (the_low_target): Add comments. --- gdb/nios2-tdep.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gdb/nios2-tdep.h') diff --git a/gdb/nios2-tdep.h b/gdb/nios2-tdep.h index af36c4187e9..1a4e5ab3ff2 100644 --- a/gdb/nios2-tdep.h +++ b/gdb/nios2-tdep.h @@ -20,6 +20,9 @@ #ifndef NIOS2_TDEP_H #define NIOS2_TDEP_H +/* Nios II ISA specific encodings and macros. */ +#include "opcode/nios2.h" + /* Registers. */ #define NIOS2_Z_REGNUM 0 /* Zero */ #define NIOS2_R2_REGNUM 2 /* used for return value */ @@ -61,13 +64,15 @@ /* Size of an instruction, in bytes. */ #define NIOS2_OPCODE_SIZE 4 +#define NIOS2_CDX_OPCODE_SIZE 2 /* Target-dependent structure in gdbarch. */ struct gdbarch_tdep { /* Assumes FRAME is stopped at a syscall (trap) instruction; returns the expected next PC. */ - CORE_ADDR (*syscall_next_pc) (struct frame_info *frame); + CORE_ADDR (*syscall_next_pc) (struct frame_info *frame, + const struct nios2_opcode *op); /* Offset to PC value in jump buffer. If this is negative, longjmp support will be disabled. */ -- cgit v1.2.1