aboutsummaryrefslogtreecommitdiff
path: root/gdb/frame.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2018-06-20 12:49:03 -0400
committerSimon Marchi <simon.marchi@ericsson.com>2018-06-20 12:49:03 -0400
commit302abd6e9facdfec3473e19ff65a5479f850ad62 (patch)
treeb646934ec16de81d5b50fb474b3253e822b8bf63 /gdb/frame.c
parentf00674fe074f6ea778503a50132c3214a9c6aec8 (diff)
downloadgdb-302abd6e9facdfec3473e19ff65a5479f850ad62.zip
gdb-302abd6e9facdfec3473e19ff65a5479f850ad62.tar.gz
gdb-302abd6e9facdfec3473e19ff65a5479f850ad62.tar.bz2
Rename regcache_cooked_read_ftype and make a function_view
regcache_cooked_read_ftype can be converted to a function_view, which allows us to use lambda functions and therefore avoid having to pass an opaque pointer parameter. Adjusting the fallouts showed that the "const regcache &" passed to the readonly_detached_regcache constructor is cast to non-const in do_cooked_read. I changed the constructor parameter to be non-const. Finally, I renamed the typedef from regcache_cooked_read_ftype to register_read_ftype, since there is nothing that forces us to use it only for regcaches nor cooked registers. gdb/ChangeLog: * regcache.h (regcache_cooked_read_ftype): Rename to... (register_read_ftype): ...this, change type to function_view. (class reg_buffer) <save>: Remove src parameter. (readonly_detached_regcache) <readonly_detached_regcache>: Make parameter non-const in first overload. Remove src parameter in second overload. * regcache.c (do_cooked_read): Remove. (readonly_detached_regcache::readonly_detached_regcache): Make parameter non-const, adjust call to other constructor. (reg_buffer::save): Remove src parameter. * frame.c (do_frame_register_read): Remove. (frame_save_as_regcache): Use lambda function. * ppc-linux-tdep.c (ppu2spu_unwind_register): Change type of src parameter to ppu2spu_data *. (ppu2spu_sniffer): Use lambda function.
Diffstat (limited to 'gdb/frame.c')
-rw-r--r--gdb/frame.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/gdb/frame.c b/gdb/frame.c
index d8309e7..450bf3a 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1024,21 +1024,19 @@ get_frame_func (struct frame_info *this_frame)
return pc;
}
-static enum register_status
-do_frame_register_read (void *src, int regnum, gdb_byte *buf)
-{
- if (!deprecated_frame_register_read ((struct frame_info *) src, regnum, buf))
- return REG_UNAVAILABLE;
- else
- return REG_VALID;
-}
-
std::unique_ptr<readonly_detached_regcache>
frame_save_as_regcache (struct frame_info *this_frame)
{
+ auto cooked_read = [this_frame] (int regnum, gdb_byte *buf)
+ {
+ if (!deprecated_frame_register_read (this_frame, regnum, buf))
+ return REG_UNAVAILABLE;
+ else
+ return REG_VALID;
+ };
+
std::unique_ptr<readonly_detached_regcache> regcache
- (new readonly_detached_regcache (get_frame_arch (this_frame),
- do_frame_register_read, this_frame));
+ (new readonly_detached_regcache (get_frame_arch (this_frame), cooked_read));
return regcache;
}