From: Daniel Jacobowitz Date: Mon, 14 May 2007 17:21:50 +0000 (+0000) Subject: * dwarf2-frame.c (dwarf2_frame_prev_register): Use pack_long X-Git-Tag: binutils-2_18-branchpoint~748 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=14d0675011b16e24eb46c557d59f281384751dcb;p=platform%2Fupstream%2Fbinutils.git * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 55c0da8..7905815 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2007-05-14 Daniel Jacobowitz + * 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. + +2007-05-14 Daniel Jacobowitz + * dwarf2-frame.c (read_encoded_value): Correct typo. Use DW_EH_PE_signed if appropriate. diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index 6af1421..b1c56eb 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -1137,10 +1137,7 @@ dwarf2_frame_prev_register (struct frame_info *next_frame, void **this_cache, *addrp = 0; *realnump = -1; if (valuep) - { - /* Store the value. */ - store_typed_address (valuep, builtin_type_void_data_ptr, cache->cfa); - } + pack_long (valuep, register_type (gdbarch, regnum), cache->cfa); break; case DWARF2_FRAME_REG_CFA_OFFSET: @@ -1149,11 +1146,8 @@ dwarf2_frame_prev_register (struct frame_info *next_frame, void **this_cache, *addrp = 0; *realnump = -1; if (valuep) - { - /* Store the value. */ - store_typed_address (valuep, builtin_type_void_data_ptr, - cache->cfa + cache->reg[regnum].loc.offset); - } + pack_long (valuep, register_type (gdbarch, regnum), + cache->cfa + cache->reg[regnum].loc.offset); break; case DWARF2_FRAME_REG_RA_OFFSET: @@ -1167,7 +1161,7 @@ dwarf2_frame_prev_register (struct frame_info *next_frame, void **this_cache, regnum = DWARF2_REG_TO_REGNUM (cache->retaddr_reg.loc.reg); pc += frame_unwind_register_unsigned (next_frame, regnum); - store_typed_address (valuep, builtin_type_void_func_ptr, pc); + pack_long (valuep, register_type (gdbarch, regnum), pc); } break; diff --git a/gdb/value.c b/gdb/value.c index 4ff088c..d31a5f4 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; } diff --git a/gdb/value.h b/gdb/value.h index 2c93e80..bbf662d 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -271,6 +271,8 @@ extern LONGEST unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno); +extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num); + extern struct value *value_from_longest (struct type *type, LONGEST num); extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr); extern struct value *value_from_double (struct type *type, DOUBLEST num);