From 1e6982353631fce67c8b11e8f286395265caac49 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Sat, 4 Jan 2003 22:37:49 +0000 Subject: [PATCH] gdb/ * buildsym.h (processing_hp_compilation): Remove obsolete variable. * gdbarch.sh Remove include of "value.h" in gdbarch.h. (COERCE_FLOAT_TO_DOUBLE): Remove. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * Makefile.in: Remove value_h from gdbarch_h. * valops.c (coerce_float_to_double): New variable. (default_coerce_float_to_double): Remove. (standard_coerce_float_to_double): Remove. (value_arg_coerce): Use coerce_float_to_double. (_initialize_valops): Add "set coerce-float-to-double". * value.h (default_coerce_float_to_double): Remove prototype. (standard_coerce_float_to_double): Remove prototype. * hpread.c (hpread_process_one_debug_symbol): Mark C++ functions as prototyped. * mdebugread.c (parse_symbol): Likewise. * stabsread.c (define_symbol): Mark all functions as prototyped. * hppa-tdep.c (hppa_coerce_float_to_double): Remove. * alpha-tdep.c (alpha_gdbarch_init): Remove call to set_gdbarch_coerce_float_to_double. * arm-tdep.c (arm_gdbarch_init): Likewise. * frv-tdep.c (frv_gdbarch_init): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise (commented out). * i386-sol2-tdep.c (i386_sol2_init_abi): Likewise. * mips-tdep.c (mips_gdbarch_init): Likewise. (mips_coerce_float_to_double): Remove. * rs6000-tdep.c (rs6000_gdbarch_init): Likewise. (rs6000_coerce_float_to_double): Remove. * s390-tdep.c (s390_gdbarch_init): Likewise. * sh-tdep.c (sh_gdbarch_init): Likewise. (sh_coerce_float_to_double): Remove. * sparc-tdep.c (sparc_gdbarch_init): Likewise. (sparc_coerce_float_to_double): Remove. * v850-tdep.c (v850_gdbarch_init): Likewise. * xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise. * config/m32r/tm-m32r.h (COERCE_FLOAT_TO_DOUBLE): Remove. * config/pa/tm-hppa.h: (COERCE_FLOAT_TO_DOUBLE): Remove. (hppa_coerce_float_to_double): Remove prototype. * config/sparc/tm-sparc.h (COERCE_FLOAT_TO_DOUBLE): Remove. doc/ * gdb.texinfo (Controlling GDB): Add ABI section. Document "set coerce-float-to-double". * gdbint.texinfo (COERCE_FLOAT_TO_DOUBLE): Remove documentation. testsuite/ * gdb.base/callfuncs.exp: Don't XFAIL unprototyped functions for stabs. * gdb.base/completion.exp: Allow marker1(void) as well as marker1(). * gdb.base/whatis.exp: Always allow (void) after function names. --- gdb/ChangeLog | 44 +++++++++++++ gdb/Makefile.in | 2 +- gdb/alpha-tdep.c | 6 +- gdb/arm-tdep.c | 4 +- gdb/buildsym.h | 12 +--- gdb/config/m32r/tm-m32r.h | 5 +- gdb/config/pa/tm-hppa.h | 14 +---- gdb/config/sparc/tm-sparc.h | 10 +-- gdb/doc/ChangeLog | 6 ++ gdb/doc/gdb.texinfo | 42 +++++++++++-- gdb/doc/gdbint.texinfo | 50 +-------------- gdb/frv-tdep.c | 4 +- gdb/gdbarch.c | 36 +---------- gdb/gdbarch.h | 20 +----- gdb/gdbarch.sh | 6 +- gdb/h8300-tdep.c | 5 +- gdb/hppa-tdep.c | 17 +---- gdb/hpread.c | 7 ++- gdb/i386-sol2-tdep.c | 6 +- gdb/mdebugread.c | 7 ++- gdb/mips-tdep.c | 22 +------ gdb/rs6000-tdep.c | 14 +---- gdb/s390-tdep.c | 4 +- gdb/sh-tdep.c | 10 +-- gdb/sparc-tdep.c | 12 +--- gdb/stabsread.c | 12 ++-- gdb/testsuite/ChangeLog | 7 +++ gdb/testsuite/gdb.base/callfuncs.exp | 8 +-- gdb/testsuite/gdb.base/completion.exp | 4 +- gdb/testsuite/gdb.base/whatis.exp | 18 +++--- gdb/v850-tdep.c | 5 +- gdb/valops.c | 90 ++++++++++++--------------- gdb/value.h | 6 +- gdb/xstormy16-tdep.c | 6 +- 34 files changed, 194 insertions(+), 327 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f2275b997f..62e95d6db6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,47 @@ +2003-01-04 Daniel Jacobowitz + + * buildsym.h (processing_hp_compilation): Remove obsolete variable. + * gdbarch.sh Remove include of "value.h" in gdbarch.h. + (COERCE_FLOAT_TO_DOUBLE): Remove. + * gdbarch.c: Regenerate. + * gdbarch.h: Regenerate. + * Makefile.in: Remove value_h from gdbarch_h. + * valops.c (coerce_float_to_double): New variable. + (default_coerce_float_to_double): Remove. + (standard_coerce_float_to_double): Remove. + (value_arg_coerce): Use coerce_float_to_double. + (_initialize_valops): Add "set coerce-float-to-double". + * value.h (default_coerce_float_to_double): Remove prototype. + (standard_coerce_float_to_double): Remove prototype. + + * hpread.c (hpread_process_one_debug_symbol): Mark C++ functions as + prototyped. + * mdebugread.c (parse_symbol): Likewise. + * stabsread.c (define_symbol): Mark all functions as prototyped. + + * hppa-tdep.c (hppa_coerce_float_to_double): Remove. + * alpha-tdep.c (alpha_gdbarch_init): Remove call to + set_gdbarch_coerce_float_to_double. + * arm-tdep.c (arm_gdbarch_init): Likewise. + * frv-tdep.c (frv_gdbarch_init): Likewise. + * h8300-tdep.c (h8300_gdbarch_init): Likewise (commented out). + * i386-sol2-tdep.c (i386_sol2_init_abi): Likewise. + * mips-tdep.c (mips_gdbarch_init): Likewise. + (mips_coerce_float_to_double): Remove. + * rs6000-tdep.c (rs6000_gdbarch_init): Likewise. + (rs6000_coerce_float_to_double): Remove. + * s390-tdep.c (s390_gdbarch_init): Likewise. + * sh-tdep.c (sh_gdbarch_init): Likewise. + (sh_coerce_float_to_double): Remove. + * sparc-tdep.c (sparc_gdbarch_init): Likewise. + (sparc_coerce_float_to_double): Remove. + * v850-tdep.c (v850_gdbarch_init): Likewise. + * xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise. + * config/m32r/tm-m32r.h (COERCE_FLOAT_TO_DOUBLE): Remove. + * config/pa/tm-hppa.h: (COERCE_FLOAT_TO_DOUBLE): Remove. + (hppa_coerce_float_to_double): Remove prototype. + * config/sparc/tm-sparc.h (COERCE_FLOAT_TO_DOUBLE): Remove. + 2003-01-04 Daniel Jacobowitz * regformats/reg-m68k.dat: Remove fpcode and fpflags. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 1c55a7ec29..bf8f0d378c 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -633,7 +633,7 @@ gdb_string_h = gdb_string.h gdb_thread_db_h = gdb_thread_db.h gdb_vfork_h = gdb_vfork.h gdb_wait_h = gdb_wait.h -gdbarch_h = gdbarch.h $(dis_asm_h) $(value_h) $(inferior_h) +gdbarch_h = gdbarch.h $(dis_asm_h) $(inferior_h) gdbcmd_h = gdbcmd.h $(command_h) $(ui_out_h) gdbcore_h = gdbcore.h $(bfd_h) gdbthread_h = gdbthread.h $(breakpoint_h) $(frame_h) diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index ea68302b93..8db5da82d4 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -1,5 +1,5 @@ /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger. - Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -1902,10 +1902,6 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_inner_than (gdbarch, core_addr_lessthan); set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); - /* Floats are always passed as doubles. */ - set_gdbarch_coerce_float_to_double (gdbarch, - standard_coerce_float_to_double); - set_gdbarch_breakpoint_from_pc (gdbarch, alpha_breakpoint_from_pc); set_gdbarch_decr_pc_after_break (gdbarch, 4); diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index b82f9e7ce8..e43c3331fd 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1,6 +1,6 @@ /* Common target dependent code for GDB on ARM systems. Copyright 1988, 1989, 1991, 1992, 1993, 1995, 1996, 1998, 1999, 2000, - 2001, 2002 Free Software Foundation, Inc. + 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -2913,8 +2913,6 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_push_return_address (gdbarch, arm_push_return_address); set_gdbarch_push_arguments (gdbarch, arm_push_arguments); - set_gdbarch_coerce_float_to_double (gdbarch, - standard_coerce_float_to_double); /* Frame handling. */ set_gdbarch_frame_chain_valid (gdbarch, arm_frame_chain_valid); diff --git a/gdb/buildsym.h b/gdb/buildsym.h index c23046224a..51aeee7563 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -1,6 +1,6 @@ /* Build symbol tables in GDB's internal format. Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1996, - 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + 1997, 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -83,16 +83,6 @@ EXTERN unsigned char processing_gcc_compilation; EXTERN unsigned char processing_acc_compilation; -/* elz: added this flag to know when a block is compiled with HP - compilers (cc, aCC). This is necessary because of the macro - COERCE_FLOAT_TO_DOUBLE defined in tm_hppa.h, which causes a - coercion of float to double to always occur in parameter passing - for a function called by gdb (see the function value_arg_coerce in - valops.c). This is necessary only if the target was compiled with - gcc, not with HP compilers or with g++ */ - -EXTERN unsigned char processing_hp_compilation; - /* Count symbols as they are processed, for error messages. */ EXTERN unsigned int symnum; diff --git a/gdb/config/m32r/tm-m32r.h b/gdb/config/m32r/tm-m32r.h index 70a30a8a55..8dc86e4d68 100644 --- a/gdb/config/m32r/tm-m32r.h +++ b/gdb/config/m32r/tm-m32r.h @@ -1,5 +1,6 @@ /* Parameters for execution on a Mitsubishi m32r processor. - Copyright 1996, 1997 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + Free Software Foundation, Inc. This file is part of GDB. @@ -164,8 +165,6 @@ extern CORE_ADDR m32r_skip_prologue (CORE_ADDR pc); /* mvs_no_check FRAME_NUM_ARGS */ #define FRAME_NUM_ARGS(fi) (-1) -#define COERCE_FLOAT_TO_DOUBLE(formal, actual) (1) - extern void m32r_write_sp (CORE_ADDR val); #define TARGET_WRITE_SP m32r_write_sp diff --git a/gdb/config/pa/tm-hppa.h b/gdb/config/pa/tm-hppa.h index 713931a5a2..6262008a35 100644 --- a/gdb/config/pa/tm-hppa.h +++ b/gdb/config/pa/tm-hppa.h @@ -1,6 +1,6 @@ /* Parameters for execution on any Hewlett-Packard PA-RISC machine. Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, - 1998, 1999, 2000 Free Software Foundation, Inc. + 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Contributed by the Center for Software Science at the University of Utah (pa-gdb-bugs@cs.utah.edu). @@ -786,18 +786,6 @@ extern CORE_ADDR hppa_target_read_fp (void); #define HPREAD_ADJUST_STACK_ADDRESS(ADDR) hpread_adjust_stack_address(ADDR) extern int hpread_adjust_stack_address (CORE_ADDR); -/* If the current gcc for for this target does not produce correct debugging - information for float parameters, both prototyped and unprototyped, then - define this macro. This forces gdb to always assume that floats are - passed as doubles and then converted in the callee. */ - -#if !GDB_MULTI_ARCH -extern int hppa_coerce_float_to_double (struct type *formal, - struct type *actual); -#define COERCE_FLOAT_TO_DOUBLE(formal, actual) \ - hppa_coerce_float_to_double (formal, actual) -#endif - /* Here's how to step off a permanent breakpoint. */ #define SKIP_PERMANENT_BREAKPOINT (hppa_skip_permanent_breakpoint) extern void hppa_skip_permanent_breakpoint (void); diff --git a/gdb/config/sparc/tm-sparc.h b/gdb/config/sparc/tm-sparc.h index 13a0f82d7a..404f685041 100644 --- a/gdb/config/sparc/tm-sparc.h +++ b/gdb/config/sparc/tm-sparc.h @@ -1,7 +1,7 @@ /* Target machine sub-parameters for SPARC, for GDB, the GNU debugger. This is included by other tm-*.h files to define SPARC cpu-related info. Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, - 1998, 1999, 2000 + 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@mcc.com) @@ -280,14 +280,6 @@ extern void sparc_store_return_value (struct type *, char *); extern CORE_ADDR sparc_extract_struct_value_address (char *); -/* If the current gcc for for this target does not produce correct - debugging information for float parameters, both prototyped and - unprototyped, then define this macro. This forces gdb to always - assume that floats are passed as doubles and then converted in the - callee. */ - -#define COERCE_FLOAT_TO_DOUBLE(FORMAL, ACTUAL) (1) - /* Stack must be aligned on 64-bit boundaries when synthesizing function calls (128-bit for sparc64). */ diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 0975876c01..c7e26c78c1 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,9 @@ +2003-01-04 Daniel Jacobowitz + + * gdb.texinfo (Controlling GDB): Add ABI section. Document + "set coerce-float-to-double". + * gdbint.texinfo (COERCE_FLOAT_TO_DOUBLE): Remove documentation. + 2003-01-02 Andrew Cagney * stabs.texinfo: Remove obsolete text. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index f4607b21d1..af42b0053b 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -1,6 +1,6 @@ \input texinfo @c -*-texinfo-*- @c Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, -@c 1999, 2000, 2001, 2002 +@c 1999, 2000, 2001, 2002, 2003 @c Free Software Foundation, Inc. @c @c %**start of header @@ -54,7 +54,7 @@ of @cite{Debugging with @value{GDBN}: the @sc{gnu} Source-Level Debugger} for @value{GDBN} Version @value{GDBVN}. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,@* - 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or @@ -87,7 +87,7 @@ development.'' @vskip 0pt plus 1filll Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, -1996, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +1996, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. @sp 2 Published by the Free Software Foundation @* 59 Temple Place - Suite 330, @* @@ -118,7 +118,7 @@ This file describes @value{GDBN}, the @sc{gnu} symbolic debugger. This is the @value{EDITION} Edition, @value{DATE}, for @value{GDBN} Version @value{GDBVN}. -Copyright (C) 1988-2002 Free Software Foundation, Inc. +Copyright (C) 1988-2003 Free Software Foundation, Inc. @menu * Summary:: Summary of @value{GDBN} @@ -12256,6 +12256,7 @@ described here. * History:: Command history * Screen Size:: Screen size * Numbers:: Numbers +* ABI:: Configuring the current ABI * Messages/Warnings:: Optional warnings and messages * Debugging Output:: Optional messages about internal happenings @end menu @@ -12502,6 +12503,39 @@ Display the current default base for numeric input. Display the current default base for numeric display. @end table +@node ABI +@section Configuring the current ABI + +@value{GDBN} can determine the @dfn{ABI} (Application Binary Interface) of your +application automatically. However, sometimes you need to override its +conclusions. Use these commands to manage @value{GDBN}'s view of the +current ABI. + +@cindex float promotion +@kindex set coerce-float-to-double + +Generally, the way that an argument of type @code{float} is passed to a +function depends on whether the function is prototyped. For a prototyped +(i.e.@: ANSI/ISO style) function, @code{float} arguments are passed unchanged, +according to the architecture's convention for @code{float}. For unprototyped +(i.e.@: K&R style) functions, @code{float} arguments are first promoted to type +@code{double} and then passed. + +Unfortunately, some forms of debug information do not reliably indicate whether +a function is prototyped. If @value{GDBN} calls a function that is not marked +as prototyped, it consults @kbd{set coerce-float-to-double}. + +@table @code +@item set coerce-float-to-double +@itemx set coerce-float-to-double on +Arguments of type @code{float} will be promoted to @code{double} when passed +to an unprototyped function. This is the default setting. + +@item set coerce-float-to-double off +Arguments of type @code{float} will be passed directly to unprototyped +functions. +@end table + @node Messages/Warnings @section Optional warnings and messages diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index c8053c08bc..9ce6ecb88b 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -8,7 +8,7 @@ @ifinfo This file documents the internals of the GNU debugger @value{GDBN}. -Copyright 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001,2002 +Copyright 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc. Contributed by Cygnus Solutions. Written by John Gilmore. Second Edition by Stan Shebs. @@ -50,8 +50,8 @@ Software Foundation raise funds for GNU development.'' @end tex @vskip 0pt plus 1filll -Copyright @copyright{} 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001, 2002 - Free Software Foundation, Inc. +Copyright @copyright{} 1990,1991,1992,1993,1994,1996,1998,1999,2000,2001, + 2002, 2003 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or @@ -3144,50 +3144,6 @@ and to cancel any deferred stores. Currently only implemented correctly for native Sparc configurations? -@item COERCE_FLOAT_TO_DOUBLE (@var{formal}, @var{actual}) -@findex COERCE_FLOAT_TO_DOUBLE -@cindex promotion to @code{double} -@cindex @code{float} arguments -@cindex prototyped functions, passing arguments to -@cindex passing arguments to prototyped functions -Return non-zero if GDB should promote @code{float} values to -@code{double} when calling a non-prototyped function. The argument -@var{actual} is the type of the value we want to pass to the function. -The argument @var{formal} is the type of this argument, as it appears in -the function's definition. Note that @var{formal} may be zero if we -have no debugging information for the function, or if we're passing more -arguments than are officially declared (for example, varargs). This -macro is never invoked if the function definitely has a prototype. - -How you should pass arguments to a function depends on whether it was -defined in K&R style or prototype style. If you define a function using -the K&R syntax that takes a @code{float} argument, then callers must -pass that argument as a @code{double}. If you define the function using -the prototype syntax, then you must pass the argument as a @code{float}, -with no promotion. - -Unfortunately, on certain older platforms, the debug info doesn't -indicate reliably how each function was defined. A function type's -@code{TYPE_FLAG_PROTOTYPED} flag may be unset, even if the function was -defined in prototype style. When calling a function whose -@code{TYPE_FLAG_PROTOTYPED} flag is unset, GDB consults the -@code{COERCE_FLOAT_TO_DOUBLE} macro to decide what to do. - -@findex standard_coerce_float_to_double -For modern targets, it is proper to assume that, if the prototype flag -is unset, that can be trusted: @code{float} arguments should be promoted -to @code{double}. You should use the function -@code{standard_coerce_float_to_double} to get this behavior. - -@findex default_coerce_float_to_double -For some older targets, if the prototype flag is unset, that doesn't -tell us anything. So we guess that, if we don't have a type for the -formal parameter (@i{i.e.}, the first argument to -@code{COERCE_FLOAT_TO_DOUBLE} is null), then we should promote it; -otherwise, we should leave it alone. The function -@code{default_coerce_float_to_double} provides this behavior; it is the -default value, for compatibility with older configurations. - @item int CONVERT_REGISTER_P(@var{regnum}) @findex CONVERT_REGISTER_P Return non-zero if register @var{regnum} can represent data values in a diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index 0c14e53a00..b4c6629dab 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -1,5 +1,5 @@ /* Target-dependent code for the Fujitsu FR-V, for GDB, the GNU Debugger. - Copyright 2002 Free Software Foundation, Inc. + Copyright 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -1097,8 +1097,6 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Settings for calling functions in the inferior. */ set_gdbarch_call_dummy_length (gdbarch, 0); - set_gdbarch_coerce_float_to_double (gdbarch, - standard_coerce_float_to_double); set_gdbarch_push_arguments (gdbarch, frv_push_arguments); set_gdbarch_push_return_address (gdbarch, frv_push_return_address); set_gdbarch_pop_frame (gdbarch, frv_pop_frame); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 938d9faaed..0a91cc6cc0 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -1,7 +1,7 @@ /* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ /* Dynamic architecture support for GDB, the GNU debugger. - Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -199,7 +199,6 @@ struct gdbarch gdbarch_deprecated_init_frame_pc_ftype *deprecated_init_frame_pc; int believe_pcc_promotion; int believe_pcc_promotion_type; - gdbarch_coerce_float_to_double_ftype *coerce_float_to_double; gdbarch_get_saved_register_ftype *get_saved_register; gdbarch_register_convertible_ftype *register_convertible; gdbarch_register_convert_to_virtual_ftype *register_convert_to_virtual; @@ -427,7 +426,6 @@ struct gdbarch startup_gdbarch = 0, 0, 0, - 0, generic_in_function_epilogue_p, construct_inferior_arguments, 0, @@ -533,7 +531,6 @@ gdbarch_alloc (const struct gdbarch_info *info, current_gdbarch->call_dummy_words = legacy_call_dummy_words; current_gdbarch->sizeof_call_dummy_words = legacy_sizeof_call_dummy_words; current_gdbarch->call_dummy_stack_adjust_p = -1; - current_gdbarch->coerce_float_to_double = default_coerce_float_to_double; current_gdbarch->register_convertible = generic_register_convertible_not; current_gdbarch->convert_register_p = legacy_convert_register_p; current_gdbarch->register_to_value = legacy_register_to_value; @@ -712,7 +709,6 @@ verify_gdbarch (struct gdbarch *gdbarch) fprintf_unfiltered (log, "\n\tfix_call_dummy"); /* Skip verify of deprecated_init_frame_pc_first, has predicate */ /* Skip verify of deprecated_init_frame_pc, has predicate */ - /* Skip verify of coerce_float_to_double, invalid_p == 0 */ /* Skip verify of get_saved_register, has predicate */ /* Skip verify of register_convertible, invalid_p == 0 */ /* Skip verify of register_convert_to_virtual, invalid_p == 0 */ @@ -1075,17 +1071,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) (long) current_gdbarch->cannot_store_register /*CANNOT_STORE_REGISTER ()*/); #endif -#ifdef COERCE_FLOAT_TO_DOUBLE - fprintf_unfiltered (file, - "gdbarch_dump: %s # %s\n", - "COERCE_FLOAT_TO_DOUBLE(formal, actual)", - XSTRING (COERCE_FLOAT_TO_DOUBLE (formal, actual))); - if (GDB_MULTI_ARCH) - fprintf_unfiltered (file, - "gdbarch_dump: COERCE_FLOAT_TO_DOUBLE = <0x%08lx>\n", - (long) current_gdbarch->coerce_float_to_double - /*COERCE_FLOAT_TO_DOUBLE ()*/); -#endif #ifdef COFF_MAKE_MSYMBOL_SPECIAL #if GDB_MULTI_ARCH /* Macro might contain `[{}]' when not multi-arch */ @@ -3870,25 +3855,6 @@ set_gdbarch_believe_pcc_promotion_type (struct gdbarch *gdbarch, gdbarch->believe_pcc_promotion_type = believe_pcc_promotion_type; } -int -gdbarch_coerce_float_to_double (struct gdbarch *gdbarch, struct type *formal, struct type *actual) -{ - gdb_assert (gdbarch != NULL); - if (gdbarch->coerce_float_to_double == 0) - internal_error (__FILE__, __LINE__, - "gdbarch: gdbarch_coerce_float_to_double invalid"); - if (gdbarch_debug >= 2) - fprintf_unfiltered (gdb_stdlog, "gdbarch_coerce_float_to_double called\n"); - return gdbarch->coerce_float_to_double (formal, actual); -} - -void -set_gdbarch_coerce_float_to_double (struct gdbarch *gdbarch, - gdbarch_coerce_float_to_double_ftype coerce_float_to_double) -{ - gdbarch->coerce_float_to_double = coerce_float_to_double; -} - int gdbarch_get_saved_register_p (struct gdbarch *gdbarch) { diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 0b2381f998..24e6a11f28 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -1,7 +1,7 @@ /* *INDENT-OFF* */ /* THIS FILE IS GENERATED */ /* Dynamic architecture support for GDB, the GNU debugger. - Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -38,7 +38,6 @@ #include "dis-asm.h" /* Get defs for disassemble_info, which unfortunately is a typedef. */ #if !GDB_MULTI_ARCH /* Pull in function declarations refered to, indirectly, via macros. */ -#include "value.h" /* For default_coerce_float_to_double which is referenced by a macro. */ #include "inferior.h" /* For unsigned_address_to_pointer(). */ #endif @@ -1274,23 +1273,6 @@ extern void set_gdbarch_believe_pcc_promotion_type (struct gdbarch *gdbarch, int #endif #endif -/* Default (function) for non- multi-arch platforms. */ -#if (!GDB_MULTI_ARCH) && !defined (COERCE_FLOAT_TO_DOUBLE) -#define COERCE_FLOAT_TO_DOUBLE(formal, actual) (default_coerce_float_to_double (formal, actual)) -#endif - -typedef int (gdbarch_coerce_float_to_double_ftype) (struct type *formal, struct type *actual); -extern int gdbarch_coerce_float_to_double (struct gdbarch *gdbarch, struct type *formal, struct type *actual); -extern void set_gdbarch_coerce_float_to_double (struct gdbarch *gdbarch, gdbarch_coerce_float_to_double_ftype *coerce_float_to_double); -#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (COERCE_FLOAT_TO_DOUBLE) -#error "Non multi-arch definition of COERCE_FLOAT_TO_DOUBLE" -#endif -#if GDB_MULTI_ARCH -#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (COERCE_FLOAT_TO_DOUBLE) -#define COERCE_FLOAT_TO_DOUBLE(formal, actual) (gdbarch_coerce_float_to_double (current_gdbarch, formal, actual)) -#endif -#endif - #if defined (GET_SAVED_REGISTER) /* Legacy for systems yet to multi-arch GET_SAVED_REGISTER */ #if !defined (GET_SAVED_REGISTER_P) diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index e2da438173..ceca635c07 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -1,7 +1,7 @@ #!/bin/sh -u # Architecture commands for GDB, the GNU debugger. -# Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GDB. # @@ -518,7 +518,6 @@ F::DEPRECATED_INIT_FRAME_PC:CORE_ADDR:deprecated_init_frame_pc:int fromleaf, str # v:2:BELIEVE_PCC_PROMOTION:int:believe_pcc_promotion::::::: v:2:BELIEVE_PCC_PROMOTION_TYPE:int:believe_pcc_promotion_type::::::: -f:2:COERCE_FLOAT_TO_DOUBLE:int:coerce_float_to_double:struct type *formal, struct type *actual:formal, actual:::default_coerce_float_to_double::0 F:2:GET_SAVED_REGISTER:void:get_saved_register:char *raw_buffer, int *optimized, CORE_ADDR *addrp, struct frame_info *frame, int regnum, enum lval_type *lval:raw_buffer, optimized, addrp, frame, regnum, lval # f:2:REGISTER_CONVERTIBLE:int:register_convertible:int nr:nr:::generic_register_convertible_not::0 @@ -732,7 +731,7 @@ cat < la_language == language_c); -} - static struct gdbarch * hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { @@ -5040,7 +5026,6 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_read_pc (gdbarch, hppa_target_read_pc); set_gdbarch_write_pc (gdbarch, hppa_target_write_pc); set_gdbarch_read_fp (gdbarch, hppa_target_read_fp); - set_gdbarch_coerce_float_to_double (gdbarch, hppa_coerce_float_to_double); return gdbarch; } diff --git a/gdb/hpread.c b/gdb/hpread.c index d64b4cae62..0323f022ff 100644 --- a/gdb/hpread.c +++ b/gdb/hpread.c @@ -1,5 +1,5 @@ /* Read hp debug symbols and convert to internal format, for GDB. - Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -5242,6 +5242,11 @@ hpread_process_one_debug_symbol (union dnttentry *dn_bufp, char *name, SYMBOL_CLASS (sym) = LOC_BLOCK; SYMBOL_TYPE (sym) = hpread_read_function_type (hp_type, dn_bufp, objfile, 1); + /* All functions in C++ have prototypes. For C we don't have enough + information in the debug info. */ + if (SYMBOL_LANGUAGE (s) == language_cplus) + TYPE_FLAGS (SYMBOL_TYPE (s)) |= TYPE_FLAG_PROTOTYPED; + /* The "SYMBOL_NAME" field is expected to be the mangled name * (if any), which we get from the "alias" field of the SOM record * if that exists. diff --git a/gdb/i386-sol2-tdep.c b/gdb/i386-sol2-tdep.c index 792923cd44..f58c455522 100644 --- a/gdb/i386-sol2-tdep.c +++ b/gdb/i386-sol2-tdep.c @@ -1,5 +1,5 @@ /* Target-dependent code for Solaris x86. - Copyright 2002 Free Software Foundation, Inc. + Copyright 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -47,10 +47,6 @@ i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->sigcontext_addr = i386bsd_sigcontext_addr; tdep->sc_pc_offset = 36 + 14 * 4; tdep->sc_sp_offset = 36 + 17 * 4; - - /* Assume that the prototype flag can be trusted. */ - set_gdbarch_coerce_float_to_double (gdbarch, - standard_coerce_float_to_double); } diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index b5a15c38d7..e7bbc10625 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1,6 +1,6 @@ /* Read a symbol table in ECOFF format (Third-Eye). Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, - 1997, 1998, 1999, 2000, 2001, 2002 + 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Original version contributed by Alessandro Forin (af@cs.cmu.edu) at CMU. Major work by Per Bothner, John Gilmore and Ian Lance Taylor @@ -795,6 +795,11 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, /* Make a type for the procedure itself */ SYMBOL_TYPE (s) = lookup_function_type (t); + /* All functions in C++ have prototypes. For C we don't have enough + information in the debug info. */ + if (SYMBOL_LANGUAGE (s) == language_cplus) + TYPE_FLAGS (SYMBOL_TYPE (s)) |= TYPE_FLAG_PROTOTYPED; + /* Create and enter a new lexical context */ b = new_block (top_stack->maxsyms); SYMBOL_BLOCK_VALUE (s) = b; diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index e8bce38318..d618e533b4 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -1,7 +1,7 @@ /* Target-dependent code for the MIPS architecture, for GDB, the GNU Debugger. Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, - 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin. @@ -5453,24 +5453,6 @@ mips_call_dummy_address (void) } -/* If the current gcc for this target does not produce correct debugging - information for float parameters, both prototyped and unprototyped, then - define this macro. This forces gdb to always assume that floats are - passed as doubles and then converted in the callee. - - For the mips chip, it appears that the debug info marks the parameters as - floats regardless of whether the function is prototyped, but the actual - values are passed as doubles for the non-prototyped case and floats for - the prototyped case. Thus we choose to make the non-prototyped case work - for C and break the prototyped case, since the non-prototyped case is - probably much more common. (FIXME). */ - -static int -mips_coerce_float_to_double (struct type *formal, struct type *actual) -{ - return current_language->la_language == language_c; -} - /* When debugging a 64 MIPS target running a 32 bit ABI, the size of the register stored on the stack (32) is different to its real raw size (64). The below ensures that registers are fetched from the @@ -6013,8 +5995,6 @@ mips_gdbarch_init (struct gdbarch_info info, set_gdbarch_register_convert_to_raw (gdbarch, mips_register_convert_to_raw); - set_gdbarch_coerce_float_to_double (gdbarch, mips_coerce_float_to_double); - set_gdbarch_frame_chain (gdbarch, mips_frame_chain); set_gdbarch_frame_chain_valid (gdbarch, func_frame_chain_valid); set_gdbarch_frameless_function_invocation (gdbarch, diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 98cf2d9f0d..d03d36d29d 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -1,6 +1,6 @@ /* Target-dependent code for GDB, the GNU debugger. Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997, - 1998, 1999, 2000, 2001, 2002 + 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -1855,17 +1855,6 @@ rs6000_register_virtual_type (int n) } } -/* For the PowerPC, it appears that the debug info marks float parameters as - floats regardless of whether the function is prototyped, but the actual - values are always passed in as doubles. Tell gdb to always assume that - floats are passed as doubles and then converted in the callee. */ - -static int -rs6000_coerce_float_to_double (struct type *formal, struct type *actual) -{ - return 1; -} - /* Return whether register N requires conversion when moving from raw format to virtual format. @@ -2906,7 +2895,6 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos); set_gdbarch_push_return_address (gdbarch, ppc_push_return_address); set_gdbarch_believe_pcc_promotion (gdbarch, 1); - set_gdbarch_coerce_float_to_double (gdbarch, rs6000_coerce_float_to_double); set_gdbarch_register_convertible (gdbarch, rs6000_register_convertible); set_gdbarch_register_convert_to_virtual (gdbarch, rs6000_register_convert_to_virtual); diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 6f48b3251b..961ff4fc89 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1,6 +1,6 @@ /* Target-dependent code for GDB, the GNU debugger. - Copyright 2001, 2002 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003 Free Software Foundation, Inc. Contributed by D.J. Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) for IBM Deutschland Entwicklung GmbH, IBM Corporation. @@ -1840,8 +1840,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_sizeof_call_dummy_words (gdbarch, sizeof (s390_call_dummy_words)); set_gdbarch_call_dummy_words (gdbarch, s390_call_dummy_words); - set_gdbarch_coerce_float_to_double (gdbarch, - standard_coerce_float_to_double); switch (info.bfd_arch_info->mach) { diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index 41c609e208..741f3f5d42 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -1,5 +1,5 @@ /* Target-dependent code for Hitachi Super-H, for GDB. - Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -2319,12 +2319,6 @@ sh_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, } #endif -static int -sh_coerce_float_to_double (struct type *formal, struct type *actual) -{ - return 1; -} - /* Find a function's return value in the appropriate registers (in regbuf), and copy it into valbuf. Extract from an array REGBUF containing the (raw) register state a function return value of type @@ -4575,8 +4569,6 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_call_dummy_p (gdbarch, 1); set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0); set_gdbarch_fix_call_dummy (gdbarch, generic_fix_call_dummy); - set_gdbarch_coerce_float_to_double (gdbarch, - sh_coerce_float_to_double); set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame); set_gdbarch_push_return_address (gdbarch, sh_push_return_address); diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index 8f5097e22a..7e8bcca811 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -1,7 +1,7 @@ /* Target-dependent code for the SPARC for GDB, the GNU debugger. Copyright 1986, 1987, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -3007,14 +3007,6 @@ sparc_gdbarch_fix_call_dummy (char *dummy, sparc_fix_call_dummy (dummy, pc, fun, type, gcc_p); } -/* Coerce float to double: a no-op. */ - -static int -sparc_coerce_float_to_double (struct type *formal, struct type *actual) -{ - return 1; -} - /* CALL_DUMMY_ADDRESS: fetch the breakpoint address for a call dummy. */ static CORE_ADDR @@ -3138,8 +3130,6 @@ sparc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* First set settings that are common for all sparc architectures. */ set_gdbarch_believe_pcc_promotion (gdbarch, 1); set_gdbarch_breakpoint_from_pc (gdbarch, memory_breakpoint_from_pc); - set_gdbarch_coerce_float_to_double (gdbarch, - sparc_coerce_float_to_double); set_gdbarch_call_dummy_breakpoint_offset_p (gdbarch, 1); set_gdbarch_call_dummy_p (gdbarch, 1); set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 1); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 0e0947d505..b74f52befd 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1,6 +1,6 @@ /* Support routines for decoding "stabs" debugging information format. Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001, 2002 + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -1533,9 +1533,13 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC) SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym)); - /* All functions in C++ have prototypes. */ - if (SYMBOL_LANGUAGE (sym) == language_cplus) - TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED; + /* All functions in C++ have prototypes. Stabs does not offer an + explicit way to identify prototyped or unprototyped functions, + but both GCC and Sun CC emit stabs for the "call-as" type rather + than the "declared-as" type for unprototyped functions, so + we treat all functions as if they were prototyped. This is used + primarily for promotion when calling the function from GDB. */ + TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED; /* fall into process_prototype_types */ diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e6096aaba3..6602520393 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2003-01-04 Daniel Jacobowitz + + * gdb.base/callfuncs.exp: Don't XFAIL unprototyped functions for + stabs. + * gdb.base/completion.exp: Allow marker1(void) as well as marker1(). + * gdb.base/whatis.exp: Always allow (void) after function names. + 2003-01-04 Daniel Jacobowitz * gdb.c++/casts.exp: Correct regexp. diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp index 90f83434f4..9183fe46b8 100644 --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -1,4 +1,4 @@ -# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -143,9 +143,6 @@ proc do_function_calls {} { gdb_test "p t_float_values(float_val1,-2.3765)" " = 1" # Test passing of arguments which might not be widened. - # Under stabs, GCC doesn't tell us whether the function was - # prototyped or not. - if {$gcc_compiled} { setup_xfail_format "stabs" } gdb_test "p t_float_values2(0.0,0.0)" " = 0" # Although PR 5318 mentions SunOS specifically, this seems @@ -157,9 +154,6 @@ proc do_function_calls {} { } } - # Under stabs, GCC doesn't tell us whether the function was - # prototyped or not. - if {$gcc_compiled} { setup_xfail_format "stabs" } gdb_test "p t_float_values2(3.14159,float_val2)" " = 1" gdb_test "p t_small_values(1,2,3,4,5,6,7,8,9,10)" " = 55" diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 332e1697a7..512bbdbcd2 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -1,4 +1,4 @@ -# Copyright 1998, 1999, 2002 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2002, 2003 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -705,7 +705,7 @@ gdb_expect { -re "marker1.*$gdb_prompt info func marker$"\ { send_gdb "\n" gdb_expect { - -re "All functions matching regular expression \"marker\":.*File.*break.c:\r\nint marker1\\(\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long int\\);.*$gdb_prompt $"\ + -re "All functions matching regular expression \"marker\":.*File.*break.c:\r\nint marker1\\((void|)\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long int\\);.*$gdb_prompt $"\ { pass "complete 'info func mar'"} -re ".*$gdb_prompt $" { fail "complete 'info func mar'"} timeout {fail "(timeout) complete 'info func mar'"} diff --git a/gdb/testsuite/gdb.base/whatis.exp b/gdb/testsuite/gdb.base/whatis.exp index 79c48e4da7..98af77a341 100644 --- a/gdb/testsuite/gdb.base/whatis.exp +++ b/gdb/testsuite/gdb.base/whatis.exp @@ -1,4 +1,4 @@ -# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002 +# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1999, 2002, 2003 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -301,15 +301,13 @@ gdb_test "whatis v_union2" \ "whatis unnamed union" -if { [istarget "hppa*-hp-hpux*"] && $hp_aCC_compiler } { - # HP-UX: HP aCC compiler w/ +objdebug option detects language as - # c++, so we need the 'void' pattern here. - # Without +objdebug compilation option we still need to match ''. - # - guo - set void "(void|)" -} else { - set void "" -} +# HP-UX: HP aCC compiler w/ +objdebug option detects language as +# c++, so we need the 'void' pattern here. +# Without +objdebug compilation option we still need to match ''. +# - guo +# Also, using stabs we will mark these functions as prototyped. This +# is harmless but causes an extra VOID to be printed. +set void "(void|)" # test whatis command with functions return type gdb_test "whatis v_char_func" \ diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index 44b3a3086c..851ba07941 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -1,5 +1,6 @@ /* Target-dependent code for the NEC V850 for GDB, the GNU debugger. - Copyright 1996, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003 + Free Software Foundation, Inc. This file is part of GDB. @@ -1256,8 +1257,6 @@ v850_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_frame_args_skip (gdbarch, 0); /* OK to default this value to 'unknown'. */ set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown); - /* W/o prototype, coerce float args to double. */ - set_gdbarch_coerce_float_to_double (gdbarch, standard_coerce_float_to_double); /* * Call Dummies diff --git a/gdb/valops.c b/gdb/valops.c index db778afa94..d3906f9fae 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1,6 +1,6 @@ /* Perform non-arithmetic operations on values, for GDB. Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, - 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -89,8 +89,30 @@ int overload_resolution = 0; The default is to stop in the frame where the signal was received. */ int unwind_on_signal_p = 0; - +/* How you should pass arguments to a function depends on whether it + was defined in K&R style or prototype style. If you define a + function using the K&R syntax that takes a `float' argument, then + callers must pass that argument as a `double'. If you define the + function using the prototype syntax, then you must pass the + argument as a `float', with no promotion. + + Unfortunately, on certain older platforms, the debug info doesn't + indicate reliably how each function was defined. A function type's + TYPE_FLAG_PROTOTYPED flag may be clear, even if the function was + defined in prototype style. When calling a function whose + TYPE_FLAG_PROTOTYPED flag is clear, GDB consults this flag to decide + what to do. + + For modern targets, it is proper to assume that, if the prototype + flag is clear, that can be trusted: `float' arguments should be + promoted to `double'. For some older targets, if the prototype + flag is clear, that doesn't tell us anything. The default is to + trust the debug information; the user can override this behavior + with "set coerce-float-to-double 0". */ + +static int coerce_float_to_double; + /* Find the address of function name NAME in the inferior. */ @@ -1054,49 +1076,6 @@ default_push_arguments (int nargs, struct value **args, CORE_ADDR sp, return sp; } - -/* Functions to use for the COERCE_FLOAT_TO_DOUBLE gdbarch method. - - How you should pass arguments to a function depends on whether it - was defined in K&R style or prototype style. If you define a - function using the K&R syntax that takes a `float' argument, then - callers must pass that argument as a `double'. If you define the - function using the prototype syntax, then you must pass the - argument as a `float', with no promotion. - - Unfortunately, on certain older platforms, the debug info doesn't - indicate reliably how each function was defined. A function type's - TYPE_FLAG_PROTOTYPED flag may be clear, even if the function was - defined in prototype style. When calling a function whose - TYPE_FLAG_PROTOTYPED flag is clear, GDB consults the - COERCE_FLOAT_TO_DOUBLE gdbarch method to decide what to do. - - For modern targets, it is proper to assume that, if the prototype - flag is clear, that can be trusted: `float' arguments should be - promoted to `double'. You should register the function - `standard_coerce_float_to_double' to get this behavior. - - For some older targets, if the prototype flag is clear, that - doesn't tell us anything. So we guess that, if we don't have a - type for the formal parameter (i.e., the first argument to - COERCE_FLOAT_TO_DOUBLE is null), then we should promote it; - otherwise, we should leave it alone. The function - `default_coerce_float_to_double' provides this behavior; it is the - default value, for compatibility with older configurations. */ -int -default_coerce_float_to_double (struct type *formal, struct type *actual) -{ - return formal == NULL; -} - - -int -standard_coerce_float_to_double (struct type *formal, struct type *actual) -{ - return 1; -} - - /* Perform the standard coercions that are specified for arguments to be passed to C functions. @@ -1139,11 +1118,7 @@ value_arg_coerce (struct value *arg, struct type *param_type, type = builtin_type_int; break; case TYPE_CODE_FLT: - /* FIXME: We should always convert floats to doubles in the - non-prototyped case. As many debugging formats include - no information about prototyping, we have to live with - COERCE_FLOAT_TO_DOUBLE for now. */ - if (!is_prototyped && COERCE_FLOAT_TO_DOUBLE (param_type, arg_type)) + if (!is_prototyped && coerce_float_to_double) { if (TYPE_LENGTH (type) < TYPE_LENGTH (builtin_type_double)) type = builtin_type_double; @@ -3496,4 +3471,19 @@ is received while in a function called from gdb (call dummy). If set, gdb\n\ unwinds the stack and restore the context to what as it was before the call.\n\ The default is to stop in the frame where the signal was received.", &setlist), &showlist); + + add_show_from_set + (add_set_cmd ("coerce-float-to-double", class_obscure, var_boolean, + (char *) &coerce_float_to_double, + "Set coercion of floats to doubles when calling functions\n" + "Variables of type float should generally be converted to doubles before\n" + "calling an unprototyped function, and left alone when calling a prototyped\n" + "function. However, some older debug info formats do not provide enough\n" + "information to determine that a function is prototyped. If this flag is\n" + "set, GDB will perform the conversion for a function it considers\n" + "unprototyped.\n" + "The default is to perform the conversion.\n", + &setlist), + &showlist); + coerce_float_to_double = 1; } diff --git a/gdb/value.h b/gdb/value.h index f09c247232..7e108c691e 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1,6 +1,6 @@ /* Definitions for values of C expressions, for GDB. Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, - 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -548,10 +548,6 @@ extern struct value *value_slice (struct value *, int, int); extern struct value *call_function_by_hand (struct value *, int, struct value **); -extern int default_coerce_float_to_double (struct type *, struct type *); - -extern int standard_coerce_float_to_double (struct type *, struct type *); - extern struct value *value_literal_complex (struct value *, struct value *, struct type *); diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index 4cf9794b66..0c14f3da14 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -1,6 +1,6 @@ /* Target-dependent code for the Sanyo Xstormy16a (LC590000) processor. - Copyright 2001, 2002 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GDB. @@ -1078,10 +1078,6 @@ xstormy16_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* OK to default this value to 'unknown'. */ set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown); - /* W/o prototype, coerce float args to double. */ - set_gdbarch_coerce_float_to_double (gdbarch, - standard_coerce_float_to_double); - /* * Call Dummies *