From: Andrew Cagney Date: Fri, 21 Apr 2000 04:17:18 +0000 (+0000) Subject: * valops.c (hand_function_call): Replace #ifdef STACK_ALIGN with X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=b0ffd5718ff8412f5c7d27089b4353fde4695364;p=pf3gnuchains%2Fpf3gnuchains3x.git * valops.c (hand_function_call): Replace #ifdef STACK_ALIGN with run-time test for STACK_ALIGN_P. * gdbarch.sh: Add support for function and variable predicates. (STACK_ALIGN): Add. Implement with predicate - STACK_ALIGN_P. * gdbarch.h, gdbarch.c: Re-generate. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dd19676110..798677fcfb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +Thu Apr 20 14:35:46 2000 Andrew Cagney + + * valops.c (hand_function_call): Replace #ifdef STACK_ALIGN with + run-time test for STACK_ALIGN_P. + * gdbarch.sh: Add support for function and variable predicates. + (STACK_ALIGN): Add. Implement with predicate - STACK_ALIGN_P. + * gdbarch.h, gdbarch.c: Re-generate. + Thu Apr 20 17:39:11 2000 Andrew Cagney * defs.h, utils.c (free_current_contents): Change parameter to diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 1db4ce900c..06eccad729 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -213,6 +213,7 @@ struct gdbarch gdbarch_frame_locals_address_ftype *frame_locals_address; gdbarch_saved_pc_after_call_ftype *saved_pc_after_call; gdbarch_frame_num_args_ftype *frame_num_args; + gdbarch_stack_align_ftype *stack_align; }; @@ -317,6 +318,7 @@ struct gdbarch startup_gdbarch = { 0, 0, 0, + 0, /* startup_gdbarch() */ }; struct gdbarch *current_gdbarch = &startup_gdbarch; @@ -620,6 +622,7 @@ verify_gdbarch (struct gdbarch *gdbarch) if ((GDB_MULTI_ARCH >= 2) && (gdbarch->frame_num_args == 0)) internal_error ("gdbarch: verify_gdbarch: frame_num_args invalid"); + /* Skip verify of stack_align, has predicate */ } @@ -955,6 +958,10 @@ gdbarch_dump (void) "gdbarch_update: FRAME_NUM_ARGS = 0x%08lx\n", (long) current_gdbarch->frame_num_args /*FRAME_NUM_ARGS ()*/); + fprintf_unfiltered (gdb_stdlog, + "gdbarch_update: STACK_ALIGN = 0x%08lx\n", + (long) current_gdbarch->stack_align + /*STACK_ALIGN ()*/); } struct gdbarch_tdep * @@ -2487,6 +2494,29 @@ set_gdbarch_frame_num_args (struct gdbarch *gdbarch, gdbarch->frame_num_args = frame_num_args; } +int +gdbarch_stack_align_p (struct gdbarch *gdbarch) +{ + return gdbarch->stack_align != 0; +} + +CORE_ADDR +gdbarch_stack_align (struct gdbarch *gdbarch, CORE_ADDR sp) +{ + if (gdbarch->stack_align == 0) + internal_error ("gdbarch: gdbarch_stack_align invalid"); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_stack_align called\n"); + return gdbarch->stack_align (sp); +} + +void +set_gdbarch_stack_align (struct gdbarch *gdbarch, + gdbarch_stack_align_ftype stack_align) +{ + gdbarch->stack_align = stack_align; +} + /* Keep a registrary of per-architecture data-pointers required by GDB modules. */ diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index cdf60a7062..06d7439312 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -798,6 +798,23 @@ extern void set_gdbarch_frame_num_args (struct gdbarch *gdbarch, gdbarch_frame_n #endif #endif +#if defined (STACK_ALIGN) +/* Legacy for systems yet to multi-arch STACK_ALIGN */ +#define STACK_ALIGN_P() (1) +#endif + +extern int gdbarch_stack_align_p (struct gdbarch *gdbarch); +#if (GDB_MULTI_ARCH > 1) || !defined (STACK_ALIGN_P) +#define STACK_ALIGN_P() (gdbarch_stack_align_p (current_gdbarch)) +#endif + +typedef CORE_ADDR (gdbarch_stack_align_ftype) (CORE_ADDR sp); +extern CORE_ADDR gdbarch_stack_align (struct gdbarch *gdbarch, CORE_ADDR sp); +extern void set_gdbarch_stack_align (struct gdbarch *gdbarch, gdbarch_stack_align_ftype *stack_align); +#if (GDB_MULTI_ARCH > 1) || !defined (STACK_ALIGN) +#define STACK_ALIGN(sp) (gdbarch_stack_align (current_gdbarch, sp)) +#endif + extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index ffa925e3b9..c2689d0f0d 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -44,6 +44,27 @@ default_is_fallback_p () # Format of the input table read="class level macro returntype function formal actual attrib startup default invalid_p fmt print print_p description" +class_is_variable_p () +{ + [ "${class}" = "v" -o "${class}" = "V" ] +} + +class_is_function_p () +{ + [ "${class}" = "f" -o "${class}" = "F" ] +} + +class_is_predicate_p () +{ + [ "${class}" = "F" -o "${class}" = "V" ] +} + +class_is_info_p () +{ + [ "${class}" = "i" ] +} + + do_read () { if eval read $read @@ -51,7 +72,19 @@ do_read () test "${startup}" || startup=0 test "${fmt}" || fmt="%ld" test "${print}" || print="(long) ${macro}" - #test "${default}" || default=0 + #FIXME: + #Should set DEFAULT to zero and force the user to provide + #an invalid_p=0 + #test "${default}" || default=0 - NO + case "${invalid_p}" in + 0 ) valid_p=1 ;; + "" ) test "${default}" && valid_p="gdbarch->${function} != ${default}" + #NOT_YET + #test "${default}" && invalid_p="gdbarch->${function} == ${default}" + ;; + * ) valid_p="!(${invalid_p})" + esac + #NOT YET: : else false @@ -69,8 +102,12 @@ do # # -> line disable # f -> function # hiding a function + # F -> function + predicate + # hiding a function + predicate to test function validity # v -> variable # hiding a variable + # V -> variable + predicate + # hiding a variable + predicate to test variables validity # i -> set from info # hiding something from the ``struct info'' object @@ -136,7 +173,7 @@ do # returned if the code creating the new architecture failed to # initialize the MEMBER or initialized the member to something # invalid. By default, a check that the value is no longer - # equal to DEFAULT ips performed. The equation ``0'' disables + # equal to DEFAULT is performed. The equation ``0'' disables # the invalid_p check. fmt ) : ;; @@ -284,6 +321,7 @@ f:2:FRAME_LOCALS_ADDRESS:CORE_ADDR:frame_locals_address:struct frame_info *fi:fi f:2:SAVED_PC_AFTER_CALL:CORE_ADDR:saved_pc_after_call:struct frame_info *frame:frame::0:0 f:2:FRAME_NUM_ARGS:int:frame_num_args:struct frame_info *frame:frame::0:0 # +F:2:STACK_ALIGN:CORE_ADDR:stack_align:CORE_ADDR sp:sp::0:0 EOF grep -v '^#' } @@ -292,23 +330,29 @@ EOF # dump it out if true then - exec > new-gdbarch - function_list | while do_read # eval read $read - do - cat < new-gdbarch + function_list | while do_read # eval read $read + do + cat <&2 + if class_is_predicate_p && default_is_fallback_p + then + echo "Error: predicate function can not have a non- multi-arch default" 1>&2 + exit 1 + fi + done + exec 1>&2 fi copyright () @@ -398,8 +442,8 @@ echo "" echo "/* The following are pre-initialized by GDBARCH. */" function_list | while do_read # eval read $read do - case "${class}" in - "i" ) + if class_is_info_p + then echo "" echo "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch);" echo "/* set_gdbarch_${function}() - not applicable - pre-initialized. */" @@ -408,8 +452,7 @@ do echo "#define ${macro} (gdbarch_${function} (current_gdbarch))" echo "#endif" echo "#endif" - ;; - esac + fi done # function typedef's @@ -418,24 +461,38 @@ echo "" echo "/* The following are initialized by the target dependant code. */" function_list | while do_read # eval read $read do - case "${class}" in - "v" ) + if class_is_predicate_p + then + echo "" + echo "#if defined (${macro})" + echo "/* Legacy for systems yet to multi-arch ${macro} */" + echo "#define ${macro}_P() (1)" + echo "#endif" + echo "" + echo "extern int gdbarch_${function}_p (struct gdbarch *gdbarch);" + echo "#if (GDB_MULTI_ARCH > 1) || !defined (${macro}_P)" + echo "#define ${macro}_P() (gdbarch_${function}_p (current_gdbarch))" + echo "#endif" + fi + if class_is_variable_p + then echo "" echo "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch);" echo "extern void set_gdbarch_${function} (struct gdbarch *gdbarch, ${returntype} ${function});" - if ! default_is_fallback_p + if ! default_is_fallback_p && ! class_is_predicate_p then echo "#if GDB_MULTI_ARCH" fi echo "#if (GDB_MULTI_ARCH > 1) || !defined (${macro})" echo "#define ${macro} (gdbarch_${function} (current_gdbarch))" echo "#endif" - if ! default_is_fallback_p + if ! default_is_fallback_p && ! class_is_predicate_p then echo "#endif" fi - ;; - "f" ) + fi + if class_is_function_p + then echo "" echo "typedef ${returntype} (gdbarch_${function}_ftype) (${formal});" if [ "${formal}" = "void" ] @@ -445,7 +502,7 @@ do echo "extern ${returntype} gdbarch_${function} (struct gdbarch *gdbarch, ${formal});" fi echo "extern void set_gdbarch_${function} (struct gdbarch *gdbarch, gdbarch_${function}_ftype *${function});" - if ! default_is_fallback_p + if ! default_is_fallback_p && ! class_is_predicate_p then echo "#if GDB_MULTI_ARCH" fi @@ -460,12 +517,11 @@ do echo "#define ${macro}(${actual}) (gdbarch_${function} (current_gdbarch, ${actual}))" fi echo "#endif" - if ! default_is_fallback_p + if ! default_is_fallback_p && ! class_is_predicate_p then echo "#endif" fi - ;; - esac + fi done # close it off @@ -834,9 +890,10 @@ echo "{" echo " /* basic architectural information */" function_list | while do_read # eval read $read do - case "${class}" in - "i" ) echo " ${returntype} ${function};" ;; - esac + if class_is_info_p + then + echo " ${returntype} ${function};" + fi done echo "" echo " /* target specific vector. */" @@ -879,10 +936,13 @@ cat <${function} = info->${function};" - esac + if class_is_info_p + then + echo " gdbarch->${function} = info->${function};" + fi done echo "" echo " /* Force the explicit initialization of these. */" function_list | while do_read # eval read $read do - case "${class}" in - "f" | "v" ) + if class_is_function_p || class_is_variable_p + then if [ "${default}" != "" -a "${default}" != "0" ] then echo " gdbarch->${function} = ${default};" fi - ;; - esac + fi done cat <= ${level})" @@ -1026,8 +1087,7 @@ do echo " && (gdbarch->${function} == ${default}))" echo " internal_error (\"gdbarch: verify_gdbarch: ${function} invalid\");" fi - ;; - esac + fi done cat <${function}" echo " /*${macro} ()*/);" - ;; - * ) + else if [ "${print_p}" = "#" ] then echo "#ifdef ${macro}" @@ -1071,8 +1130,7 @@ do echo " \"gdbarch_update: ${macro} = ${fmt}\\n\"," echo " ${print});" fi - ;; - esac + fi done echo "}" @@ -1091,8 +1149,22 @@ EOF echo "" function_list | while do_read # eval read $read do - case "${class}" in - "f" ) + if class_is_predicate_p + then + echo "" + echo "int" + echo "gdbarch_${function}_p (struct gdbarch *gdbarch)" + echo "{" + if [ "${valid_p}" ] + then + echo " return ${valid_p};" + else + echo "#error \"gdbarch_${function}_p: not defined\"" + fi + echo "}" + fi + if class_is_function_p + then echo "" echo "${returntype}" if [ "${formal}" = "void" ] @@ -1134,8 +1206,8 @@ do echo "{" echo " gdbarch->${function} = ${function};" echo "}" - ;; - "v" ) + elif class_is_variable_p + then echo "" echo "${returntype}" echo "gdbarch_${function} (struct gdbarch *gdbarch)" @@ -1168,8 +1240,8 @@ do echo "{" echo " gdbarch->${function} = ${function};" echo "}" - ;; - "i" ) + elif class_is_info_p + then echo "" echo "${returntype}" echo "gdbarch_${function} (struct gdbarch *gdbarch)" @@ -1178,8 +1250,7 @@ do echo " fprintf_unfiltered (gdb_stdlog, \"gdbarch_${function} called\n\");" echo " return gdbarch->${function};" echo "}" - ;; - esac + fi done # All the trailing guff diff --git a/gdb/valops.c b/gdb/valops.c index 3198741390..36846c7ebd 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1534,14 +1534,14 @@ You must use a pointer to function type variable. Command ignored.", arg_name); arg_type = check_typedef (VALUE_ENCLOSING_TYPE (args[i])); len = TYPE_LENGTH (arg_type); -#ifdef STACK_ALIGN - /* 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. */ - aligned_len = STACK_ALIGN (len); -#else - aligned_len = len; -#endif + if (STACK_ALIGN_P ()) + /* 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. */ + aligned_len = STACK_ALIGN (len); + else + aligned_len = len; if (INNER_THAN (1, 2)) { /* stack grows downward */ @@ -1583,12 +1583,11 @@ You must use a pointer to function type variable. Command ignored.", arg_name); if (struct_return) { int len = TYPE_LENGTH (value_type); -#ifdef STACK_ALIGN - /* 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. */ - len = STACK_ALIGN (len); -#endif + if (STACK_ALIGN_P ()) + /* 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. */ + len = STACK_ALIGN (len); if (INNER_THAN (1, 2)) { /* stack grows downward */ @@ -1609,11 +1608,10 @@ You must use a pointer to function type variable. Command ignored.", arg_name); hppa_push_arguments */ #ifndef NO_EXTRA_ALIGNMENT_NEEDED -#if defined(STACK_ALIGN) /* 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 (INNER_THAN (1, 2)) + if (STACK_ALIGN_P () && INNER_THAN (1, 2)) { /* If stack grows down, we must leave a hole at the top. */ int len = 0; @@ -1624,7 +1622,6 @@ You must use a pointer to function type variable. Command ignored.", arg_name); len += CALL_DUMMY_STACK_ADJUST; sp -= STACK_ALIGN (len) - len; } -#endif /* STACK_ALIGN */ #endif /* NO_EXTRA_ALIGNMENT_NEEDED */ sp = PUSH_ARGUMENTS (nargs, args, sp, struct_return, struct_addr); @@ -1642,8 +1639,7 @@ You must use a pointer to function type variable. Command ignored.", arg_name); sp = PUSH_RETURN_ADDRESS (real_pc, sp); #endif /* PUSH_RETURN_ADDRESS */ -#if defined(STACK_ALIGN) - if (!INNER_THAN (1, 2)) + if (STACK_ALIGN_P () && !INNER_THAN (1, 2)) { /* If stack grows up, we must leave a hole at the bottom, note that sp already has been advanced for the arguments! */ @@ -1651,7 +1647,6 @@ You must use a pointer to function type variable. Command ignored.", arg_name); sp += CALL_DUMMY_STACK_ADJUST; sp = STACK_ALIGN (sp); } -#endif /* STACK_ALIGN */ /* XXX This seems wrong. For stacks that grow down we shouldn't do anything here! */