This is the mail archive of the gdb-patches@sourceware.cygnus.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]

Re: Severe regression in corefile.exp with Solaris 2.7 sparc + hack


On Mar 7,  2:17pm, Jim Kingdon wrote:

> > Due to the BFD change, a CORE_ADDR is now an unsigned long long with 64 Bits.
> > When casting 32 bit pointers to a CORE_ADDR in solib.c, the sign bit of the
> > pointer gets extended
> 
> Weird.  GCC seems to do that too (albeit with a warning "cast from
> pointer to integer of different size").
> 
> The best solution I could think of was to change "(CORE_ADDR)lm"
> (where lm is a void*) to "(CORE_ADDR)(size_t)lm".  At least for me
> that seems to work (on a small test case).  Hardly elegant, but better
> than manually anding with 0xffffffff I guess.

Of the two choices, I prefer manually anding with 0xffffffff.  The
cast that you suggest will only yield the desired results when
sizeof(void *) == sizeof(size_t).

When sizeof(void *) < sizeof(size_t), you'll once again end up with an
undesired sign extension.  And when sizeof(void *) > sizeof(size_t),
you'll end up losing some significant address bits.

Peter's solution (at least) identifies a class of targets for which
sign extension is a problem and correctly masks the address for those
targets.

I think there must be a better solution than the one that Peter
proposes.  However, I don't know what it is either.

Kevin

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