RFA: neaten up sim memory dumping

Jim Blandy jimb@redhat.com
Mon Jun 28 23:58:00 GMT 2004


Of course, there's no end to the improvements one could make here.
This, at least, improved things enough that I could be sure what was
really going on.

2004-06-28  Jim Blandy  <jimb@redhat.com>

	* remote-sim.c (dump_mem): Include leading zeros in dumped values,
	so the user can tell whether we're dumping words or bytes.  When
	we dump words, interpret them using the target byte order, not
	host byte order.

Index: gdb/remote-sim.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sim.c,v
retrieving revision 1.39
diff -c -p -r1.39 remote-sim.c
*** gdb/remote-sim.c	25 Jun 2004 19:46:08 -0000	1.39
--- gdb/remote-sim.c	28 Jun 2004 23:56:20 -0000
*************** dump_mem (char *buf, int len)
*** 129,139 ****
      {
        if (len == 8 || len == 4)
  	{
! 	  long l[2];
! 	  memcpy (l, buf, len);
! 	  printf_filtered ("\t0x%lx", l[0]);
  	  if (len == 8)
! 	    printf_filtered (" 0x%lx", l[1]);
  	  printf_filtered ("\n");
  	}
        else
--- 129,140 ----
      {
        if (len == 8 || len == 4)
  	{
! 	  printf_filtered ("\t0x%08lx",
!                            (unsigned long) extract_unsigned_integer (buf, 4));
  	  if (len == 8)
! 	    printf_filtered (" 0x%08lx", 
!                              ((unsigned long)
!                               extract_unsigned_integer (buf + 4, 4)));
  	  printf_filtered ("\n");
  	}
        else
*************** dump_mem (char *buf, int len)
*** 141,147 ****
  	  int i;
  	  printf_filtered ("\t");
  	  for (i = 0; i < len; i++)
! 	    printf_filtered ("0x%x ", buf[i]);
  	  printf_filtered ("\n");
  	}
      }
--- 142,148 ----
  	  int i;
  	  printf_filtered ("\t");
  	  for (i = 0; i < len; i++)
! 	    printf_filtered ("0x%02x ", buf[i]);
  	  printf_filtered ("\n");
  	}
      }



More information about the Gdb-patches mailing list