summaryrefslogtreecommitdiff
path: root/gdb/nios2-linux-tdep.c
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2015-08-03 11:39:52 -0700
committerSandra Loosemore <sandra@codesourcery.com>2015-08-03 11:39:52 -0700
commitaf60a1ef46d2c4aca22868b0f2819234b949018e (patch)
treef10910f0faea7fcb62be21c72260f520a82712c5 /gdb/nios2-linux-tdep.c
parentcb1c8103f13d413e05ca6e61e21b56bba3baae74 (diff)
downloadbinutils-gdb-af60a1ef46d2c4aca22868b0f2819234b949018e.tar.gz
Nios II R2 support for GDB.
2015-08-03 Sandra Loosemore <sandra@codesourcery.com> 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.
Diffstat (limited to 'gdb/nios2-linux-tdep.c')
-rw-r--r--gdb/nios2-linux-tdep.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/gdb/nios2-linux-tdep.c b/gdb/nios2-linux-tdep.c
index 68c949a09fb..6b483e82f42 100644
--- a/gdb/nios2-linux-tdep.c
+++ b/gdb/nios2-linux-tdep.c
@@ -156,13 +156,30 @@ nios2_linux_rt_sigreturn_init (const struct tramp_frame *self,
trad_frame_set_id (this_cache, frame_id_build (base, func));
}
-static struct tramp_frame nios2_linux_rt_sigreturn_tramp_frame =
+/* Trampoline for sigreturn. This has the form
+ movi r2, __NR_rt_sigreturn
+ trap 0
+ appropriately encoded for R1 or R2. */
+
+static struct tramp_frame nios2_r1_linux_rt_sigreturn_tramp_frame =
+{
+ SIGTRAMP_FRAME,
+ 4,
+ {
+ { MATCH_R1_MOVI | SET_IW_I_B (2) | SET_IW_I_IMM16 (139), -1 },
+ { MATCH_R1_TRAP | SET_IW_R_IMM5 (0), -1},
+ { TRAMP_SENTINEL_INSN }
+ },
+ nios2_linux_rt_sigreturn_init
+};
+
+static struct tramp_frame nios2_r2_linux_rt_sigreturn_tramp_frame =
{
SIGTRAMP_FRAME,
4,
{
- { 0x00800004 | (139 << 6), -1 }, /* movi r2,__NR_rt_sigreturn */
- { 0x003b683a, -1 }, /* trap */
+ { MATCH_R2_MOVI | SET_IW_F2I16_B (2) | SET_IW_F2I16_IMM16 (139), -1 },
+ { MATCH_R2_TRAP | SET_IW_X2L5_IMM5 (0), -1},
{ TRAMP_SENTINEL_INSN }
},
nios2_linux_rt_sigreturn_init
@@ -172,7 +189,8 @@ static struct tramp_frame nios2_linux_rt_sigreturn_tramp_frame =
instruction to be executed. */
static CORE_ADDR
-nios2_linux_syscall_next_pc (struct frame_info *frame)
+nios2_linux_syscall_next_pc (struct frame_info *frame,
+ const struct nios2_opcode *op)
{
CORE_ADDR pc = get_frame_pc (frame);
ULONGEST syscall_nr = get_frame_register_unsigned (frame, NIOS2_R2_REGNUM);
@@ -182,7 +200,7 @@ nios2_linux_syscall_next_pc (struct frame_info *frame)
if (syscall_nr == 139 /* rt_sigreturn */)
return frame_unwind_caller_pc (frame);
- return pc + NIOS2_OPCODE_SIZE;
+ return pc + op->size;
}
/* Hook function for gdbarch_register_osabi. */
@@ -207,8 +225,12 @@ nios2_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_iterate_over_regset_sections
(gdbarch, nios2_iterate_over_regset_sections);
/* Linux signal frame unwinders. */
- tramp_frame_prepend_unwinder (gdbarch,
- &nios2_linux_rt_sigreturn_tramp_frame);
+ if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_nios2r2)
+ tramp_frame_prepend_unwinder (gdbarch,
+ &nios2_r2_linux_rt_sigreturn_tramp_frame);
+ else
+ tramp_frame_prepend_unwinder (gdbarch,
+ &nios2_r1_linux_rt_sigreturn_tramp_frame);
tdep->syscall_next_pc = nios2_linux_syscall_next_pc;