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]

Fix big-endian host printing bug in ARM simulator


Hi Guys,

  I am checking in the patch below to fix a bug in the ARM simulator.
  On a big-endian host the emulation of the Write0 SWI would fail
  because the word read from simulated memory would be cast into a
  (char *) pointer, resulting in the actual byte being in the in the
  upper 8 bits not the bottom 8 bits, and so a nul character would be
  printed instead.

Cheers
        Nick

2003-03-02  Nick Clifton  <nickc at redhat dot com>

	* armos.c (SWIWrite0): Catch big-endian bug when printing
	characters.

Index: sim/arm/armos.c
===================================================================
RCS file: /cvs/src/src/sim/arm/armos.c,v
retrieving revision 1.18
diff -c -3 -p -w -r1.18 armos.c
*** sim/arm/armos.c	16 Aug 2002 09:38:09 -0000	1.18
--- sim/arm/armos.c	2 Mar 2003 10:24:15 -0000
*************** SWIWrite0 (ARMul_State * state, ARMword 
*** 274,280 ****
    struct OSblock *OSptr = (struct OSblock *) state->OSptr;
  
    while ((temp = ARMul_SafeReadByte (state, addr++)) != 0)
!     (void) sim_callback->write_stdout (sim_callback, (char *) &temp, 1);
  
    OSptr->ErrorNo = sim_callback->get_errno (sim_callback);
  }
--- 274,286 ----
    struct OSblock *OSptr = (struct OSblock *) state->OSptr;
  
    while ((temp = ARMul_SafeReadByte (state, addr++)) != 0)
!     {
!       char buffer = temp;
!       /* Note - we cannot just cast 'temp' to a (char *) here,
! 	 since on a big-endian host the byte value will end
! 	 up in the wrong place and a nul character will be printed.  */
!       (void) sim_callback->write_stdout (sim_callback, & buffer, 1);
!     }
  
    OSptr->ErrorNo = sim_callback->get_errno (sim_callback);
  }


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