From bf4d6c1cfc72fc4d60becc31cb9076d3185c8cfe Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Tue, 24 Sep 2013 16:14:15 +0000 Subject: [PATCH] Revert use of classify callback in i386 gdbarch_tdep. This is no longer useful, as it was introduced to reuse the funcall handling code in amd64-tdep.c in the context of x64-windows. But we have since then changed the implementations to be completely independent of each other. This reverts the non-windows-specific part of the change called: amd64: Integer parameters in function calls on Windows (the x64-windows portion has already been reverted) gdb/ChangeLog: Revert: * i386-tdep.h (enum amd64_reg_class): New, moved here from amd64-tdep.c. (struct gdbarch_tdep): Add fields call_dummy_num_integer_regs, call_dummy_integer_regs, and classify. * amd64-tdep.h (amd64_classify): Add declaration. * amd64-tdep.c (amd64_dummy_call_integer_regs): New static constant. (amd64_reg_class): Delete, moved to i386-tdep.h. (amd64_classify): Make non-static. Move declaration to amd64-tdep.h. Replace call to amd64_classify by call to tdep->classify. (amd64_push_arguments): Get the list of registers to use for passing integer parameters from the gdbarch tdep structure, rather than using a hardcoded one. Replace calls to amd64_classify by calls to tdep->classify. (amd64_push_dummy_call): Get the register number used for the "hidden" argument from tdep->call_dummy_integer_regs. (amd64_init_abi): Initialize tdep->call_dummy_num_integer_regs and tdep->call_dummy_integer_regs. Set tdep->classify. --- gdb/ChangeLog | 21 ++++++++++++++++++ gdb/amd64-tdep.c | 65 +++++++++++++++++++++++++++----------------------------- gdb/amd64-tdep.h | 4 ---- gdb/i386-tdep.h | 24 --------------------- 4 files changed, 52 insertions(+), 62 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cd03e31..9d42eec 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,6 +1,27 @@ 2013-09-24 Joel Brobecker Revert: + * i386-tdep.h (enum amd64_reg_class): New, moved here from + amd64-tdep.c. + (struct gdbarch_tdep): Add fields call_dummy_num_integer_regs, + call_dummy_integer_regs, and classify. + * amd64-tdep.h (amd64_classify): Add declaration. + * amd64-tdep.c (amd64_dummy_call_integer_regs): New static constant. + (amd64_reg_class): Delete, moved to i386-tdep.h. + (amd64_classify): Make non-static. Move declaration to amd64-tdep.h. + Replace call to amd64_classify by call to tdep->classify. + (amd64_push_arguments): Get the list of registers to use for + passing integer parameters from the gdbarch tdep structure, + rather than using a hardcoded one. Replace calls to amd64_classify + by calls to tdep->classify. + (amd64_push_dummy_call): Get the register number used for + the "hidden" argument from tdep->call_dummy_integer_regs. + (amd64_init_abi): Initialize tdep->call_dummy_num_integer_regs + and tdep->call_dummy_integer_regs. Set tdep->classify. + +2013-09-24 Joel Brobecker + + Revert: * i386-tdep.h (gdbarch_tdep): Add field memory_args_by_pointer. * amd64-tdep.c (amd64_push_arguments): Add handling of architectures where tdep->memory_args_by_pointer is non-zero. diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 35526cf..37218ce 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -92,17 +92,6 @@ static const char *amd64_ymmh_names[] = "ymm12h", "ymm13h", "ymm14h", "ymm15h" }; -/* The registers used to pass integer arguments during a function call. */ -static int amd64_dummy_call_integer_regs[] = -{ - AMD64_RDI_REGNUM, /* %rdi */ - AMD64_RSI_REGNUM, /* %rsi */ - AMD64_RDX_REGNUM, /* %rdx */ - AMD64_RCX_REGNUM, /* %rcx */ - 8, /* %r8 */ - 9 /* %r9 */ -}; - /* DWARF Register Number Mapping as defined in the System V psABI, section 3.6. */ @@ -391,6 +380,20 @@ amd64_pseudo_register_write (struct gdbarch *gdbarch, +/* Register classes as defined in the psABI. */ + +enum amd64_reg_class +{ + AMD64_INTEGER, + AMD64_SSE, + AMD64_SSEUP, + AMD64_X87, + AMD64_X87UP, + AMD64_COMPLEX_X87, + AMD64_NO_CLASS, + AMD64_MEMORY +}; + /* Return the union class of CLASS1 and CLASS2. See the psABI for details. */ @@ -427,6 +430,8 @@ amd64_merge_classes (enum amd64_reg_class class1, enum amd64_reg_class class2) return AMD64_SSE; } +static void amd64_classify (struct type *type, enum amd64_reg_class class[2]); + /* Return non-zero if TYPE is a non-POD structure or union type. */ static int @@ -546,7 +551,7 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class class[2]) /* Classify TYPE, and store the result in CLASS. */ -void +static void amd64_classify (struct type *type, enum amd64_reg_class class[2]) { enum type_code code = TYPE_CODE (type); @@ -614,7 +619,6 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, gdb_byte *readbuf, const gdb_byte *writebuf) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum amd64_reg_class class[2]; int len = TYPE_LENGTH (type); static int integer_regnum[] = { AMD64_RAX_REGNUM, AMD64_RDX_REGNUM }; @@ -624,10 +628,9 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function, int i; gdb_assert (!(readbuf && writebuf)); - gdb_assert (tdep->classify); /* 1. Classify the return type with the classification algorithm. */ - tdep->classify (type, class); + amd64_classify (type, class); /* 2. If the type has class MEMORY, then the caller provides space for the return value and passes the address of this storage in @@ -749,10 +752,15 @@ static CORE_ADDR amd64_push_arguments (struct regcache *regcache, int nargs, struct value **args, CORE_ADDR sp, int struct_return) { - struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache)); - int *integer_regs = tdep->call_dummy_integer_regs; - int num_integer_regs = tdep->call_dummy_num_integer_regs; - + static int integer_regnum[] = + { + AMD64_RDI_REGNUM, /* %rdi */ + AMD64_RSI_REGNUM, /* %rsi */ + AMD64_RDX_REGNUM, /* %rdx */ + AMD64_RCX_REGNUM, /* %rcx */ + 8, /* %r8 */ + 9 /* %r9 */ + }; static int sse_regnum[] = { /* %xmm0 ... %xmm7 */ @@ -769,8 +777,6 @@ amd64_push_arguments (struct regcache *regcache, int nargs, int sse_reg = 0; int i; - gdb_assert (tdep->classify); - /* Reserve a register for the "hidden" argument. */ if (struct_return) integer_reg++; @@ -785,7 +791,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs, int j; /* Classify argument. */ - tdep->classify (type, class); + amd64_classify (type, class); /* Calculate the number of integer and SSE registers needed for this argument. */ @@ -799,7 +805,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs, /* Check whether enough registers are available, and if the argument should be passed in registers at all. */ - if (integer_reg + needed_integer_regs > num_integer_regs + if (integer_reg + needed_integer_regs > ARRAY_SIZE (integer_regnum) || sse_reg + needed_sse_regs > ARRAY_SIZE (sse_regnum) || (needed_integer_regs == 0 && needed_sse_regs == 0)) { @@ -823,7 +829,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs, switch (class[j]) { case AMD64_INTEGER: - regnum = integer_regs[integer_reg++]; + regnum = integer_regnum[integer_reg++]; break; case AMD64_SSE: @@ -881,7 +887,6 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int struct_return, CORE_ADDR struct_addr) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); gdb_byte buf[8]; /* Pass arguments. */ @@ -890,12 +895,8 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Pass "hidden" argument". */ if (struct_return) { - /* The "hidden" argument is passed throught the first argument - register. */ - const int arg_regnum = tdep->call_dummy_integer_regs[0]; - store_unsigned_integer (buf, 8, byte_order, struct_addr); - regcache_cooked_write (regcache, arg_regnum, buf); + regcache_cooked_write (regcache, AMD64_RDI_REGNUM, buf); } /* Store return address. */ @@ -2888,10 +2889,6 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_push_dummy_call (gdbarch, amd64_push_dummy_call); set_gdbarch_frame_align (gdbarch, amd64_frame_align); set_gdbarch_frame_red_zone_size (gdbarch, 128); - tdep->call_dummy_num_integer_regs = - ARRAY_SIZE (amd64_dummy_call_integer_regs); - tdep->call_dummy_integer_regs = amd64_dummy_call_integer_regs; - tdep->classify = amd64_classify; set_gdbarch_convert_register_p (gdbarch, i387_convert_register_p); set_gdbarch_register_to_value (gdbarch, i387_register_to_value); diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h index a33e7d6..265e535 100644 --- a/gdb/amd64-tdep.h +++ b/gdb/amd64-tdep.h @@ -103,13 +103,9 @@ extern void amd64_supply_xsave (struct regcache *regcache, int regnum, extern void amd64_collect_fxsave (const struct regcache *regcache, int regnum, void *fxsave); - /* Similar to amd64_collect_fxsave, but use XSAVE extended state. */ extern void amd64_collect_xsave (const struct regcache *regcache, int regnum, void *xsave, int gcore); - -void amd64_classify (struct type *type, enum amd64_reg_class class[2]); - /* Variables exported from amd64-linux-tdep.c. */ diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index 0c408fa..092744c 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -52,20 +52,6 @@ enum struct_return reg_struct_return /* Return "short" structures in registers. */ }; -/* Register classes as defined in the AMD x86-64 psABI. */ - -enum amd64_reg_class -{ - AMD64_INTEGER, - AMD64_SSE, - AMD64_SSEUP, - AMD64_X87, - AMD64_X87UP, - AMD64_COMPLEX_X87, - AMD64_NO_CLASS, - AMD64_MEMORY -}; - /* i386 architecture specific information. */ struct gdbarch_tdep { @@ -75,16 +61,6 @@ struct gdbarch_tdep int gregset_num_regs; size_t sizeof_gregset; - /* The general-purpose registers used to pass integers when making - function calls. This only applies to amd64, as all parameters - are passed through the stack on x86. */ - int call_dummy_num_integer_regs; - int *call_dummy_integer_regs; - - /* Classify TYPE according to calling conventions, and store - the result in CLASS. Used on amd64 only. */ - void (*classify) (struct type *type, enum amd64_reg_class class[2]); - /* Floating-point registers. */ struct regset *fpregset; size_t sizeof_fpregset; -- 2.7.4