This is the mail archive of the gdb-patches@sources.redhat.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]
Other format: [Raw text]

[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;

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