From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6012 invoked by alias); 25 Mar 2003 00:14:55 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 6005 invoked from network); 25 Mar 2003 00:14:54 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 25 Mar 2003 00:14:54 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id E6A662B11 for ; Mon, 24 Mar 2003 19:14:47 -0500 (EST) Message-ID: <3E7F9F77.3040504@redhat.com> Date: Tue, 25 Mar 2003 00:14:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [patch rfc] Deprecate EXTRA_STACK_ALIGNMENT_NEEDED, flip default Content-Type: multipart/mixed; boundary="------------010807000102030603020902" X-SW-Source: 2003-03/txt/msg00480.txt.bz2 This is a multi-part message in MIME format. --------------010807000102030603020902 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1926 Hello, This patch does two things: - deprecates the architecture variable EXTRA_STACK_ALIGNMENT_NEEDED - flips that variables default so that it is initially disabled (architectures adjusted where needed) The code in question (from hand_function_call) reads: /* elz: on HPPA no need for this extra alignment, maybe it is needed on other architectures. This is because all the alignment is taken care of in the above code (ifdef REG_STRUCT_HAS_ADDR) and in hppa_push_arguments */ if (EXTRA_STACK_ALIGNMENT_NEEDED) { /* MVS 11/22/96: I think at least some of this stack_align code is really broken. Better to let PUSH_ARGUMENTS adjust the stack in a target-defined manner. */ if (STACK_ALIGN_P () && INNER_THAN (1, 2)) { /* If stack grows down, we must leave a hole at the top. */ int len = 0; for (i = nargs - 1; i >= 0; i--) len += TYPE_LENGTH (VALUE_ENCLOSING_TYPE (args[i])); if (CALL_DUMMY_STACK_ADJUST_P) len += CALL_DUMMY_STACK_ADJUST; sp -= STACK_ALIGN (len) - len; } } Several things to note: - The alignment code is only enabled when EXTRA_STACK_ALIGNMENT_NEEDED and STACK_ALIGN_P(). While EXTRA_STACK_ALIGNMENT_NEEDED defaults to 1 (and few architectures clear it), it turns out that very few architectures provide a STACK_ALIGN method and consequently most architectures don't have the above code enabled. In fact, as best I can tell, the above is only used by the m68k, m68hc11 and SPARC. (I've attached a text file containing the relevant values). - Unless there is some obscure magic going on (such as the TYPE_LENGTH always being aligned), the above, given an odd sized type, will most likely mis-align the SP and not align it! Scary! Anyway, this patch deprecates the method, and I'll commit it in a day or so. Andrew --------------010807000102030603020902 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 9415 2003-03-24 Andrew Cagney * gdbarch.sh (DEPRECATED_EXTRA_STACK_ALIGNMENT_NEEDED): Replace EXTRA_STACK_ALIGNMENT_NEEDED. Default to 0 not 1. * gdbarch.h, gdbarch.c: Re-generate. * config/sparc/tm-sparc.h (DEPRECATED_EXTRA_STACK_ALIGNMENT_NEEDED): Define. * sparc-tdep.c (sparc_gdbarch_init): Set deprecated_extra_stack_alignment_needed. * config/pa/tm-hppa.h (EXTRA_STACK_ALIGNMENT_NEEDED): Delete. * xstormy16-tdep.c (xstormy16_gdbarch_init): Do not clear extra_stack_alignment_needed. * v850-tdep.c (v850_gdbarch_init): Ditto. * hppa-tdep.c (hppa_gdbarch_init): Ditto. * h8300-tdep.c (h8300_gdbarch_init): Ditto. * d10v-tdep.c (d10v_gdbarch_init): Ditto. * cris-tdep.c (cris_gdbarch_init): Ditto. * m68k-tdep.c (m68k_gdbarch_init): Ditto. * m68hc11-tdep.c (m68hc11_gdbarch_init): Ditto. Index: cris-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/cris-tdep.c,v retrieving revision 1.53 diff -u -r1.53 cris-tdep.c --- cris-tdep.c 14 Mar 2003 16:05:35 -0000 1.53 +++ cris-tdep.c 24 Mar 2003 23:55:52 -0000 @@ -4321,9 +4321,6 @@ set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown); - /* No extra stack alignment needed. Set to 1 by default. */ - set_gdbarch_extra_stack_alignment_needed (gdbarch, 0); - /* Helpful for backtracing and returning in a call dummy. */ set_gdbarch_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos); Index: d10v-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/d10v-tdep.c,v retrieving revision 1.87 diff -u -r1.87 d10v-tdep.c --- d10v-tdep.c 17 Mar 2003 14:23:49 -0000 1.87 +++ d10v-tdep.c 24 Mar 2003 23:55:52 -0000 @@ -1728,7 +1728,6 @@ set_gdbarch_stack_align (gdbarch, d10v_stack_align); set_gdbarch_register_sim_regno (gdbarch, d10v_register_sim_regno); - set_gdbarch_extra_stack_alignment_needed (gdbarch, 0); set_gdbarch_print_registers_info (gdbarch, d10v_print_registers_info); Index: gdbarch.sh =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.sh,v retrieving revision 1.206 diff -u -r1.206 gdbarch.sh --- gdbarch.sh 14 Mar 2003 16:05:35 -0000 1.206 +++ gdbarch.sh 24 Mar 2003 23:55:55 -0000 @@ -603,7 +603,8 @@ # F:2:STACK_ALIGN:CORE_ADDR:stack_align:CORE_ADDR sp:sp::0:0 M:::CORE_ADDR:frame_align:CORE_ADDR address:address -v:2:EXTRA_STACK_ALIGNMENT_NEEDED:int:extra_stack_alignment_needed::::0:1::0::: +# NOTE: cagney/2003-03-24: This is better handled by PUSH_ARGUMENTS. +v:2:DEPRECATED_EXTRA_STACK_ALIGNMENT_NEEDED:int:deprecated_extra_stack_alignment_needed::::0:0::0::: F:2:REG_STRUCT_HAS_ADDR:int:reg_struct_has_addr:int gcc_p, struct type *type:gcc_p, type::0:0 # FIXME: kettenis/2003-03-08: This should be replaced by a function # parametrized with (at least) the regcache. Index: h8300-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/h8300-tdep.c,v retrieving revision 1.42 diff -u -r1.42 h8300-tdep.c --- h8300-tdep.c 13 Mar 2003 21:45:40 -0000 1.42 +++ h8300-tdep.c 24 Mar 2003 23:55:55 -0000 @@ -1175,7 +1175,6 @@ set_gdbarch_addr_bit (gdbarch, BINWORD * TARGET_CHAR_BIT); /* set_gdbarch_stack_align (gdbarch, SOME_stack_align); */ - set_gdbarch_extra_stack_alignment_needed (gdbarch, 0); set_gdbarch_believe_pcc_promotion (gdbarch, 1); return gdbarch; Index: hppa-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-tdep.c,v retrieving revision 1.59 diff -u -r1.59 hppa-tdep.c --- hppa-tdep.c 19 Mar 2003 20:14:00 -0000 1.59 +++ hppa-tdep.c 24 Mar 2003 23:55:57 -0000 @@ -4966,7 +4966,6 @@ set_gdbarch_saved_pc_after_call (gdbarch, hppa_saved_pc_after_call); set_gdbarch_inner_than (gdbarch, hppa_inner_than); set_gdbarch_stack_align (gdbarch, hppa_stack_align); - set_gdbarch_extra_stack_alignment_needed (gdbarch, 0); set_gdbarch_decr_pc_after_break (gdbarch, 0); set_gdbarch_register_size (gdbarch, 4); set_gdbarch_num_regs (gdbarch, hppa_num_regs); Index: m68hc11-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/m68hc11-tdep.c,v retrieving revision 1.52 diff -u -r1.52 m68hc11-tdep.c --- m68hc11-tdep.c 14 Mar 2003 16:05:35 -0000 1.52 +++ m68hc11-tdep.c 24 Mar 2003 23:55:57 -0000 @@ -1425,6 +1425,7 @@ set_gdbarch_function_start_offset (gdbarch, 0); set_gdbarch_breakpoint_from_pc (gdbarch, m68hc11_breakpoint_from_pc); set_gdbarch_stack_align (gdbarch, m68hc11_stack_align); + set_gdbarch_deprecated_extra_stack_alignment_needed (gdbarch, 1); set_gdbarch_print_insn (gdbarch, gdb_print_insn_m68hc11); m68hc11_add_reggroups (gdbarch); Index: m68k-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/m68k-tdep.c,v retrieving revision 1.47 diff -u -r1.47 m68k-tdep.c --- m68k-tdep.c 13 Mar 2003 21:45:40 -0000 1.47 +++ m68k-tdep.c 24 Mar 2003 23:55:57 -0000 @@ -1000,7 +1000,7 @@ /* Stack grows down. */ set_gdbarch_inner_than (gdbarch, core_addr_lessthan); set_gdbarch_stack_align (gdbarch, m68k_stack_align); - + set_gdbarch_deprecated_extra_stack_alignment_needed (gdbarch, 1); set_gdbarch_believe_pcc_promotion (gdbarch, 1); set_gdbarch_decr_pc_after_break (gdbarch, 2); Index: sparc-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/sparc-tdep.c,v retrieving revision 1.73 diff -u -r1.73 sparc-tdep.c --- sparc-tdep.c 14 Mar 2003 17:07:00 -0000 1.73 +++ sparc-tdep.c 24 Mar 2003 23:55:58 -0000 @@ -3276,6 +3276,7 @@ set_gdbarch_sizeof_call_dummy_words (gdbarch, 0); #endif set_gdbarch_stack_align (gdbarch, sparc32_stack_align); + set_gdbarch_deprecated_extra_stack_alignment_needed (gdbarch, 1); set_gdbarch_store_struct_return (gdbarch, sparc32_store_struct_return); set_gdbarch_use_struct_convention (gdbarch, generic_use_struct_convention); @@ -3333,6 +3334,7 @@ set_gdbarch_sizeof_call_dummy_words (gdbarch, 0); #endif set_gdbarch_stack_align (gdbarch, sparc64_stack_align); + set_gdbarch_deprecated_extra_stack_alignment_needed (gdbarch, 1); set_gdbarch_store_struct_return (gdbarch, sparc64_store_struct_return); set_gdbarch_use_struct_convention (gdbarch, sparc64_use_struct_convention); Index: v850-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/v850-tdep.c,v retrieving revision 1.43 diff -u -r1.43 v850-tdep.c --- v850-tdep.c 13 Mar 2003 21:45:41 -0000 1.43 +++ v850-tdep.c 24 Mar 2003 23:55:58 -0000 @@ -1294,8 +1294,6 @@ set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT); set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT); - set_gdbarch_extra_stack_alignment_needed (gdbarch, 0); - return gdbarch; } Index: valops.c =================================================================== RCS file: /cvs/src/src/gdb/valops.c,v retrieving revision 1.94 diff -u -r1.94 valops.c --- valops.c 13 Mar 2003 21:45:41 -0000 1.94 +++ valops.c 24 Mar 2003 23:55:59 -0000 @@ -1599,7 +1599,10 @@ on other architectures. This is because all the alignment is taken care of in the above code (ifdef REG_STRUCT_HAS_ADDR) and in hppa_push_arguments */ - if (EXTRA_STACK_ALIGNMENT_NEEDED) + /* NOTE: cagney/2003-03-24: The below code is very broken. Given an + odd sized parameter the below will mis-align the stack. As was + suggested back in '96, better to let PUSH_ARGUMENTS handle it. */ + if (DEPRECATED_EXTRA_STACK_ALIGNMENT_NEEDED) { /* MVS 11/22/96: I think at least some of this stack_align code is really broken. Better to let PUSH_ARGUMENTS adjust the Index: xstormy16-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/xstormy16-tdep.c,v retrieving revision 1.31 diff -u -r1.31 xstormy16-tdep.c --- xstormy16-tdep.c 14 Mar 2003 17:07:00 -0000 1.31 +++ xstormy16-tdep.c 24 Mar 2003 23:55:59 -0000 @@ -1115,7 +1115,6 @@ set_gdbarch_pointer_to_address (gdbarch, xstormy16_pointer_to_address); set_gdbarch_stack_align (gdbarch, xstormy16_stack_align); - set_gdbarch_extra_stack_alignment_needed (gdbarch, 0); set_gdbarch_save_dummy_frame_tos (gdbarch, xstormy16_save_dummy_frame_tos); Index: config/pa/tm-hppa.h =================================================================== RCS file: /cvs/src/src/gdb/config/pa/tm-hppa.h,v retrieving revision 1.38 diff -u -r1.38 tm-hppa.h --- config/pa/tm-hppa.h 19 Mar 2003 20:14:01 -0000 1.38 +++ config/pa/tm-hppa.h 24 Mar 2003 23:56:00 -0000 @@ -116,10 +116,6 @@ #define STACK_ALIGN(sp) hppa_stack_align (sp) #endif -#if !GDB_MULTI_ARCH -#define EXTRA_STACK_ALIGNMENT_NEEDED 0 -#endif - /* Sequence of bytes for breakpoint instruction. */ #define BREAKPOINT {0x00, 0x01, 0x00, 0x04} Index: config/sparc/tm-sparc.h =================================================================== RCS file: /cvs/src/src/gdb/config/sparc/tm-sparc.h,v retrieving revision 1.39 diff -u -r1.39 tm-sparc.h --- config/sparc/tm-sparc.h 14 Mar 2003 17:07:00 -0000 1.39 +++ config/sparc/tm-sparc.h 24 Mar 2003 23:56:00 -0000 @@ -756,3 +756,4 @@ #define TM_PRINT_INSN_MACH bfd_mach_sparc +#define DEPRECATED_EXTRA_STACK_ALIGNMENT_NEEDED 1 --------------010807000102030603020902 Content-Type: text/plain; name="old" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="old" Content-length: 2250 alpha-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 alpha-elf:gdbarch_dump: STACK_ALIGN_P() = 0 arm-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 arm-elf:gdbarch_dump: STACK_ALIGN_P() = 0 avr:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 avr:gdbarch_dump: STACK_ALIGN_P() = 0 cris-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 0 cris-elf:gdbarch_dump: STACK_ALIGN_P() = 0 d10v-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 0 d10v-elf:gdbarch_dump: STACK_ALIGN_P() = 1 h8300hms:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 0 h8300hms:gdbarch_dump: STACK_ALIGN_P() = 0 i386-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 i386-elf:gdbarch_dump: STACK_ALIGN_P() = 0 ia64-linux-gnu:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 ia64-linux-gnu:gdbarch_dump: STACK_ALIGN_P() = 0 m68hc11-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 m68hc11-elf:gdbarch_dump: STACK_ALIGN_P() = 1 m68k-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 m68k-elf:gdbarch_dump: STACK_ALIGN_P() = 1 mcore-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 mcore-elf:gdbarch_dump: STACK_ALIGN_P() = 0 mips-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 mips-elf:gdbarch_dump: STACK_ALIGN_P() = 0 mn10300-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 mn10300-elf:gdbarch_dump: STACK_ALIGN_P() = 0 ns32k-netbsd:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 ns32k-netbsd:gdbarch_dump: STACK_ALIGN_P() = 0 powerpc-eabi:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 powerpc-eabi:gdbarch_dump: STACK_ALIGN_P() = 0 s390-linux-gnu:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 s390-linux-gnu:gdbarch_dump: STACK_ALIGN_P() = 0 sh-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 sh-elf:gdbarch_dump: STACK_ALIGN_P() = 0 sparc-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 sparc-elf:gdbarch_dump: STACK_ALIGN_P() = 1 v850-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 0 v850-elf:gdbarch_dump: STACK_ALIGN_P() = 0 vax-netbsd:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 vax-netbsd:gdbarch_dump: STACK_ALIGN_P() = 0 x86_64-linux-gnu:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 1 x86_64-linux-gnu:gdbarch_dump: STACK_ALIGN_P() = 0 xstormy16-elf:gdbarch_dump: EXTRA_STACK_ALIGNMENT_NEEDED = 0 xstormy16-elf:gdbarch_dump: STACK_ALIGN_P() = 1 --------------010807000102030603020902--