break; /* fall out and go to normal handling */
}
}
- longest = value_as_long (arg2);
+
+ /* When we cast pointers to integers, we mustn't use
+ POINTER_TO_ADDRESS to find the address the pointer
+ represents, as value_as_long would. GDB should evaluate
+ expressions just as the compiler would --- and the compiler
+ sees a cast as a simple reinterpretation of the pointer's
+ bits. */
+ if (code2 == TYPE_CODE_PTR)
+ longest = extract_unsigned_integer (VALUE_CONTENTS (arg2),
+ TYPE_LENGTH (type2));
+ else
+ longest = value_as_long (arg2);
return value_from_longest (type, convert_to_boolean ?
(LONGEST) (longest ? 1 : 0) : longest);
}
val = allocate_value (type);
- if (GDB_TARGET_IS_D10V
- && TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_TARGET_TYPE (type)
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
- {
- /* pointer to function */
- unsigned long num;
- unsigned short snum;
- snum = read_memory_unsigned_integer (addr, 2);
- num = D10V_MAKE_IADDR (snum);
- store_address (VALUE_CONTENTS_RAW (val), 4, num);
- }
- else if (GDB_TARGET_IS_D10V
- && TYPE_CODE (type) == TYPE_CODE_PTR)
- {
- /* pointer to data */
- unsigned long num;
- unsigned short snum;
- snum = read_memory_unsigned_integer (addr, 2);
- num = D10V_MAKE_DADDR (snum);
- store_address (VALUE_CONTENTS_RAW (val), 4, num);
- }
- else
- read_memory (addr, VALUE_CONTENTS_ALL_RAW (val), TYPE_LENGTH (type));
+ read_memory (addr, VALUE_CONTENTS_ALL_RAW (val), TYPE_LENGTH (type));
VALUE_LVAL (val) = lval_memory;
VALUE_ADDRESS (val) = addr;
int length = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (val));
struct type *type = VALUE_TYPE (val);
- if (GDB_TARGET_IS_D10V
- && TYPE_CODE (type) == TYPE_CODE_PTR
- && TYPE_TARGET_TYPE (type)
- && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC))
- {
- /* pointer to function */
- unsigned long num;
- unsigned short snum;
- snum = read_memory_unsigned_integer (addr, 2);
- num = D10V_MAKE_IADDR (snum);
- store_address (VALUE_CONTENTS_RAW (val), 4, num);
- }
- else if (GDB_TARGET_IS_D10V
- && TYPE_CODE (type) == TYPE_CODE_PTR)
- {
- /* pointer to data */
- unsigned long num;
- unsigned short snum;
- snum = read_memory_unsigned_integer (addr, 2);
- num = D10V_MAKE_DADDR (snum);
- store_address (VALUE_CONTENTS_RAW (val), 4, num);
- }
- else if (length)
+ if (length)
read_memory (addr, VALUE_CONTENTS_ALL_RAW (val), length);
VALUE_LAZY (val) = 0;