X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fvalue.c;h=35a7a5cdce3d894f0b2d55653bbfe111c993b46f;hb=34877895ca38f74ae31bd65a6916560020d9d62b;hp=71030efed072d69a50786812b35d573a0628e35e;hpb=b02f78f9285728ce2d05ce01e7b14880f70cd6e6;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/value.c b/gdb/value.c index 71030efed0..35a7a5cdce 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -41,8 +41,9 @@ #include "user-regs.h" #include #include "completer.h" -#include "common/selftest.h" -#include "common/array-view.h" +#include "gdbsupport/selftest.h" +#include "gdbsupport/array-view.h" +#include "cli/cli-style.h" /* Definition of a user function. */ struct internal_function @@ -1977,7 +1978,7 @@ init_if_undefined_command (const char* args, int from_tty) intvar = expr->elts[2].internalvar; /* Only evaluate the expression if the lvalue is void. - This may still fail if the expresssion is invalid. */ + This may still fail if the expression is invalid. */ if (intvar->kind == INTERNALVAR_VOID) evaluate_expression (expr.get ()); } @@ -2025,7 +2026,7 @@ create_internalvar (const char *name) { struct internalvar *var = XNEW (struct internalvar); - var->name = concat (name, (char *)NULL); + var->name = xstrdup (name); var->kind = INTERNALVAR_VOID; var->next = internalvars; internalvars = var; @@ -2152,7 +2153,7 @@ value_of_internalvar (struct gdbarch *gdbarch, struct internalvar *var) on this value go back to affect the original internal variable. Do not do this for INTERNALVAR_MAKE_VALUE variables, as those have - no underlying modifyable state in the internal variable. + no underlying modifiable state in the internal variable. Likewise, if the variable's value is a computed lvalue, we want references to it to produce another computed lvalue, where @@ -2539,7 +2540,8 @@ show_convenience (const char *ignore, int from_tty) } catch (const gdb_exception_error &ex) { - fprintf_filtered (gdb_stdout, _(""), ex.what ()); + fprintf_styled (gdb_stdout, metadata_style.style (), + _(""), ex.what ()); } printf_filtered (("\n")); @@ -2735,7 +2737,7 @@ value_as_address (struct value *val) LONGEST unpack_long (struct type *type, const gdb_byte *valaddr) { - enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); + enum bfd_endian byte_order = type_byte_order (type); enum type_code code = TYPE_CODE (type); int len = TYPE_LENGTH (type); int nosign = TYPE_UNSIGNED (type); @@ -2751,10 +2753,16 @@ unpack_long (struct type *type, const gdb_byte *valaddr) case TYPE_CODE_CHAR: case TYPE_CODE_RANGE: case TYPE_CODE_MEMBERPTR: - if (nosign) - return extract_unsigned_integer (valaddr, len, byte_order); - else - return extract_signed_integer (valaddr, len, byte_order); + { + LONGEST result; + if (nosign) + result = extract_unsigned_integer (valaddr, len, byte_order); + else + result = extract_signed_integer (valaddr, len, byte_order); + if (code == TYPE_CODE_RANGE) + result += TYPE_RANGE_DATA (type)->bias; + return result; + } case TYPE_CODE_FLT: case TYPE_CODE_DECFLOAT: @@ -3092,7 +3100,7 @@ static LONGEST unpack_bits_as_long (struct type *field_type, const gdb_byte *valaddr, LONGEST bitpos, LONGEST bitsize) { - enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (field_type)); + enum bfd_endian byte_order = type_byte_order (field_type); ULONGEST val; ULONGEST valmask; int lsbcount; @@ -3201,7 +3209,7 @@ unpack_value_bitfield (struct value *dest_val, int dst_bit_offset; struct type *field_type = value_type (dest_val); - byte_order = gdbarch_byte_order (get_type_arch (field_type)); + byte_order = type_byte_order (field_type); /* First, unpack and sign extend the bitfield as if it was wholly valid. Optimized out/unavailable bits are read as zero, but @@ -3261,7 +3269,7 @@ void modify_field (struct type *type, gdb_byte *addr, LONGEST fieldval, LONGEST bitpos, LONGEST bitsize) { - enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); + enum bfd_endian byte_order = type_byte_order (type); ULONGEST oword; ULONGEST mask = (ULONGEST) -1 >> (8 * sizeof (ULONGEST) - bitsize); LONGEST bytesize; @@ -3307,7 +3315,7 @@ modify_field (struct type *type, gdb_byte *addr, void pack_long (gdb_byte *buf, struct type *type, LONGEST num) { - enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); + enum bfd_endian byte_order = type_byte_order (type); LONGEST len; type = check_typedef (type); @@ -3315,12 +3323,14 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num) switch (TYPE_CODE (type)) { + case TYPE_CODE_RANGE: + num -= TYPE_RANGE_DATA (type)->bias; + /* Fall through. */ case TYPE_CODE_INT: case TYPE_CODE_CHAR: case TYPE_CODE_ENUM: case TYPE_CODE_FLAGS: case TYPE_CODE_BOOL: - case TYPE_CODE_RANGE: case TYPE_CODE_MEMBERPTR: store_signed_integer (buf, len, byte_order, num); break; @@ -3353,7 +3363,7 @@ pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num) type = check_typedef (type); len = TYPE_LENGTH (type); - byte_order = gdbarch_byte_order (get_type_arch (type)); + byte_order = type_byte_order (type); switch (TYPE_CODE (type)) {