aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2003-09-17 19:48:42 +0000
committerMark Kettenis <kettenis@gnu.org>2003-09-17 19:48:42 +0000
commit192cb3d4e24944db8dfac26575a1209605dffee0 (patch)
tree99165e9de7a4ccea2fb6d292bfd3c07b16ca5eb7 /gdb
parentefe59759d8d01aa611222e4d7000e41561945741 (diff)
downloadgdb-192cb3d4e24944db8dfac26575a1209605dffee0.zip
gdb-192cb3d4e24944db8dfac26575a1209605dffee0.tar.gz
gdb-192cb3d4e24944db8dfac26575a1209605dffee0.tar.bz2
* gdbarch.sh (DEPRECATED_REG_STRUCT_HAS_ADDR): Add comment.
* gdbarch.h, gdbarch.c: Regenerate. (stabs_argument_has_addr): New architecture method. * arch-utils.h (default_stabs_argument_has_addr): New prototype. * arch-utils.c: Include "buildsym.h". (default_stabs_argument_has_addr): New function. * stabsread.c (define_symbol): Use stabs_argument_has_addr instead of DEPRECATED_REG_STRUCT_HAS_ADDR.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/arch-utils.c18
-rw-r--r--gdb/arch-utils.h3
-rw-r--r--gdb/gdbarch.c24
-rw-r--r--gdb/gdbarch.h11
-rwxr-xr-xgdb/gdbarch.sh3
-rw-r--r--gdb/stabsread.c66
7 files changed, 96 insertions, 40 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4601597..15fe387 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2003-09-17 Mark Kettenis <kettenis@gnu.org>
+
+ * gdbarch.sh (DEPRECATED_REG_STRUCT_HAS_ADDR): Add comment.
+ * gdbarch.h, gdbarch.c: Regenerate.
+ (stabs_argument_has_addr): New architecture method.
+ * arch-utils.h (default_stabs_argument_has_addr): New prototype.
+ * arch-utils.c: Include "buildsym.h".
+ (default_stabs_argument_has_addr): New function.
+ * stabsread.c (define_symbol): Use stabs_argument_has_addr
+ instead of DEPRECATED_REG_STRUCT_HAS_ADDR.
+
2003-09-17 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh (DEPRECATED_NPC_REGNUM): Deprecate NPC_REGNUM.
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index e344ec0..9289e7a 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -23,6 +23,7 @@
#include "defs.h"
#include "arch-utils.h"
+#include "buildsym.h"
#include "gdbcmd.h"
#include "inferior.h" /* enum CALL_DUMMY_LOCATION et.al. */
#include "gdb_string.h"
@@ -359,6 +360,23 @@ legacy_value_to_register (struct frame_info *frame, int regnum,
put_frame_register (frame, regnum, to);
}
+int
+default_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
+{
+ if (DEPRECATED_REG_STRUCT_HAS_ADDR_P ()
+ && DEPRECATED_REG_STRUCT_HAS_ADDR (processing_gcc_compilation, type))
+ {
+ CHECK_TYPEDEF (type);
+
+ return (TYPE_CODE (type) == TYPE_CODE_STRUCT
+ || TYPE_CODE (type) == TYPE_CODE_UNION
+ || TYPE_CODE (type) == TYPE_CODE_SET
+ || TYPE_CODE (type) == TYPE_CODE_BITSTRING);
+ }
+
+ return 0;
+}
+
/* Functions to manipulate the endianness of the target. */
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index d2e6829..06f7bf3 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -138,6 +138,9 @@ extern void legacy_register_to_value (struct frame_info *frame, int regnum,
extern void legacy_value_to_register (struct frame_info *frame, int regnum,
struct type *type, const void *from);
+extern int default_stabs_argument_has_addr (struct gdbarch *gdbarch,
+ struct type *type);
+
/* For compatibility with older architectures, returns
(LEGACY_SIM_REGNO_IGNORE) when the register doesn't have a valid
name. */
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 974a3c0..274e67c 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -238,6 +238,7 @@ struct gdbarch
gdbarch_deprecated_stack_align_ftype *deprecated_stack_align;
gdbarch_frame_align_ftype *frame_align;
gdbarch_deprecated_reg_struct_has_addr_ftype *deprecated_reg_struct_has_addr;
+ gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr;
int frame_red_zone_size;
int parm_boundary;
const struct floatformat * float_format;
@@ -406,6 +407,7 @@ struct gdbarch startup_gdbarch =
0, /* deprecated_stack_align */
0, /* frame_align */
0, /* deprecated_reg_struct_has_addr */
+ default_stabs_argument_has_addr, /* stabs_argument_has_addr */
0, /* frame_red_zone_size */
0, /* parm_boundary */
0, /* float_format */
@@ -540,6 +542,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
current_gdbarch->frameless_function_invocation = generic_frameless_function_invocation_not;
current_gdbarch->deprecated_frame_args_address = get_frame_base;
current_gdbarch->deprecated_frame_locals_address = get_frame_base;
+ current_gdbarch->stabs_argument_has_addr = default_stabs_argument_has_addr;
current_gdbarch->convert_from_func_ptr_addr = core_addr_identity;
current_gdbarch->addr_bits_remove = core_addr_identity;
current_gdbarch->smash_text_address = core_addr_identity;
@@ -730,6 +733,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of deprecated_stack_align, has predicate */
/* Skip verify of frame_align, has predicate */
/* Skip verify of deprecated_reg_struct_has_addr, has predicate */
+ /* Skip verify of stabs_argument_has_addr, invalid_p == 0 */
if (gdbarch->float_format == 0)
gdbarch->float_format = default_float_format (gdbarch);
if (gdbarch->double_format == 0)
@@ -798,6 +802,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: register_reggroup_p = 0x%08lx\n",
(long) current_gdbarch->register_reggroup_p);
fprintf_unfiltered (file,
+ "gdbarch_dump: stabs_argument_has_addr = 0x%08lx\n",
+ (long) current_gdbarch->stabs_argument_has_addr);
+ fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_pseudo_register_read_p() = %d\n",
gdbarch_pseudo_register_read_p (current_gdbarch));
fprintf_unfiltered (file,
@@ -4931,6 +4938,23 @@ set_gdbarch_deprecated_reg_struct_has_addr (struct gdbarch *gdbarch,
}
int
+gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->stabs_argument_has_addr != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stabs_argument_has_addr called\n");
+ return gdbarch->stabs_argument_has_addr (gdbarch, type);
+}
+
+void
+set_gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch,
+ gdbarch_stabs_argument_has_addr_ftype stabs_argument_has_addr)
+{
+ gdbarch->stabs_argument_has_addr = stabs_argument_has_addr;
+}
+
+int
gdbarch_frame_red_zone_size (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 65006ca..9991371 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -1939,6 +1939,9 @@ typedef CORE_ADDR (gdbarch_frame_align_ftype) (struct gdbarch *gdbarch, CORE_ADD
extern CORE_ADDR gdbarch_frame_align (struct gdbarch *gdbarch, CORE_ADDR address);
extern void set_gdbarch_frame_align (struct gdbarch *gdbarch, gdbarch_frame_align_ftype *frame_align);
+/* DEPRECATED_REG_STRUCT_HAS_ADDR has been replaced by
+ stabs_argument_has_addr. */
+
#if defined (DEPRECATED_REG_STRUCT_HAS_ADDR)
/* Legacy for systems yet to multi-arch DEPRECATED_REG_STRUCT_HAS_ADDR */
#if !defined (DEPRECATED_REG_STRUCT_HAS_ADDR_P)
@@ -1964,6 +1967,10 @@ extern void set_gdbarch_deprecated_reg_struct_has_addr (struct gdbarch *gdbarch,
#define DEPRECATED_REG_STRUCT_HAS_ADDR(gcc_p, type) (gdbarch_deprecated_reg_struct_has_addr (current_gdbarch, gcc_p, type))
#endif
+typedef int (gdbarch_stabs_argument_has_addr_ftype) (struct gdbarch *gdbarch, struct type *type);
+extern int gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type);
+extern void set_gdbarch_stabs_argument_has_addr (struct gdbarch *gdbarch, gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr);
+
extern int gdbarch_frame_red_zone_size (struct gdbarch *gdbarch);
extern void set_gdbarch_frame_red_zone_size (struct gdbarch *gdbarch, int frame_red_zone_size);
#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (FRAME_RED_ZONE_SIZE)
@@ -2039,7 +2046,7 @@ extern void set_gdbarch_addr_bits_remove (struct gdbarch *gdbarch, gdbarch_addr_
#define ADDR_BITS_REMOVE(addr) (gdbarch_addr_bits_remove (current_gdbarch, addr))
#endif
-/* It is not at all clear why SMASH_TEXT_ADDRESS is not folded into
+/* It is not at all clear why SMASH_TEXT_ADDRESS is not folded into
ADDR_BITS_REMOVE. */
typedef CORE_ADDR (gdbarch_smash_text_address_ftype) (CORE_ADDR addr);
@@ -2333,7 +2340,7 @@ typedef int (gdbarch_register_reggroup_p_ftype) (struct gdbarch *gdbarch, int re
extern int gdbarch_register_reggroup_p (struct gdbarch *gdbarch, int regnum, struct reggroup *reggroup);
extern void set_gdbarch_register_reggroup_p (struct gdbarch *gdbarch, gdbarch_register_reggroup_p_ftype *register_reggroup_p);
-/* Fetch the pointer to the ith function argument. */
+/* Fetch the pointer to the ith function argument. */
#if defined (FETCH_POINTER_ARGUMENT)
/* Legacy for systems yet to multi-arch FETCH_POINTER_ARGUMENT */
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 0884c3c..47ca465 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -648,7 +648,10 @@ F:2:FRAME_NUM_ARGS:int:frame_num_args:struct frame_info *frame:frame
# alignment.
F:2:DEPRECATED_STACK_ALIGN:CORE_ADDR:deprecated_stack_align:CORE_ADDR sp:sp
M:::CORE_ADDR:frame_align:CORE_ADDR address:address
+# DEPRECATED_REG_STRUCT_HAS_ADDR has been replaced by
+# stabs_argument_has_addr.
F:2:DEPRECATED_REG_STRUCT_HAS_ADDR:int:deprecated_reg_struct_has_addr:int gcc_p, struct type *type:gcc_p, type
+m:::int:stabs_argument_has_addr:struct type *type:type:::default_stabs_argument_has_addr::0
v::FRAME_RED_ZONE_SIZE:int:frame_red_zone_size
v:2:PARM_BOUNDARY:int:parm_boundary
#
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index abfbefc..93f61d5 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1748,17 +1748,20 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
if (within_function)
{
- /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
- name to represent an argument passed in a register.
- GCC uses 'P' for the same case. So if we find such a symbol pair
- we combine it into one 'P' symbol. For Sun cc we need to do this
- regardless of DEPRECATED_REG_STRUCT_HAS_ADDR, because the compiler puts out
- the 'p' symbol even if it never saves the argument onto the stack.
-
- On most machines, we want to preserve both symbols, so that
- we can still get information about what is going on with the
- stack (VAX for computing args_printed, using stack slots instead
- of saved registers in backtraces, etc.).
+ /* Sun cc uses a pair of symbols, one 'p' and one 'r', with
+ the same name to represent an argument passed in a
+ register. GCC uses 'P' for the same case. So if we find
+ such a symbol pair we combine it into one 'P' symbol.
+ For Sun cc we need to do this regardless of
+ stabs_argument_has_addr, because the compiler puts out
+ the 'p' symbol even if it never saves the argument onto
+ the stack.
+
+ On most machines, we want to preserve both symbols, so
+ that we can still get information about what is going on
+ with the stack (VAX for computing args_printed, using
+ stack slots instead of saved registers in backtraces,
+ etc.).
Note that this code illegally combines
main(argc) struct foo argc; { register struct foo argc; }
@@ -1768,13 +1771,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
if (local_symbols
&& local_symbols->nsyms > 0
#ifndef USE_REGISTER_NOT_ARG
- && DEPRECATED_REG_STRUCT_HAS_ADDR_P ()
- && DEPRECATED_REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
- SYMBOL_TYPE (sym))
- && (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
- || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION
- || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET
- || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING)
+ && gdbarch_stabs_argument_has_addr (current_gdbarch,
+ SYMBOL_TYPE (sym))
#endif
)
{
@@ -2047,29 +2045,21 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
break;
}
- /* When passing structures to a function, some systems sometimes pass
- the address in a register, not the structure itself. */
+ /* Some systems pass variables of certain types by reference instead
+ of by value, i.e. they will pass the address of a structure (in a
+ register or on the stack) instead of the structure itself. */
- if (DEPRECATED_REG_STRUCT_HAS_ADDR_P ()
- && DEPRECATED_REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym))
+ if (gdbarch_stabs_argument_has_addr (current_gdbarch, SYMBOL_TYPE (sym))
&& (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
{
- struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym));
-
- if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT)
- || (TYPE_CODE (symbol_type) == TYPE_CODE_UNION)
- || (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING)
- || (TYPE_CODE (symbol_type) == TYPE_CODE_SET))
- {
- /* If DEPRECATED_REG_STRUCT_HAS_ADDR yields non-zero we have to convert
- LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
- if (SYMBOL_CLASS (sym) == LOC_REGPARM)
- SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
- /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
- and subsequent arguments on the sparc, for example). */
- else if (SYMBOL_CLASS (sym) == LOC_ARG)
- SYMBOL_CLASS (sym) = LOC_REF_ARG;
- }
+ /* We have to convert LOC_REGPARM to LOC_REGPARM_ADDR (for
+ variables passed in a register). */
+ if (SYMBOL_CLASS (sym) == LOC_REGPARM)
+ SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+ /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
+ and subsequent arguments on SPARC, for example). */
+ else if (SYMBOL_CLASS (sym) == LOC_ARG)
+ SYMBOL_CLASS (sym) = LOC_REF_ARG;
}
/* Is there more to parse? For example LRS/alias information? */