aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/valops.c84
2 files changed, 49 insertions, 41 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 748efe9..e4004fe 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2014-10-03 Luis Machado <lgustavo@codesourcery.com>
+
+ * valops.c (value_assign): Check for bit field assignments
+ before calling architecture-specific register value
+ conversion functions.
+
2014-10-03 Pierre Muller <muller@sourceware.org>
* dbxread.c (read_dbx_symtab): Also ignore N_BNSYM/N_ENSYM.
diff --git a/gdb/valops.c b/gdb/valops.c
index e1decf0..f177907 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1112,52 +1112,54 @@ value_assign (struct value *toval, struct value *fromval)
error (_("Value being assigned to is no longer active."));
gdbarch = get_frame_arch (frame);
- if (gdbarch_convert_register_p (gdbarch, VALUE_REGNUM (toval), type))
+
+ if (value_bitsize (toval))
{
- /* If TOVAL is a special machine register requiring
- conversion of program values to a special raw
- format. */
- gdbarch_value_to_register (gdbarch, frame,
- VALUE_REGNUM (toval), type,
- value_contents (fromval));
+ struct value *parent = value_parent (toval);
+ int offset = value_offset (parent) + value_offset (toval);
+ int changed_len;
+ gdb_byte buffer[sizeof (LONGEST)];
+ int optim, unavail;
+
+ changed_len = (value_bitpos (toval)
+ + value_bitsize (toval)
+ + HOST_CHAR_BIT - 1)
+ / HOST_CHAR_BIT;
+
+ if (changed_len > (int) sizeof (LONGEST))
+ error (_("Can't handle bitfields which "
+ "don't fit in a %d bit word."),
+ (int) sizeof (LONGEST) * HOST_CHAR_BIT);
+
+ if (!get_frame_register_bytes (frame, value_reg, offset,
+ changed_len, buffer,
+ &optim, &unavail))
+ {
+ if (optim)
+ throw_error (OPTIMIZED_OUT_ERROR,
+ _("value has been optimized out"));
+ if (unavail)
+ throw_error (NOT_AVAILABLE_ERROR,
+ _("value is not available"));
+ }
+
+ modify_field (type, buffer, value_as_long (fromval),
+ value_bitpos (toval), value_bitsize (toval));
+
+ put_frame_register_bytes (frame, value_reg, offset,
+ changed_len, buffer);
}
else
{
- if (value_bitsize (toval))
+ if (gdbarch_convert_register_p (gdbarch, VALUE_REGNUM (toval),
+ type))
{
- struct value *parent = value_parent (toval);
- int offset = value_offset (parent) + value_offset (toval);
- int changed_len;
- gdb_byte buffer[sizeof (LONGEST)];
- int optim, unavail;
-
- changed_len = (value_bitpos (toval)
- + value_bitsize (toval)
- + HOST_CHAR_BIT - 1)
- / HOST_CHAR_BIT;
-
- if (changed_len > (int) sizeof (LONGEST))
- error (_("Can't handle bitfields which "
- "don't fit in a %d bit word."),
- (int) sizeof (LONGEST) * HOST_CHAR_BIT);
-
- if (!get_frame_register_bytes (frame, value_reg, offset,
- changed_len, buffer,
- &optim, &unavail))
- {
- if (optim)
- throw_error (OPTIMIZED_OUT_ERROR,
- _("value has been optimized out"));
- if (unavail)
- throw_error (NOT_AVAILABLE_ERROR,
- _("value is not available"));
- }
-
- modify_field (type, buffer, value_as_long (fromval),
- value_bitpos (toval), value_bitsize (toval));
-
- put_frame_register_bytes (frame, value_reg, offset,
- changed_len, buffer);
+ /* If TOVAL is a special machine register requiring
+ conversion of program values to a special raw
+ format. */
+ gdbarch_value_to_register (gdbarch, frame,
+ VALUE_REGNUM (toval), type,
+ value_contents (fromval));
}
else
{