From 758b0c5b1dfab824516badb3f8b238b40905732f Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Mon, 7 May 2012 18:54:27 -0400 Subject: [PATCH] mips-tdeps ON_STACK push_dummy_call adjustements. --- gdb/mips-tdep.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 5e9a6ed..68ac858 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -3009,7 +3009,7 @@ mips_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr) return align_down (addr, 16); } -/* Implement the push_dummy_code gdbarch method for mips targets. */ +/* Implement the "push_dummy_call" gdbarch method. */ static CORE_ADDR mips_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, @@ -3019,9 +3019,9 @@ mips_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, struct regcache *regcache) { int bp_len; - gdb_byte null_insn[4] = { 0 }; + static gdb_byte nop_insn[] = { 0, 0, 0, 0 }; - *bp_addr = mips_frame_align (gdbarch, sp); + *bp_addr = sp; gdbarch_breakpoint_from_pc (gdbarch, bp_addr, &bp_len); /* The breakpoint layer automatically adjusts the address of @@ -3029,9 +3029,9 @@ mips_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, bad luck, the 4 bytes located just before our breakpoint instruction could look like a branch instruction, and thus trigger the adjustement, and break the function call entirely. - So, we reserve those 4 bytes and write a null instruction + So, we reserve those 4 bytes and write a nop instruction to prevent that from happening. */ - write_memory (*bp_addr - bp_len, null_insn, sizeof (null_insn)); + write_memory (*bp_addr - bp_len, nop_insn, sizeof (nop_insn)); sp = mips_frame_align (gdbarch, *bp_addr - 2 * bp_len); /* Inferior resumes at the function entry point. */ @@ -6937,9 +6937,6 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* MIPS version of CALL_DUMMY. */ - /* NOTE: cagney/2003-08-05: Eventually call dummy location will be - replaced by a command, and all targets will default to on stack - (regardless of the stack's execute status). */ set_gdbarch_call_dummy_location (gdbarch, ON_STACK); set_gdbarch_push_dummy_code (gdbarch, mips_push_dummy_code); set_gdbarch_frame_align (gdbarch, mips_frame_align); -- 1.7.0.4