diff options
author | Joel Brobecker <brobecker@gnat.com> | 2011-11-10 17:14:41 +0000 |
---|---|---|
committer | Joel Brobecker <brobecker@gnat.com> | 2011-11-10 17:14:41 +0000 |
commit | 22355c9080f27ed22e4aac714e95729970d48c4b (patch) | |
tree | 0b6ccbdda26946a879eb6020a8038ba070bf7857 /gdb/findvar.c | |
parent | e28cade762a84feb67e0864b0e66e380f7cc60d5 (diff) | |
download | binutils-22355c9080f27ed22e4aac714e95729970d48c4b.zip binutils-22355c9080f27ed22e4aac714e95729970d48c4b.tar.gz binutils-22355c9080f27ed22e4aac714e95729970d48c4b.tar.bz2 |
read_frame_register_value and big endian arches
The read_frame_register_value function as it was implemented introduced
a regression on big-endian targets. The problem appears when trying to
get the value of an entity stored inside a register, and when the size
of the entity is smaller than the size of the register. In that case,
we were always reading the first N bytes of the register, which is wrong
for big-endian architectures, where we need to read the last N bytes of
the register.
gdb/ChangeLog:
* findvar.c (read_frame_register_value): Read correct bytes from
register on big-endian architectures.
gdb/testsuite/ChangeLog:
* gdb.ada/small_reg_param: New testcase.
Diffstat (limited to 'gdb/findvar.c')
-rw-r--r-- | gdb/findvar.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/gdb/findvar.c b/gdb/findvar.c index 54e7b4a..426b488 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -641,11 +641,19 @@ read_frame_register_value (struct value *value, struct frame_info *frame) { struct value *regval = get_frame_register_value (frame, regnum); int reg_len = TYPE_LENGTH (value_type (regval)); + int reg_offset = 0; + /* If the register length is larger than the number of bytes + remaining to copy, then only copy the appropriate bytes. */ if (offset + reg_len > len) - reg_len = len - offset; - value_contents_copy (value, offset, regval, value_offset (regval), - reg_len); + { + reg_len = len - offset; + if (gdbarch_byte_order (get_frame_arch (frame)) == BFD_ENDIAN_BIG) + reg_offset = TYPE_LENGTH (value_type (regval)) - reg_len; + } + + value_contents_copy (value, offset, regval, + value_offset (regval) + reg_offset, reg_len); offset += reg_len; regnum++; |