This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] mips-tdep.c: Fix bug in evaluating signed address


Hi,

the below patch fixes the mips_integer_to_address function.  What
happens is this:

If the incoming type is an *unsigned* value, then unpack_long takes the
(un)signedness into account.  This results in `val' not being signed
extended, as the mips_integer_to_address function was originally
designed for.

So, to enforce correct signedness of the resulting address, I changed
the unpack_long call to extract_signed_integer.  This way, val is always
sign extended and the mips address is correctly signed.


Ok to apply?


Thanks,
Corinna


	* mips-tdep.c (mips_integer_to_address): Call extract_signed_integer
	instead of unpack_long to maintain signedness.


Index: gdb/mips-tdep.c
===================================================================
RCS file: /cvs/cvsfiles/gnupro/gdb/mips-tdep.c,v
retrieving revision 1.24
diff -u -p -r1.24 mips-tdep.c
--- gdb/mips-tdep.c	15 Jun 2006 08:57:17 -0000	1.24
+++ gdb/mips-tdep.c	16 Jun 2006 16:15:48 -0000
@@ -4749,7 +4749,7 @@ mips_integer_to_address (struct gdbarch 
 			 struct type *type, const gdb_byte *buf)
 {
   gdb_byte *tmp = alloca (TYPE_LENGTH (builtin_type_void_data_ptr));
-  LONGEST val = unpack_long (type, buf);
+  LONGEST val = extract_signed_integer (buf, TYPE_LENGTH (type));
   store_signed_integer (tmp, TYPE_LENGTH (builtin_type_void_data_ptr), val);
   return extract_signed_integer (tmp,
 				 TYPE_LENGTH (builtin_type_void_data_ptr));

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]