[patch] Fix gdb.cp/gdb2495.exp regression with gcc-4.7 #4 [Re: [revert] Regression on PowerPC]

Jan Kratochvil
2012-03-08T23:24:31Z

On Wed, 04 Jan 2012 15:01:04 +0100, Jan Kratochvil wrote:
> On Tue, 03 Jan 2012 15:44:53 +0100, Ulrich Weigand wrote:
> > Maybe there should be a default implementation based on
> > gdbarch_inner_than/gdbarch_frame_align_p and the breakpoint length?
>
> I will return to it in some time.

I made a copy from dicos-tdep.

No regressions on {x86_64,x86_64-m32,i686} many Fedora distros tried.

Thanks,
Jan

2012-03-09 Jan Kratochvil <jan.kratochvil@redhat.com>

* amd64-linux-tdep.c: Include inferior.h.
(amd64_linux_init_abi): Set ON_STACK and i386_linux_push_dummy_code.
* i386-linux-tdep.c (i386_linux_push_dummy_code): New function.
(i386_linux_init_abi): Set ON_STACK and i386_linux_push_dummy_code.
* i386-tdep.h (i386_linux_push_dummy_code): New declaration.

--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -32,6 +32,7 @@
#include "i386-linux-tdep.h"
#include "linux-tdep.h"
#include "i386-xstate.h"
+#include "inferior.h"

#include "gdb_string.h"

@@ -1530,6 +1531,9 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
amd64_linux_record_tdep.arg6 = AMD64_R9_REGNUM;

tdep->i386_syscall_record = amd64_linux_syscall_record;
+
+ set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
+ set_gdbarch_push_dummy_code (gdbarch, i386_linux_push_dummy_code);
}
\f

--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -704,6 +704,26 @@ i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch,
return closure;
}

+/* Implementation for set_gdbarch_push_dummy_code. */
+
+CORE_ADDR
+i386_linux_push_dummy_code (struct gdbarch *gdbarch,
+ CORE_ADDR sp, CORE_ADDR funaddr,
+ struct value **args, int nargs,
+ struct type *value_type,
+ CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
+ struct regcache *regcache)
+{
+ int bplen;
+ CORE_ADDR bppc = sp;
+
+ gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen);
+ *bp_addr = sp - bplen;
+ *real_pc = funaddr;
+
+ return *bp_addr;
+}
+
static void
i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
@@ -965,6 +985,9 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
i386_linux_get_syscall_number);

set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
+
+ set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
+ set_gdbarch_push_dummy_code (gdbarch, i386_linux_push_dummy_code);
}

/* Provide a prototype to silence -Wmissing-prototypes. */
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -379,6 +379,14 @@ extern void i386_svr4_init_abi (struct gdbarch_info, struct gdbarch *);

extern int i386_process_record (struct gdbarch *gdbarch,
struct regcache *regcache, CORE_ADDR addr);
+
+extern CORE_ADDR i386_linux_push_dummy_code (struct gdbarch *gdbarch,
+ CORE_ADDR sp, CORE_ADDR funaddr,
+ struct value **args, int nargs,
+ struct type *value_type,
+ CORE_ADDR *real_pc,
+ CORE_ADDR *bp_addr,
+ struct regcache *regcache);
\f

/* Functions and variables exported from i386bsd-tdep.c. */