summaryrefslogtreecommitdiff
path: root/gdb/value.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2007-05-14 17:21:50 +0000
committerDaniel Jacobowitz <dan@debian.org>2007-05-14 17:21:50 +0000
commitd88cc49f7b2837b265c29961561b2760714ac66d (patch)
tree6f9cded31560cce2a65bdeacf66a577976ff824f /gdb/value.c
parent528a5bf57dc70ee23ae3a93d0f52f4821740a0f0 (diff)
downloadgdb-d88cc49f7b2837b265c29961561b2760714ac66d.tar.gz
* dwarf2-frame.c (dwarf2_frame_prev_register): Use pack_long
instead of store_typed_address. * value.c (pack_long): New. (value_from_longest): Use it. * value.h (pack_long): New prototype.
Diffstat (limited to 'gdb/value.c')
-rw-r--r--gdb/value.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/gdb/value.c b/gdb/value.c
index 4ff088cdfd5..d31a5f45560 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1505,23 +1505,18 @@ modify_field (gdb_byte *addr, LONGEST fieldval, int bitpos, int bitsize)
store_unsigned_integer (addr, sizeof oword, oword);
}
-/* Convert C numbers into newly allocated values */
+/* Pack NUM into BUF using a target format of TYPE. */
-struct value *
-value_from_longest (struct type *type, LONGEST num)
+void
+pack_long (gdb_byte *buf, struct type *type, LONGEST num)
{
- struct value *val = allocate_value (type);
- enum type_code code;
int len;
-retry:
- code = TYPE_CODE (type);
+
+ type = check_typedef (type);
len = TYPE_LENGTH (type);
- switch (code)
+ switch (TYPE_CODE (type))
{
- case TYPE_CODE_TYPEDEF:
- type = check_typedef (type);
- goto retry;
case TYPE_CODE_INT:
case TYPE_CODE_CHAR:
case TYPE_CODE_ENUM:
@@ -1529,17 +1524,30 @@ retry:
case TYPE_CODE_BOOL:
case TYPE_CODE_RANGE:
case TYPE_CODE_MEMBERPTR:
- store_signed_integer (value_contents_raw (val), len, num);
+ store_signed_integer (buf, len, num);
break;
case TYPE_CODE_REF:
case TYPE_CODE_PTR:
- store_typed_address (value_contents_raw (val), type, (CORE_ADDR) num);
+ store_typed_address (buf, type, (CORE_ADDR) num);
break;
default:
- error (_("Unexpected type (%d) encountered for integer constant."), code);
+ error (_("Unexpected type (%d) encountered for integer constant."),
+ TYPE_CODE (type));
}
+}
+
+
+/* Convert C numbers into newly allocated values. */
+
+struct value *
+value_from_longest (struct type *type, LONGEST num)
+{
+ struct value *val = allocate_value (type);
+
+ pack_long (value_contents_raw (val), type, num);
+
return val;
}