[Crash-utility] [PATCH] sial: Fix processing of bitfields on bigendian systems

Michael Holzheu holzheu at linux.vnet.ibm.com
Thu Sep 17 08:29:25 UTC 2009


Hi Dave,

Here comes the patch!

For the future: Do you always want the patches as attachments and not
inline?

Michael

Am Mittwoch, den 16.09.2009, 16:55 -0400 schrieb Dave Anderson:
> ----- "Luc Chouinard" <Luc.Chouinard at trueposition.com> wrote:
> 
> > ACK - and thanks!
> 
> Can you attach an actual patch that I can download and apply?
> 
> Thanks,
>   Dave
> 
> > 
> > > -----Original Message-----
> > > From: crash-utility-bounces at redhat.com [mailto:crash-utility-
> > > bounces at redhat.com] On Behalf Of Michael Holzheu
> > > Sent: Wednesday, September 16, 2009 1:45 PM
> > > To: Chouinard, Luc
> > > Cc: wein at de.ibm.com; crash
> > > Subject: [Crash-utility] [PATCH] sial: Fix processing of bitfields
> > on
> > > bigendian systems
> > > 
> > > Hi Luc,
> > > 
> > > The processing of bit fields on big endian systems in sial is
> > currently
> > > broken, because the bits are not copied to the correct position and
> > are
> > > not shifted the right way.
> > > 
> > > To fix this, the following patch does the processing on big endian
> > > systems as follows:
> > > 1. sial_exemem(): Copy complete bit field to the "end" (right) of
> > the
> > >    long long variable.
> > > 2. get_bit_value(): Shift the bits of the bit field member right to
> > >    the "end" of the long long variable. This results in the value
> > of
> > >    the requested bitfield member.
> > > 
> > > Michael
> > > ---
> > >  extensions/libsial/sial_member.c |    7 +++++--
> > >  extensions/libsial/sial_type.c   |    6 +++++-
> > >  2 files changed, 10 insertions(+), 3 deletions(-)
> > > 
> > > Index: crash-4.0.9/extensions/libsial/sial_member.c
> > > ===================================================================
> > > --- crash-4.0.9.orig/extensions/libsial/sial_member.c
> > > +++ crash-4.0.9/extensions/libsial/sial_member.c
> > > @@ -236,10 +236,13 @@ srcpos_t p;
> > >  		}
> > >  		/* bit field gymnastic */
> > >  		else if(stm->m.nbits) {
> > > -
> > >  			ull value=0;
> > > +			void *target = &value;
> > > +
> > > +			if (__BYTE_ORDER != __LITTLE_ENDIAN)
> > > +				target = target + (sizeof(value) -
> > stm->m.size);
> > > 
> > > -			API_GETMEM(m->mem+stm->m.offset, &value,
> > stm->m.size);
> > > +			API_GETMEM(m->mem+stm->m.offset, target,
> > stm->m.size);
> > >  			get_bit_value(value, stm->m.nbits, stm->m.fbit,
> > stm-
> > > >m.size, v);
> > >  			/* no mempos for bit fields ... */
> > > 
> > > Index: crash-4.0.9/extensions/libsial/sial_type.c
> > > ===================================================================
> > > --- crash-4.0.9.orig/extensions/libsial/sial_type.c
> > > +++ crash-4.0.9/extensions/libsial/sial_type.c
> > > @@ -287,7 +287,11 @@ get_bit_value(ull val, int nbits, int bo
> > >          else {
> > >                  mask = ((1 << nbits) - 1);
> > >          }
> > > -        val = val >> boff;
> > > +
> > > +	if (__BYTE_ORDER == __LITTLE_ENDIAN)
> > > +		val = val >> boff;
> > > +	else
> > > +		val = val >> (vnbits - boff - nbits);
> > >  	val &= mask;
> > > 
> > >  	if(issigned(v)) {
> > > 
> > > 
> > > --
> > > Crash-utility mailing list
> > > Crash-utility at redhat.com
> > > https://www.redhat.com/mailman/listinfo/crash-utility
> > 
> > 
> > 
> > --
> > Crash-utility mailing list
> > Crash-utility at redhat.com
> > https://www.redhat.com/mailman/listinfo/crash-utility
> 
> --
> Crash-utility mailing list
> Crash-utility at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crash-4.0.9-sial_bit_field.patch
Type: text/x-vhdl
Size: 1370 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/crash-utility/attachments/20090917/72a13a04/attachment.bin>


More information about the Crash-utility mailing list