This is the mail archive of the gdb@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: long long considered harmful?


On Tue, Apr 22, 2003 at 01:39:53PM -0400, Kris Warkentin wrote:
> Below is a clipping from our debug.h header which defines the register
> structures for QNX Neutrino.  I've been in conversation with Mark Kettenis
> about our gdb submission and it looks like portability issues in this header
> are one of the few remaining stumbling blocks, at least from his
> perspective.  I guess that conceivably some older systems might not be able
> to deal with a 64 bit int type.  The question I want to ask is, "how do I
> deal with this in a portable way?"
> 
> I don't believe that any of these structures are ever manipulated in any way
> other than to read/write bytes of data into and out of them.  Would it be
> best just to define any long long members as arrays of char?  It doesn't
> seem very pretty but it would certainly do the trick.
> 
> ie. "char u64[8]" instead of "long long u64" is fine but "char gpr_hi[32 *
> 8]" instead of "long long gpr_hi[32]" seems a bit nasty.
> 
> comments?

Several things come to my eye as problems here:

> >>>>>>>>>>>>>debug.h clip<<<<<<<<<<<<<<<<<<<<<
> typedef union
> {
>   unsigned long long u64;
>   double f;
> } mipsfloat;

This is a target entity isn't it?  You've got no business using
"double" for a target float.  Use the gdb type mechanism instead.

> typedef struct mips_cpu_registers
> {
>   unsigned regs[74];
>   unsigned long long regs_alignment;
> } MIPS_CPU_REGISTERS;

What's the purpose of the alignment entry?  I doubt it does what you
want it to.

> #ifdef __BIGREGS__

Eh?

> typedef union
> {
>   unsigned long long u64[2];
>   unsigned u32[4];
>   unsigned char u8[16];
>   float f32[4];
> } ppcvmx;

As above.

I recommend something like 'typedef char qnx_reg64[8];'; then you can
still say 'qnx_reg64 gpr[32]' and get the right result.


-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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