mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-10-18 21:34:13 +08:00
* valops.c (value_cast): If casting a scalar to a pointer, do not
issue a message about truncation unless it exceeds the length of an address, not the length of a pointer. This is because what the user gives us is an address, not a pointer, and we will ultimately convert it (via ADDRESS_TO_POINTER) to a pointer, not truncate it to a pointer. This allows things like "print *(int *)0x01000234" to work without generating a misleading message on a target having two byte pointers and four byte addresses.
This commit is contained in:
@ -1,3 +1,14 @@
|
|||||||
|
Tue Feb 6 11:58:57 2001 David Taylor <taylor@redhat.com>
|
||||||
|
|
||||||
|
* valops.c (value_cast): If casting a scalar to a pointer, do not
|
||||||
|
issue a message about truncation unless it exceeds the length of
|
||||||
|
an address, not the length of a pointer. This is because what the
|
||||||
|
user gives us is an address, not a pointer, and we will ultimately
|
||||||
|
convert it (via ADDRESS_TO_POINTER) to a pointer, not truncate it
|
||||||
|
to a pointer. This allows things like "print *(int *)0x01000234"
|
||||||
|
to work without generating a misleading message on a target having
|
||||||
|
two byte pointers and four byte addresses.
|
||||||
|
|
||||||
2001-02-05 Christopher Faylor <cgf@cygnus.com>
|
2001-02-05 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* win32-nat.c: Change PTR to void * throughout.
|
* win32-nat.c: Change PTR to void * throughout.
|
||||||
|
19
gdb/valops.c
19
gdb/valops.c
@ -287,12 +287,23 @@ value_cast (struct type *type, register value_ptr arg2)
|
|||||||
code2 == TYPE_CODE_ENUM ||
|
code2 == TYPE_CODE_ENUM ||
|
||||||
code2 == TYPE_CODE_RANGE))
|
code2 == TYPE_CODE_RANGE))
|
||||||
{
|
{
|
||||||
int ptr_bit = HOST_CHAR_BIT * TYPE_LENGTH (type);
|
/* TYPE_LENGTH (type) is the length of a pointer, but we really
|
||||||
|
want the length of an address! -- we are really dealing with
|
||||||
|
addresses (i.e., gdb representations) not pointers (i.e.,
|
||||||
|
target representations) here.
|
||||||
|
|
||||||
|
This allows things like "print *(int *)0x01000234" to work
|
||||||
|
without printing a misleading message -- which would
|
||||||
|
otherwise occur when dealing with a target having two byte
|
||||||
|
pointers and four byte addresses. */
|
||||||
|
|
||||||
|
int addr_bit = TARGET_ADDR_BIT;
|
||||||
|
|
||||||
LONGEST longest = value_as_long (arg2);
|
LONGEST longest = value_as_long (arg2);
|
||||||
if (ptr_bit < sizeof (LONGEST) * HOST_CHAR_BIT)
|
if (addr_bit < sizeof (LONGEST) * HOST_CHAR_BIT)
|
||||||
{
|
{
|
||||||
if (longest >= ((LONGEST) 1 << ptr_bit)
|
if (longest >= ((LONGEST) 1 << addr_bit)
|
||||||
|| longest <= -((LONGEST) 1 << ptr_bit))
|
|| longest <= -((LONGEST) 1 << addr_bit))
|
||||||
warning ("value truncated");
|
warning ("value truncated");
|
||||||
}
|
}
|
||||||
return value_from_longest (type, longest);
|
return value_from_longest (type, longest);
|
||||||
|
Reference in New Issue
Block a user