diff options
-rw-r--r-- | gnu/usr.bin/binutils/gdb/amd64-tdep.c | 112 |
1 files changed, 38 insertions, 74 deletions
diff --git a/gnu/usr.bin/binutils/gdb/amd64-tdep.c b/gnu/usr.bin/binutils/gdb/amd64-tdep.c index 90a4e11bed0..e0b2ca046f5 100644 --- a/gnu/usr.bin/binutils/gdb/amd64-tdep.c +++ b/gnu/usr.bin/binutils/gdb/amd64-tdep.c @@ -371,11 +371,8 @@ amd64_classify (struct type *type, enum amd64_reg_class class[2]) class[0] = class[1] = AMD64_NO_CLASS; /* Arguments of types (signed and unsigned) _Bool, char, short, int, - long, long long, and pointers are in the INTEGER class. Similarly, - range types, used by languages such as Ada, are also in the INTEGER - class. */ + long, long long, and pointers are in the INTEGER class. */ if ((code == TYPE_CODE_INT || code == TYPE_CODE_ENUM - || code == TYPE_CODE_RANGE || code == TYPE_CODE_PTR || code == TYPE_CODE_REF) && (len == 1 || len == 2 || len == 4 || len == 8)) class[0] = AMD64_INTEGER; @@ -422,28 +419,11 @@ amd64_return_value (struct gdbarch *gdbarch, struct type *type, 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 - %rdi as if it were the first argument to the function. In effect, - this address becomes a hidden first argument. - - On return %rax will contain the address that has been passed in - by the caller in %rdi. */ + for the return value and passes the address of this storage in + %rdi as if it were the first argument to the function. In + effect, this address becomes a hidden first argument. */ if (class[0] == AMD64_MEMORY) - { - /* As indicated by the comment above, the ABI guarantees that we - can always find the return value just after the function has - returned. */ - - if (readbuf) - { - ULONGEST addr; - - regcache_raw_read_unsigned (regcache, AMD64_RAX_REGNUM, &addr); - read_memory (addr, readbuf, TYPE_LENGTH (type)); - } - - return RETURN_VALUE_ABI_RETURNS_ADDRESS; - } + return RETURN_VALUE_STRUCT_CONVENTION; gdb_assert (class[1] != AMD64_MEMORY); gdb_assert (len <= 16); @@ -646,7 +626,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs, } static CORE_ADDR -amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, +amd64_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, int struct_return, CORE_ADDR struct_addr) @@ -781,7 +761,7 @@ amd64_skip_prologue (CORE_ADDR start_pc) struct amd64_frame_cache cache; CORE_ADDR pc; - pc = amd64_analyze_prologue (start_pc, 0xffffffffffffffffLL, &cache); + pc = amd64_analyze_prologue (start_pc, 0xffffffffffffffff, &cache); if (cache.frameless_p) return start_pc; @@ -984,26 +964,15 @@ static const struct frame_unwind amd64_sigtramp_frame_unwind = static const struct frame_unwind * amd64_sigtramp_frame_sniffer (struct frame_info *next_frame) { - struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (next_frame)); - - /* We shouldn't even bother if we don't have a sigcontext_addr - handler. */ - if (tdep->sigcontext_addr == NULL) - return NULL; - - if (tdep->sigtramp_p != NULL) - { - if (tdep->sigtramp_p (next_frame)) - return &amd64_sigtramp_frame_unwind; - } + CORE_ADDR pc = frame_pc_unwind (next_frame); + char *name; - if (tdep->sigtramp_start != 0) + find_pc_partial_function (pc, &name, NULL, NULL); + if (PC_IN_SIGTRAMP (pc, name)) { - CORE_ADDR pc = frame_pc_unwind (next_frame); + gdb_assert (gdbarch_tdep (current_gdbarch)->sigcontext_addr); - gdb_assert (tdep->sigtramp_end != 0); - if (pc >= tdep->sigtramp_start && pc < tdep->sigtramp_end) - return &amd64_sigtramp_frame_unwind; + return &amd64_sigtramp_frame_unwind; } return NULL; @@ -1048,36 +1017,20 @@ amd64_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp) } -/* Supply register REGNUM from the buffer specified by FPREGS and LEN - in the floating-point register set REGSET to register cache - REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */ +/* Supply register REGNUM from the floating-point register set REGSET + to register cache REGCACHE. If REGNUM is -1, do this for all + registers in REGSET. */ static void amd64_supply_fpregset (const struct regset *regset, struct regcache *regcache, int regnum, const void *fpregs, size_t len) { - const struct gdbarch_tdep *tdep = gdbarch_tdep (regset->arch); + const struct gdbarch_tdep *tdep = regset->descr; gdb_assert (len == tdep->sizeof_fpregset); amd64_supply_fxsave (regcache, regnum, fpregs); } -/* Collect register REGNUM from the register cache REGCACHE and store - it in the buffer specified by FPREGS and LEN as described by the - floating-point register set REGSET. If REGNUM is -1, do this for - all registers in REGSET. */ - -static void -amd64_collect_fpregset (const struct regset *regset, - const struct regcache *regcache, - int regnum, void *fpregs, size_t len) -{ - const struct gdbarch_tdep *tdep = gdbarch_tdep (regset->arch); - - gdb_assert (len == tdep->sizeof_fpregset); - amd64_collect_fxsave (regcache, regnum, fpregs); -} - /* Return the appropriate register set for the core section identified by SECT_NAME and SECT_SIZE. */ @@ -1090,8 +1043,11 @@ amd64_regset_from_core_section (struct gdbarch *gdbarch, if (strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset) { if (tdep->fpregset == NULL) - tdep->fpregset = regset_alloc (gdbarch, amd64_supply_fpregset, - amd64_collect_fpregset); + { + tdep->fpregset = XMALLOC (struct regset); + tdep->fpregset->descr = tdep; + tdep->fpregset->supply_regset = amd64_supply_fpregset; + } return tdep->fpregset; } @@ -1201,7 +1157,7 @@ amd64_supply_fxsave (struct regcache *regcache, int regnum, { i387_supply_fxsave (regcache, regnum, fxsave); - if (fxsave && gdbarch_ptr_bit (get_regcache_arch (regcache)) == 64) + if (fxsave) { const char *regs = fxsave; @@ -1225,11 +1181,19 @@ amd64_collect_fxsave (const struct regcache *regcache, int regnum, i387_collect_fxsave (regcache, regnum, fxsave); - if (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 64) - { - if (regnum == -1 || regnum == I387_FISEG_REGNUM) - regcache_raw_collect (regcache, I387_FISEG_REGNUM, regs + 12); - if (regnum == -1 || regnum == I387_FOSEG_REGNUM) - regcache_raw_collect (regcache, I387_FOSEG_REGNUM, regs + 20); - } + if (regnum == -1 || regnum == I387_FISEG_REGNUM) + regcache_raw_collect (regcache, I387_FISEG_REGNUM, regs + 12); + if (regnum == -1 || regnum == I387_FOSEG_REGNUM) + regcache_raw_collect (regcache, I387_FOSEG_REGNUM, regs + 20); +} + +/* Fill register REGNUM (if it is a floating-point or SSE register) in + *FXSAVE with the value in GDB's register cache. If REGNUM is -1, do + this for all registers. This function doesn't touch any of the + reserved bits in *FXSAVE. */ + +void +amd64_fill_fxsave (char *fxsave, int regnum) +{ + amd64_collect_fxsave (current_regcache, regnum, fxsave); } |