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]

Re: [RFA:] sim-config.c: When having a bfd, don't just check bfd_little_endian


> Date: Wed, 10 Nov 2004 10:11:56 -0500
> From: Andrew Cagney <cagney@gnu.org>

> > Index: sim-config.c
> > ===================================================================
> > RCS file: /cvs/src/src/sim/common/sim-config.c,v
> > retrieving revision 1.2
> > diff -c -p -r1.2 sim-config.c
> > *** sim-config.c	23 Nov 2002 01:12:05 -0000	1.2
> > --- sim-config.c	9 Nov 2004 19:41:07 -0000
> > *************** sim_config (SIM_DESC sd)
> > *** 146,152 ****
> >     SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
> >   
> >     /* extract all relevant information */
> > !   if (STATE_PROG_BFD (sd) == NULL)
> >       prefered_target_byte_order = 0;
> >     else
> >       prefered_target_byte_order = (bfd_little_endian(STATE_PROG_BFD (sd))
> > --- 146,156 ----
> >     SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
> >   
> >     /* extract all relevant information */
> > !   if (STATE_PROG_BFD (sd) == NULL
> > !       /* If we have a binary input file (presumably with specified
> > ! 	 "--architecture"), it'll have no endianness.  */
> > !       || (!bfd_little_endian (STATE_PROG_BFD (sd))
> > ! 	  && !bfd_big_endian (STATE_PROG_BFD (sd))))
> 
> Yes, although this three way case better expressed using a switch. 

Not one I see, not without looking at bfd private data
abfd->xvec->byteorder or introducing a multi-valued accessor for
the bfd endian data or expressing it awkwardly along the lines of:
 switch (2 * (bfd_little_endian (STATE_PROG_BFD (sd) != false))
         + (bfd_big_endian (STATE_PROG_BFD (sd) != false)))
   ...

> Change it before committing if you care.

Since you made it optional I committed as-is; I didn't see an
obvious and simple way to better express it as a switch.

brgds, H-P


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