This is the mail archive of the gdb-patches@sourceware.cygnus.com 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]

RFD: printcmd.c: Changing output width of p/a and x/a


Due to a recent BFD change, a CORE_ADDR is now an unsigned long long with
64 Bits on Solaris 2.7 sparc and causes a testsuite regression in
long_long.exp:

(gdb) x/a &oct
0xffbef848:     0xffffffffa72ee539
(gdb) FAIL: gdb.base/long_long.exp: x/a &oct

printcmd.c:print_scalar_formatted calls print_address with the result
from unpack_pointer. As the `examine type' passed to unpack_pointer is signed,
we get sign extension to 64 bits when printing the address value.

The solution is simple, just truncate the core address like we truncate values
around line 404 in printcmd.c

But how much truncation should be done to meet user expectations ?

I have a feeling that we should truncate to TARGET_PTR_BIT (which would
get rid of the testsuite regression without causing new ones).

On the other hand this would be inconsistent with the truncation of values,
which is done with the type length of the value.

Would you expect 

(gdb) p/a (char)-1

to yield

$1 = 0xff		(truncation to length of value, will cause testsuite
			 regressions, which have to be adressed by changing
			 the expect patterns)
or

$1 = 0xffffffff		(truncation to size of pointer)


Here is a patch to truncate to the size of a pointer, please let me know
if you want this to be changed to truncate to the length of the value.

2000-03-07  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>

	* printcmd.c (print_scalar_formatted):  Truncate addresses to the
	size of a target pointer before passing them to print_address.

*** ./printcmd.c.orig	Sun Mar  5 17:35:36 2000
--- ./printcmd.c	Tue Mar  7 19:59:46 2000
***************
*** 443,449 ****
        break;
  
      case 'a':
!       print_address (unpack_pointer (type, valaddr), stream);
        break;
  
      case 'c':
--- 443,455 ----
        break;
  
      case 'a':
!       {
! 	/* Truncate address to the size of a target pointer.  */
! 	CORE_ADDR addr = unpack_pointer (type, valaddr);
! 	if (TARGET_PTR_BIT < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
! 	  addr &= ((CORE_ADDR) 1 << TARGET_PTR_BIT) - 1;
! 	print_address (addr, stream);
!       }
        break;
  
      case 'c':

-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de

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