diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2015-08-03 11:39:52 -0700 |
---|---|---|
committer | Sandra Loosemore <sandra@codesourcery.com> | 2015-08-03 11:39:52 -0700 |
commit | af60a1ef46d2c4aca22868b0f2819234b949018e (patch) | |
tree | f10910f0faea7fcb62be21c72260f520a82712c5 /gdb/gdbserver | |
parent | cb1c8103f13d413e05ca6e61e21b56bba3baae74 (diff) | |
download | gdb-af60a1ef46d2c4aca22868b0f2819234b949018e.zip gdb-af60a1ef46d2c4aca22868b0f2819234b949018e.tar.gz gdb-af60a1ef46d2c4aca22868b0f2819234b949018e.tar.bz2 |
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/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/gdbserver/linux-nios2-low.c | 25 |
2 files changed, 31 insertions, 2 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index e01fa46..8862a48 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,11 @@ +2015-08-03 Sandra Loosemore <sandra@codesourcery.com> + + * 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. + 2015-07-30 Yao Qi <yao.qi@linaro.org> * linux-arm-low.c (arm_hwcap): Remove it. diff --git a/gdb/gdbserver/linux-nios2-low.c b/gdb/gdbserver/linux-nios2-low.c index 8a7ac28..71542b4 100644 --- a/gdb/gdbserver/linux-nios2-low.c +++ b/gdb/gdbserver/linux-nios2-low.c @@ -117,9 +117,17 @@ nios2_set_pc (struct regcache *regcache, CORE_ADDR pc) supply_register_by_name (regcache, "pc", newpc.buf); } -/* Breakpoint support. */ +/* Breakpoint support. Also see comments on nios2_breakpoint_from_pc + in nios2-tdep.c. */ + +#if defined(__nios2_arch__) && __nios2_arch__ == 2 +#define NIOS2_BREAKPOINT 0xb7fd0020 +#define CDX_BREAKPOINT 0xd7c9 +#else +#define NIOS2_BREAKPOINT 0x003b6ffa +#endif -static const unsigned int nios2_breakpoint = 0x003b6ffa; +static const unsigned int nios2_breakpoint = NIOS2_BREAKPOINT; #define nios2_breakpoint_len 4 /* Implement the breakpoint_reinsert_addr linux_target_ops method. */ @@ -141,6 +149,13 @@ nios2_breakpoint_at (CORE_ADDR where) { unsigned int insn; + /* For R2, first check for the 2-byte CDX trap.n breakpoint encoding. */ +#if defined(__nios2_arch__) && __nios2_arch__ == 2 + (*the_target->read_memory) (where, (unsigned char *) &insn, 2); + if (insn == CDX_BREAKPOINT) + return 1; +#endif + (*the_target->read_memory) (where, (unsigned char *) &insn, 4); if (insn == nios2_breakpoint) return 1; @@ -248,6 +263,12 @@ struct linux_target_ops the_low_target = NULL, nios2_get_pc, nios2_set_pc, + + /* We only register the 4-byte breakpoint, even on R2 targets which also + support 2-byte breakpoints. Since there is no supports_z_point_type + function provided, gdbserver never inserts software breakpoints itself + and instead relies on GDB to insert the breakpoint of the correct length + via a memory write. */ (const unsigned char *) &nios2_breakpoint, nios2_breakpoint_len, nios2_reinsert_addr, |