aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/d10v-tdep.c20
-rw-r--r--gdb/doc/ChangeLog5
-rw-r--r--gdb/doc/gdbint.texinfo33
-rw-r--r--gdb/gdbarch.c37
-rw-r--r--gdb/gdbarch.h26
-rwxr-xr-xgdb/gdbarch.sh11
-rw-r--r--gdb/infcall.c241
-rw-r--r--gdb/sparc-tdep.c10
9 files changed, 321 insertions, 78 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5b0739a..e7324f2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,21 @@
2003-05-03 Andrew Cagney <cagney@redhat.com>
+ * gdbarch.sh (PUSH_DUMMY_CODE): New architecture method, add
+ comments noteing that it replaces the old FIX_CALL_DUMMY code.
+ * gdbarch.h, gdbarch.c: Re-generate.
+ * d10v-tdep.c (d10v_push_dummy_code): New function.
+ (d10v_gdbarch_init): Set push_dummy_code.
+ * infcall.c (legacy_push_dummy_code): New function.
+ (generic_push_dummy_code): New function.
+ (push_dummy_code): New function.
+ (call_function_by_hand): Call push_dummy_code. Pass bp_addr,
+ instead of dummy_addr, to push_dummy_call. Move call to
+ generic_save_call_dummy_addr to outside of CALL_DUMMY_LOCATION
+ switch.
+ * sparc-tdep.c (sparc_gdbarch_init): Mention push_dummy_code.
+
+2003-05-03 Andrew Cagney <cagney@redhat.com>
+
* disasm.h (print_insn): Declare.
* disasm.c (init_gdb_disassemble_info): New function.
(gdb_disassembly): Call init_gdb_disassemble_info.
diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c
index 227e032..348e9f4 100644
--- a/gdb/d10v-tdep.c
+++ b/gdb/d10v-tdep.c
@@ -956,6 +956,25 @@ pop_stack_item (struct stack_item *si)
static CORE_ADDR
+d10v_push_dummy_code (struct gdbarch *gdbarch,
+ CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc,
+ struct value **args, int nargs,
+ struct type *value_type,
+ CORE_ADDR *real_pc, CORE_ADDR *bp_addr)
+{
+ /* Allocate space sufficient for a breakpoint. */
+ sp = (sp - 4) & ~3;
+ /* Store the address of that breakpoint taking care to first convert
+ it into a code (IADDR) address from a stack (DADDR) address.
+ This of course assumes that the two virtual addresses map onto
+ the same real address. */
+ (*bp_addr) = d10v_make_iaddr (d10v_convert_iaddr_to_raw (sp));
+ /* d10v always starts the call at the callee's entry point. */
+ (*real_pc) = funaddr;
+ return sp;
+}
+
+static CORE_ADDR
d10v_push_dummy_call (struct gdbarch *gdbarch, struct regcache *regcache,
CORE_ADDR dummy_addr, int nargs, struct value **args,
CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr)
@@ -1617,6 +1636,7 @@ d10v_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
}
set_gdbarch_extract_return_value (gdbarch, d10v_extract_return_value);
+ set_gdbarch_push_dummy_code (gdbarch, d10v_push_dummy_code);
set_gdbarch_push_dummy_call (gdbarch, d10v_push_dummy_call);
set_gdbarch_store_return_value (gdbarch, d10v_store_return_value);
set_gdbarch_extract_struct_value_address (gdbarch, d10v_extract_struct_value_address);
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 70a56c2..dda0e12 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,8 @@
+2003-05-03 Andrew Cagney <cagney@redhat.com>
+
+ * gdbint.texinfo (Target Architecture Definition): Document
+ push_dummy_code. Add cross references.
+
2003-05-02 Elena Zannoni <ezannoni@redhat.com>
* gdb.texinfo (Character Sets): Update to reflect new behavior of
diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
index c99d789..9896e79 100644
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
@@ -3095,19 +3095,31 @@ call.
Should be deprecated in favor of a macro that uses target-byte-ordered
data.
+This method has been replaced by @code{push_dummy_code}
+(@pxref{push_dummy_code}).
+
@item SIZEOF_CALL_DUMMY_WORDS
@findex SIZEOF_CALL_DUMMY_WORDS
The size of @code{CALL_DUMMY_WORDS}. This must return a positive value.
See also @code{CALL_DUMMY_LENGTH}.
+This method has been replaced by @code{push_dummy_code}
+(@pxref{push_dummy_code}).
+
@item CALL_DUMMY
@findex CALL_DUMMY
A static initializer for @code{CALL_DUMMY_WORDS}. Deprecated.
+This method has been replaced by @code{push_dummy_code}
+(@pxref{push_dummy_code}).
+
@item CALL_DUMMY_LOCATION
@findex CALL_DUMMY_LOCATION
See the file @file{inferior.h}.
+This method has been replaced by @code{push_dummy_code}
+(@pxref{push_dummy_code}).
+
@item DEPRECATED_CALL_DUMMY_STACK_ADJUST
@findex DEPRECATED_CALL_DUMMY_STACK_ADJUST
Stack adjustment needed when performing an inferior function call. This
@@ -3707,6 +3719,27 @@ Returns the updated top-of-stack pointer.
This method replaces @code{DEPRECATED_PUSH_ARGUMENTS}.
+@item CORE_ADDR push_dummy_code (@var{gdbarch}, @var{sp}, @var{funaddr}, @var{using_gcc}, @var{args}, @var{nargs}, @var{value_type}, @var{real_pc}, @var{bp_addr})
+@findex push_dummy_code
+@findex FIX_CALL_DUMMY
+@anchor{push_dummy_code} Given a stack based call dummy, push the
+instruction sequence (including space for a breakpoint) to which the
+called function should return.
+
+Set @var{bp_addr} to the address at which the breakpoint instruction
+should be inserted, @var{real_pc} to the resume address when starting
+the call sequence, and return the updated inner-most stack address.
+
+By default, the stack is grown sufficient to hold a frame-aligned
+(@pxref{frame_align}) breakpoint, @var{bp_addr} is set to the address
+reserved for that breakpoint, and @var{real_pc} set to @var{funaddr}.
+
+This method replaces @code{CALL_DUMMY_WORDS},
+@code{SIZEOF_CALL_DUMMY_WORDS}, @code{CALL_DUMMY},
+@code{CALL_DUMMY_LOCATION}, @code{REGISTER_SIZE},
+@code{GDB_TARGET_IS_HPPA}, @code{CALL_DUMMY_BREAKPOINT_OFFSET}, and
+@code{FIX_CALL_DUMMY}.
+
@item DEPRECATED_PUSH_DUMMY_FRAME
@findex DEPRECATED_PUSH_DUMMY_FRAME
Used in @samp{call_function_by_hand} to create an artificial stack frame.
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 6ed7d86..f4058ff 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -196,6 +196,7 @@ struct gdbarch
int sizeof_call_dummy_words;
int deprecated_call_dummy_stack_adjust;
gdbarch_fix_call_dummy_ftype *fix_call_dummy;
+ gdbarch_push_dummy_code_ftype *push_dummy_code;
gdbarch_deprecated_init_frame_pc_first_ftype *deprecated_init_frame_pc_first;
gdbarch_deprecated_init_frame_pc_ftype *deprecated_init_frame_pc;
int believe_pcc_promotion;
@@ -432,6 +433,7 @@ struct gdbarch startup_gdbarch =
0,
0,
0,
+ 0,
generic_in_function_epilogue_p,
construct_inferior_arguments,
0,
@@ -665,6 +667,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of sizeof_call_dummy_words, invalid_p == 0 */
/* Skip verify of deprecated_call_dummy_stack_adjust, has predicate */
/* Skip verify of fix_call_dummy, has predicate */
+ /* Skip verify of push_dummy_code, has predicate */
/* Skip verify of deprecated_init_frame_pc_first, has predicate */
/* Skip verify of deprecated_init_frame_pc, has predicate */
/* Skip verify of deprecated_get_saved_register, has predicate */
@@ -1964,6 +1967,14 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
fprintf_unfiltered (file,
"gdbarch_dump: push_dummy_call = 0x%08lx\n",
(long) current_gdbarch->push_dummy_call);
+ if (GDB_MULTI_ARCH)
+ fprintf_unfiltered (file,
+ "gdbarch_dump: gdbarch_push_dummy_code_p() = %d\n",
+ gdbarch_push_dummy_code_p (current_gdbarch));
+ if (GDB_MULTI_ARCH)
+ fprintf_unfiltered (file,
+ "gdbarch_dump: push_dummy_code = 0x%08lx\n",
+ (long) current_gdbarch->push_dummy_code);
#ifdef REGISTER_BYTE
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
@@ -3879,6 +3890,32 @@ set_gdbarch_fix_call_dummy (struct gdbarch *gdbarch,
}
int
+gdbarch_push_dummy_code_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->push_dummy_code != 0;
+}
+
+CORE_ADDR
+gdbarch_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr)
+{
+ gdb_assert (gdbarch != NULL);
+ if (gdbarch->push_dummy_code == 0)
+ internal_error (__FILE__, __LINE__,
+ "gdbarch: gdbarch_push_dummy_code invalid");
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_push_dummy_code called\n");
+ return gdbarch->push_dummy_code (gdbarch, sp, funaddr, using_gcc, args, nargs, value_type, real_pc, bp_addr);
+}
+
+void
+set_gdbarch_push_dummy_code (struct gdbarch *gdbarch,
+ gdbarch_push_dummy_code_ftype push_dummy_code)
+{
+ gdbarch->push_dummy_code = push_dummy_code;
+}
+
+int
gdbarch_deprecated_init_frame_pc_first_p (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index f781cc9..f00cc34 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1135,6 +1135,8 @@ extern void set_gdbarch_deprecated_use_generic_dummy_frames (struct gdbarch *gdb
#define DEPRECATED_USE_GENERIC_DUMMY_FRAMES (gdbarch_deprecated_use_generic_dummy_frames (current_gdbarch))
#endif
+/* Replaced by push_dummy_code. */
+
/* Default (value) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (CALL_DUMMY_LOCATION)
#define CALL_DUMMY_LOCATION (AT_ENTRY_POINT)
@@ -1149,6 +1151,8 @@ extern void set_gdbarch_call_dummy_location (struct gdbarch *gdbarch, int call_d
#define CALL_DUMMY_LOCATION (gdbarch_call_dummy_location (current_gdbarch))
#endif
+/* Replaced by push_dummy_code. */
+
/* Default (function) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (CALL_DUMMY_ADDRESS)
#define CALL_DUMMY_ADDRESS() (entry_point_address ())
@@ -1166,6 +1170,8 @@ extern void set_gdbarch_call_dummy_address (struct gdbarch *gdbarch, gdbarch_cal
#endif
#endif
+/* Replaced by push_dummy_code. */
+
extern CORE_ADDR gdbarch_call_dummy_start_offset (struct gdbarch *gdbarch);
extern void set_gdbarch_call_dummy_start_offset (struct gdbarch *gdbarch, CORE_ADDR call_dummy_start_offset);
#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (CALL_DUMMY_START_OFFSET)
@@ -1175,6 +1181,8 @@ extern void set_gdbarch_call_dummy_start_offset (struct gdbarch *gdbarch, CORE_A
#define CALL_DUMMY_START_OFFSET (gdbarch_call_dummy_start_offset (current_gdbarch))
#endif
+/* Replaced by push_dummy_code. */
+
extern CORE_ADDR gdbarch_call_dummy_breakpoint_offset (struct gdbarch *gdbarch);
extern void set_gdbarch_call_dummy_breakpoint_offset (struct gdbarch *gdbarch, CORE_ADDR call_dummy_breakpoint_offset);
#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (CALL_DUMMY_BREAKPOINT_OFFSET)
@@ -1184,6 +1192,8 @@ extern void set_gdbarch_call_dummy_breakpoint_offset (struct gdbarch *gdbarch, C
#define CALL_DUMMY_BREAKPOINT_OFFSET (gdbarch_call_dummy_breakpoint_offset (current_gdbarch))
#endif
+/* Replaced by push_dummy_code. */
+
extern int gdbarch_call_dummy_length (struct gdbarch *gdbarch);
extern void set_gdbarch_call_dummy_length (struct gdbarch *gdbarch, int call_dummy_length);
#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (CALL_DUMMY_LENGTH)
@@ -1236,6 +1246,8 @@ extern void set_gdbarch_deprecated_pc_in_call_dummy (struct gdbarch *gdbarch, gd
#endif
#endif
+/* Replaced by push_dummy_code. */
+
/* Default (value) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (CALL_DUMMY_WORDS)
#define CALL_DUMMY_WORDS (legacy_call_dummy_words)
@@ -1250,6 +1262,8 @@ extern void set_gdbarch_call_dummy_words (struct gdbarch *gdbarch, LONGEST * cal
#define CALL_DUMMY_WORDS (gdbarch_call_dummy_words (current_gdbarch))
#endif
+/* Replaced by push_dummy_code. */
+
/* Default (value) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (SIZEOF_CALL_DUMMY_WORDS)
#define SIZEOF_CALL_DUMMY_WORDS (legacy_sizeof_call_dummy_words)
@@ -1264,6 +1278,8 @@ extern void set_gdbarch_sizeof_call_dummy_words (struct gdbarch *gdbarch, int si
#define SIZEOF_CALL_DUMMY_WORDS (gdbarch_sizeof_call_dummy_words (current_gdbarch))
#endif
+/* Replaced by push_dummy_code. */
+
#if defined (DEPRECATED_CALL_DUMMY_STACK_ADJUST)
/* Legacy for systems yet to multi-arch DEPRECATED_CALL_DUMMY_STACK_ADJUST */
#if !defined (DEPRECATED_CALL_DUMMY_STACK_ADJUST_P)
@@ -1300,6 +1316,8 @@ extern void set_gdbarch_deprecated_call_dummy_stack_adjust (struct gdbarch *gdba
#endif
#endif
+/* Replaced by push_dummy_code. */
+
#if defined (FIX_CALL_DUMMY)
/* Legacy for systems yet to multi-arch FIX_CALL_DUMMY */
#if !defined (FIX_CALL_DUMMY_P)
@@ -1337,6 +1355,14 @@ extern void set_gdbarch_fix_call_dummy (struct gdbarch *gdbarch, gdbarch_fix_cal
#endif
#endif
+/* This is a replacement for FIX_CALL_DUMMY et.al. */
+
+extern int gdbarch_push_dummy_code_p (struct gdbarch *gdbarch);
+
+typedef CORE_ADDR (gdbarch_push_dummy_code_ftype) (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr);
+extern CORE_ADDR gdbarch_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr);
+extern void set_gdbarch_push_dummy_code (struct gdbarch *gdbarch, gdbarch_push_dummy_code_ftype *push_dummy_code);
+
#if defined (DEPRECATED_INIT_FRAME_PC_FIRST)
/* Legacy for systems yet to multi-arch DEPRECATED_INIT_FRAME_PC_FIRST */
#if !defined (DEPRECATED_INIT_FRAME_PC_FIRST_P)
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 193d52a..37e61b0 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -523,10 +523,15 @@ F:2:GET_LONGJMP_TARGET:int:get_longjmp_target:CORE_ADDR *pc:pc::0:0
# reqires that these methods be set up from the word go. This also
# avoids any potential problems with moving beyond multi-arch partial.
v::DEPRECATED_USE_GENERIC_DUMMY_FRAMES:int:deprecated_use_generic_dummy_frames:::::1::0
+# Replaced by push_dummy_code.
v::CALL_DUMMY_LOCATION:int:call_dummy_location:::::AT_ENTRY_POINT::0
+# Replaced by push_dummy_code.
f::CALL_DUMMY_ADDRESS:CORE_ADDR:call_dummy_address:void::::entry_point_address::0
+# Replaced by push_dummy_code.
v::CALL_DUMMY_START_OFFSET:CORE_ADDR:call_dummy_start_offset
+# Replaced by push_dummy_code.
v::CALL_DUMMY_BREAKPOINT_OFFSET:CORE_ADDR:call_dummy_breakpoint_offset
+# Replaced by push_dummy_code.
v::CALL_DUMMY_LENGTH:int:call_dummy_length
# NOTE: cagney/2002-11-24: This function with predicate has a valid
# (callable) initial value. As a consequence, even when the predicate
@@ -534,10 +539,16 @@ v::CALL_DUMMY_LENGTH:int:call_dummy_length
# migration process - old code, calling DEPRECATED_PC_IN_CALL_DUMMY(),
# doesn't need to be modified.
F::DEPRECATED_PC_IN_CALL_DUMMY:int:deprecated_pc_in_call_dummy:CORE_ADDR pc, CORE_ADDR sp, CORE_ADDR frame_address:pc, sp, frame_address::generic_pc_in_call_dummy:generic_pc_in_call_dummy
+# Replaced by push_dummy_code.
v::CALL_DUMMY_WORDS:LONGEST *:call_dummy_words::::0:legacy_call_dummy_words::0:0x%08lx
+# Replaced by push_dummy_code.
v::SIZEOF_CALL_DUMMY_WORDS:int:sizeof_call_dummy_words::::0:legacy_sizeof_call_dummy_words::0
+# Replaced by push_dummy_code.
V:2:DEPRECATED_CALL_DUMMY_STACK_ADJUST:int:deprecated_call_dummy_stack_adjust::::0
+# Replaced by push_dummy_code.
F::FIX_CALL_DUMMY:void:fix_call_dummy:char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, struct value **args, struct type *type, int gcc_p:dummy, pc, fun, nargs, args, type, gcc_p
+# This is a replacement for FIX_CALL_DUMMY et.al.
+M::PUSH_DUMMY_CODE:CORE_ADDR:push_dummy_code:CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc, struct value **args, int nargs, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr:sp, funaddr, using_gcc, args, nargs, value_type, real_pc, bp_addr:
F:2:DEPRECATED_INIT_FRAME_PC_FIRST:CORE_ADDR:deprecated_init_frame_pc_first:int fromleaf, struct frame_info *prev:fromleaf, prev
F:2:DEPRECATED_INIT_FRAME_PC:CORE_ADDR:deprecated_init_frame_pc:int fromleaf, struct frame_info *prev:fromleaf, prev
#
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 1ce22fb..c2ee412 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -215,6 +215,140 @@ breakpoint_auto_delete_contents (void *arg)
breakpoint_auto_delete (*(bpstat *) arg);
}
+static CORE_ADDR
+legacy_push_dummy_code (struct gdbarch *gdbarch,
+ CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc,
+ struct value **args, int nargs,
+ struct type *value_type,
+ CORE_ADDR *real_pc, CORE_ADDR *bp_addr)
+{
+ /* CALL_DUMMY is an array of words (REGISTER_SIZE), but each word is
+ in host byte order. Before calling FIX_CALL_DUMMY, we byteswap
+ it and remove any extra bytes which might exist because ULONGEST
+ is bigger than REGISTER_SIZE. */
+ /* NOTE: This is pretty wierd, as the call dummy is actually a
+ sequence of instructions. But CISC machines will have to pack
+ the instructions into REGISTER_SIZE units (and so will RISC
+ machines for which INSTRUCTION_SIZE is not REGISTER_SIZE). */
+ /* NOTE: This is pretty stupid. CALL_DUMMY should be in strict
+ target byte order. */
+ CORE_ADDR start_sp;
+ ULONGEST *dummy = alloca (SIZEOF_CALL_DUMMY_WORDS);
+ int sizeof_dummy1 = (REGISTER_SIZE * SIZEOF_CALL_DUMMY_WORDS
+ / sizeof (ULONGEST));
+ char *dummy1 = alloca (sizeof_dummy1);
+ memcpy (dummy, CALL_DUMMY_WORDS, SIZEOF_CALL_DUMMY_WORDS);
+ if (INNER_THAN (1, 2))
+ {
+ /* Stack grows down */
+ sp -= sizeof_dummy1;
+ start_sp = sp;
+ }
+ else
+ {
+ /* Stack grows up */
+ start_sp = sp;
+ sp += sizeof_dummy1;
+ }
+ /* NOTE: cagney/2002-09-10: Don't bother re-adjusting the stack
+ after allocating space for the call dummy. A target can specify
+ a SIZEOF_DUMMY1 (via SIZEOF_CALL_DUMMY_WORDS) such that all local
+ alignment requirements are met. */
+ /* Create a call sequence customized for this function and the
+ number of arguments for it. */
+ {
+ int i;
+ for (i = 0; i < (int) (SIZEOF_CALL_DUMMY_WORDS / sizeof (dummy[0]));
+ i++)
+ store_unsigned_integer (&dummy1[i * REGISTER_SIZE],
+ REGISTER_SIZE,
+ (ULONGEST) dummy[i]);
+ }
+ /* NOTE: cagney/2003-04-22: This computation of REAL_PC, BP_ADDR and
+ DUMMY_ADDR is pretty messed up. It comes from constant tinkering
+ with the values. Instead a FIX_CALL_DUMMY replacement
+ (PUSH_DUMMY_BREAKPOINT?) should just do everything. */
+#ifdef GDB_TARGET_IS_HPPA
+ real_pc = FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args,
+ value_type, using_gcc);
+#else
+ if (FIX_CALL_DUMMY_P ())
+ {
+ /* gdb_assert (CALL_DUMMY_LOCATION == ON_STACK) true? */
+ FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, value_type,
+ using_gcc);
+ }
+ (*real_pc) = start_sp;
+#endif
+ /* Yes, the offset is applied to the real_pc and not the dummy addr.
+ Ulgh! Blame the HP/UX target. */
+ (*bp_addr) = (*real_pc) + CALL_DUMMY_BREAKPOINT_OFFSET;
+ /* Yes, the offset is applied to the real_pc and not the
+ dummy_addr. Ulgh! Blame the HP/UX target. */
+ (*real_pc) += CALL_DUMMY_START_OFFSET;
+ write_memory (start_sp, (char *) dummy1, sizeof_dummy1);
+ if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES)
+ generic_save_call_dummy_addr (start_sp, start_sp + sizeof_dummy1);
+ return sp;
+}
+
+static CORE_ADDR
+generic_push_dummy_code (struct gdbarch *gdbarch,
+ CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc,
+ struct value **args, int nargs,
+ struct type *value_type,
+ CORE_ADDR *real_pc, CORE_ADDR *bp_addr)
+{
+ /* Something here to findout the size of a breakpoint and then
+ allocate space for it on the stack. */
+ int bplen;
+ /* This code assumes frame align. */
+ gdb_assert (gdbarch_frame_align_p (gdbarch));
+ /* Force the stack's alignment. The intent is to ensure that the SP
+ is aligned to at least a breakpoint instruction's boundary. */
+ sp = gdbarch_frame_align (gdbarch, sp);
+ /* Allocate space for, and then position the breakpoint on the
+ stack. */
+ if (gdbarch_inner_than (gdbarch, 1, 2))
+ {
+ CORE_ADDR bppc = sp;
+ gdbarch_breakpoint_from_pc (gdbarch, &bppc, &bplen);
+ sp = gdbarch_frame_align (gdbarch, sp - bplen);
+ (*bp_addr) = sp;
+ /* Should the breakpoint size/location be re-computed here? */
+ }
+ else
+ {
+ (*bp_addr) = sp;
+ gdbarch_breakpoint_from_pc (gdbarch, bp_addr, &bplen);
+ sp = gdbarch_frame_align (gdbarch, sp + bplen);
+ }
+ /* Inferior resumes at the function entry point. */
+ (*real_pc) = funaddr;
+ return sp;
+}
+
+/* Provide backward compatibility. Once FIX_CALL_DUMMY is eliminated,
+ this can be simplified. */
+
+static CORE_ADDR
+push_dummy_code (struct gdbarch *gdbarch,
+ CORE_ADDR sp, CORE_ADDR funaddr, int using_gcc,
+ struct value **args, int nargs,
+ struct type *value_type,
+ CORE_ADDR *real_pc, CORE_ADDR *bp_addr)
+{
+ if (gdbarch_push_dummy_code_p (gdbarch))
+ return gdbarch_push_dummy_code (gdbarch, sp, funaddr, using_gcc,
+ args, nargs, value_type, real_pc, bp_addr);
+ else if (FIX_CALL_DUMMY_P ())
+ return legacy_push_dummy_code (gdbarch, sp, funaddr, using_gcc,
+ args, nargs, value_type, real_pc, bp_addr);
+ else
+ return generic_push_dummy_code (gdbarch, sp, funaddr, using_gcc,
+ args, nargs, value_type, real_pc, bp_addr);
+}
+
/* All this stuff with a dummy frame may seem unnecessarily complicated
(why not just save registers in GDB?). The purpose of pushing a dummy
frame which looks just like a real frame is so that if you call a
@@ -362,98 +496,51 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
struct_return = using_struct_return (function, funaddr, value_type,
using_gcc);
+ /* Determine the location of the breakpoint (and possibly other
+ stuff) that the called function will return to. The SPARC, for a
+ function returning a structure or union, needs to make space for
+ not just the breakpoint but also an extra word containing the
+ size (?) of the structure being passed. */
+
+ /* The actual breakpoint (at BP_ADDR) is inserted separatly so there
+ is no need to write that out. */
+
switch (CALL_DUMMY_LOCATION)
{
case ON_STACK:
- {
- /* CALL_DUMMY is an array of words (REGISTER_SIZE), but each
- word is in host byte order. Before calling FIX_CALL_DUMMY,
- we byteswap it and remove any extra bytes which might exist
- because ULONGEST is bigger than REGISTER_SIZE. */
- /* NOTE: This is pretty wierd, as the call dummy is actually a
- sequence of instructions. But CISC machines will have to
- pack the instructions into REGISTER_SIZE units (and so will
- RISC machines for which INSTRUCTION_SIZE is not
- REGISTER_SIZE). */
- /* NOTE: This is pretty stupid. CALL_DUMMY should be in
- strict target byte order. */
- CORE_ADDR start_sp;
- ULONGEST *dummy = alloca (SIZEOF_CALL_DUMMY_WORDS);
- int sizeof_dummy1 = (REGISTER_SIZE * SIZEOF_CALL_DUMMY_WORDS
- / sizeof (ULONGEST));
- char *dummy1 = alloca (sizeof_dummy1);
- memcpy (dummy, CALL_DUMMY_WORDS, SIZEOF_CALL_DUMMY_WORDS);
- if (INNER_THAN (1, 2))
- {
- /* Stack grows down */
- sp -= sizeof_dummy1;
- start_sp = sp;
- }
- else
- {
- /* Stack grows up */
- start_sp = sp;
- sp += sizeof_dummy1;
- }
- /* NOTE: cagney/2002-09-10: Don't bother re-adjusting the
- stack after allocating space for the call dummy. A target
- can specify a SIZEOF_DUMMY1 (via SIZEOF_CALL_DUMMY_WORDS)
- such that all local alignment requirements are met. */
- /* Create a call sequence customized for this function and the
- number of arguments for it. */
+ /* "dummy_addr" is here just to keep old targets happy. New
+ targets return that same information via "sp" and "bp_addr". */
+ if (INNER_THAN (1, 2))
{
- int i;
- for (i = 0; i < (int) (SIZEOF_CALL_DUMMY_WORDS / sizeof (dummy[0]));
- i++)
- store_unsigned_integer (&dummy1[i * REGISTER_SIZE],
- REGISTER_SIZE,
- (ULONGEST) dummy[i]);
+ sp = push_dummy_code (current_gdbarch, sp, funaddr,
+ using_gcc, args, nargs, value_type,
+ &real_pc, &bp_addr);
+ dummy_addr = sp;
}
- /* NOTE: cagney/2003-04-22: This computation of REAL_PC,
- BP_ADDR and DUMMY_ADDR is pretty messed up. It comes from
- constant tinkering with the values. Instead a
- FIX_CALL_DUMMY replacement (PUSH_DUMMY_BREAKPOINT?) should
- just do everything. */
-#ifdef GDB_TARGET_IS_HPPA
- real_pc = FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args,
- value_type, using_gcc);
-#else
- if (FIX_CALL_DUMMY_P ())
- {
- /* gdb_assert (CALL_DUMMY_LOCATION == ON_STACK) true? */
- FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, value_type,
- using_gcc);
- }
- real_pc = start_sp;
-#endif
- dummy_addr = start_sp;
- /* Yes, the offset is applied to the real_pc and not the dummy
- addr. Ulgh! Blame the HP/UX target. */
- bp_addr = real_pc + CALL_DUMMY_BREAKPOINT_OFFSET;
- /* Yes, the offset is applied to the real_pc and not the
- dummy_addr. Ulgh! Blame the HP/UX target. */
- real_pc += CALL_DUMMY_START_OFFSET;
- write_memory (start_sp, (char *) dummy1, sizeof_dummy1);
- if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES)
- generic_save_call_dummy_addr (start_sp, start_sp + sizeof_dummy1);
- break;
- }
+ else
+ {
+ dummy_addr = sp;
+ sp = push_dummy_code (current_gdbarch, sp, funaddr,
+ using_gcc, args, nargs, value_type,
+ &real_pc, &bp_addr);
+ }
+ break;
case AT_ENTRY_POINT:
real_pc = funaddr;
dummy_addr = CALL_DUMMY_ADDRESS ();
/* A call dummy always consists of just a single breakpoint, so
it's address is the same as the address of the dummy. */
bp_addr = dummy_addr;
- if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES)
- /* NOTE: cagney/2002-04-13: The entry point is going to be
- modified with a single breakpoint. */
- generic_save_call_dummy_addr (CALL_DUMMY_ADDRESS (),
- CALL_DUMMY_ADDRESS () + 1);
break;
default:
internal_error (__FILE__, __LINE__, "bad switch");
}
+ if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES)
+ /* Save where the breakpoint is going to be inserted so that the
+ dummy-frame code is later able to re-identify it. */
+ generic_save_call_dummy_addr (bp_addr, bp_addr + 1);
+
if (nargs < TYPE_NFIELDS (ftype))
error ("too few arguments in function call");
@@ -646,7 +733,7 @@ You must use a pointer to function type variable. Command ignored.", arg_name);
simply error out. That would the implementation of this method
for all ABIs (which is probably a good thing). */
sp = gdbarch_push_dummy_call (current_gdbarch, current_regcache,
- dummy_addr, nargs, args, sp, struct_return,
+ bp_addr, nargs, args, sp, struct_return,
struct_addr);
else if (DEPRECATED_PUSH_ARGUMENTS_P ())
/* Keep old targets working. */
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 07c1269..b3081cd 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -3224,7 +3224,15 @@ sparc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_call_dummy_breakpoint_offset (gdbarch, 0x30);
set_gdbarch_call_dummy_length (gdbarch, 0x38);
- /* NOTE: cagney/2002-04-26: Based from info posted by Peter
+ /* NOTE: cagney/2003-05-01: Using the just added push_dummy_code
+ architecture method, it is now possible to implement a
+ generic dummy frames based inferior function call that stores
+ the breakpoint (and struct info) on the stack. Further, by
+ treating a SIGSEG at a breakpoint as equivalent to a SIGTRAP
+ it is even possible to make this work when the stack is
+ no-execute.
+
+ NOTE: cagney/2002-04-26: Based from info posted by Peter
Schauer around Oct '99. Briefly, due to aspects of the SPARC
ABI, it isn't possible to use ON_STACK with a strictly
compliant compiler.