From 215c69dc9a7d8f868198b5523abcf41458fb6e4a Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Wed, 21 Feb 2018 11:20:03 +0000 Subject: No longer create readonly regcache Nowadays, we create a readonly regcache in get_return_value, and pass it to gdbarch_return_value to get the return value. In theory, we can pass a readable_regcache instance and get the return value, because we don't need to modify the regcache. Unfortunately, gdbarch_return_value is designed to multiplex regcache, according to READBUF and WRITEBUF. # If READBUF is not NULL, extract the return value and save it in this # buffer. # # If WRITEBUF is not NULL, it contains a return value which will be # stored into the appropriate register. In fact, gdbarch_return_value should be split to three functions, 1) only return return_value_convention, 2) pass regcache_readonly and readbuf, 3) pass regcache and writebuf. These changes are out of the scope of this patch series, so I pass regcache to gdbarch_return_value even for read, and trust each gdbarch backend doesn't modify regcache. gdb: 2018-02-21 Yao Qi * infcmd.c (get_return_value): Let stop_regs point to get_current_regcache. * regcache.c (regcache::regcache): Remove. (register_dump_reg_buffer): New class. (regcache_print): Adjust. * regcache.h (regcache): Remove constructors. --- gdb/infcmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gdb/infcmd.c') diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 331fd8751b1..c10a49892e3 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1625,8 +1625,8 @@ advance_command (const char *arg, int from_tty) struct value * get_return_value (struct value *function, struct type *value_type) { - regcache stop_regs (regcache::readonly, *get_current_regcache ()); - struct gdbarch *gdbarch = stop_regs.arch (); + regcache *stop_regs = get_current_regcache (); + struct gdbarch *gdbarch = stop_regs->arch (); struct value *value; value_type = check_typedef (value_type); @@ -1646,7 +1646,7 @@ get_return_value (struct value *function, struct type *value_type) case RETURN_VALUE_ABI_RETURNS_ADDRESS: case RETURN_VALUE_ABI_PRESERVES_ADDRESS: value = allocate_value (value_type); - gdbarch_return_value (gdbarch, function, value_type, &stop_regs, + gdbarch_return_value (gdbarch, function, value_type, stop_regs, value_contents_raw (value), NULL); break; case RETURN_VALUE_STRUCT_CONVENTION: -- cgit v1.2.1