This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] Fix (top-gdb) print phex_nz(0,0)
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 15 Nov 2001 13:28:00 -0500
- Subject: [patch] Fix (top-gdb) print phex_nz(0,0)
Hello,
The attatched patch fixes a bug in the phex_nz() function so that it
correctly handles a format length of zero.
Hmm, I wonder, better check phex(), ... Oh, ugger, ...
I'll also commit an identical patch for phex() ...
Andrew
2001-11-15 Andrew Cagney <ac131313@redhat.com>
* utils.c (phex_nz): For default case, set str to phex_nz return
value.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.49
diff -p -r1.49 utils.c
*** utils.c 2001/11/02 21:46:52 1.49
--- utils.c 2001/11/15 18:21:30
*************** phex (ULONGEST l, int sizeof_l)
*** 2442,2453 ****
char *
phex_nz (ULONGEST l, int sizeof_l)
{
! char *str = get_cell ();
switch (sizeof_l)
{
case 8:
{
unsigned long high = (unsigned long) (l >> thirty_two);
if (high == 0)
sprintf (str, "%lx", (unsigned long) (l & 0xffffffff));
else
--- 2442,2454 ----
char *
phex_nz (ULONGEST l, int sizeof_l)
{
! char *str;
switch (sizeof_l)
{
case 8:
{
unsigned long high = (unsigned long) (l >> thirty_two);
+ str = get_cell ();
if (high == 0)
sprintf (str, "%lx", (unsigned long) (l & 0xffffffff));
else
*************** phex_nz (ULONGEST l, int sizeof_l)
*** 2456,2468 ****
break;
}
case 4:
sprintf (str, "%lx", (unsigned long) l);
break;
case 2:
sprintf (str, "%x", (unsigned short) (l & 0xffff));
break;
default:
! phex_nz (l, sizeof (l));
break;
}
return str;
--- 2457,2471 ----
break;
}
case 4:
+ str = get_cell ();
sprintf (str, "%lx", (unsigned long) l);
break;
case 2:
+ str = get_cell ();
sprintf (str, "%x", (unsigned short) (l & 0xffff));
break;
default:
! str = phex_nz (l, sizeof (l));
break;
}
return str;