diff options
author | Jim Blandy <jimb@codesourcery.com> | 2001-07-10 21:15:28 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2001-07-10 21:15:28 +0000 |
commit | 2bf1f4a12e3577f7483aaa185c6917d8ba94a9bc (patch) | |
tree | a4631ff80eea9522dbd495b60e7282e428f41a7a | |
parent | ba3a85231b0063f457e88e57edd12f244b6ceabc (diff) | |
download | gdb-2bf1f4a12e3577f7483aaa185c6917d8ba94a9bc.zip gdb-2bf1f4a12e3577f7483aaa185c6917d8ba94a9bc.tar.gz gdb-2bf1f4a12e3577f7483aaa185c6917d8ba94a9bc.tar.bz2 |
* valops.c (value_cast): When casting a pointer to an integer,
don't convert it to an address.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/valops.c | 13 |
2 files changed, 17 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 81098a8..f439aed 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2001-07-10 Jim Blandy <jimb@redhat.com> + + * valops.c (value_cast): When casting a pointer to an integer, + don't convert it to an address. + 2001-07-10 Andrew Cagney <ac131313@redhat.com> * remote-utils.h (struct serial): Declare as opaque. Remove diff --git a/gdb/valops.c b/gdb/valops.c index 7cc025d..dc987c4 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -281,7 +281,18 @@ value_cast (struct type *type, register value_ptr arg2) 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); } |