From 3543a589b22f9e26af4f71ce737dd9aae3410fda Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 22 Jul 2011 15:31:52 +0000 Subject: gdb * amd64-tdep.c (amd64_pseudo_register_read_value): Rename from amd64_pseudo_register_read. Change arguments. Call mark_value_bytes_unavailable when needed. (amd64_init_abi): Use set_gdbarch_pseudo_register_read_value, not set_gdbarch_pseudo_register_read. * sentinel-frame.c (sentinel_frame_prev_register): Use regcache_cooked_read_value. * regcache.h (regcache_cooked_read_value): Declare. * regcache.c (regcache_cooked_read_value): New function. (regcache_cooked_read): Call gdbarch_pseudo_register_read_value if available. * i386-tdep.h (i386_pseudo_register_read_value): Declare. (i386_pseudo_register_read): Remove. * i386-tdep.c (i386_pseudo_register_read_into_value): Rename from i386_pseudo_register_read. Change arguments. Call mark_value_bytes_unavailable when needed. (i386_pseudo_register_read_value): New function. (i386_gdbarch_init): Call set_gdbarch_pseudo_register_read_value, not set_gdbarch_pseudo_register_read. * gdbarch.sh (pseudo_register_read_value): New method. * gdbarch.c, gdbarch.h: Rebuild. * findvar.c (value_from_register): Call get_frame_register_value. gdb/testsuite * gdb.dwarf2/typeddwarf.c: XFAIL 'z' on x86-64. * gdb.dwarf2/typeddwarf.exp (xfail-gdb-test): Add arch_pattern argument. * gdb.dwarf2/typeddwarf-amd64.S: New file. --- gdb/regcache.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'gdb/regcache.c') diff --git a/gdb/regcache.c b/gdb/regcache.c index 41f218d..0af93e8 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -709,11 +709,66 @@ regcache_cooked_read (struct regcache *regcache, int regnum, gdb_byte *buf) return regcache->register_status[regnum]; } + else if (gdbarch_pseudo_register_read_value_p (regcache->descr->gdbarch)) + { + struct value *mark, *computed; + enum register_status result = REG_VALID; + + mark = value_mark (); + + computed = gdbarch_pseudo_register_read_value (regcache->descr->gdbarch, + regcache, regnum); + if (value_entirely_available (computed)) + memcpy (buf, value_contents_raw (computed), + regcache->descr->sizeof_register[regnum]); + else + { + memset (buf, 0, regcache->descr->sizeof_register[regnum]); + result = REG_UNAVAILABLE; + } + + value_free_to_mark (mark); + + return result; + } else return gdbarch_pseudo_register_read (regcache->descr->gdbarch, regcache, regnum, buf); } +struct value * +regcache_cooked_read_value (struct regcache *regcache, int regnum) +{ + gdb_assert (regnum >= 0); + gdb_assert (regnum < regcache->descr->nr_cooked_registers); + + if (regnum < regcache->descr->nr_raw_registers + || (regcache->readonly_p + && regcache->register_status[regnum] != REG_UNKNOWN) + || !gdbarch_pseudo_register_read_value_p (regcache->descr->gdbarch)) + { + struct value *result; + + result = allocate_value (register_type (regcache->descr->gdbarch, + regnum)); + VALUE_LVAL (result) = lval_register; + VALUE_REGNUM (result) = regnum; + + /* It is more efficient in general to do this delegation in this + direction than in the other one, even though the value-based + API is preferred. */ + if (regcache_cooked_read (regcache, regnum, + value_contents_raw (result)) == REG_UNAVAILABLE) + mark_value_bytes_unavailable (result, 0, + TYPE_LENGTH (value_type (result))); + + return result; + } + else + return gdbarch_pseudo_register_read_value (regcache->descr->gdbarch, + regcache, regnum); +} + enum register_status regcache_cooked_read_signed (struct regcache *regcache, int regnum, LONGEST *val) -- cgit v1.1