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: Question: Checking register value in buffer


> On Thu, May 19, 2005 at 12:04:44PM +1000, Joel Brobecker wrote:
> >         LONGEST rav = extract_signed_integer (buf, 8)
> > 
> > and then do the test using integer arithmetics. But then I'm not guarantied
> > that LONGEST is at least 64bit long, am I.
> 
> It had better be, or the rest of alpha_next_pc is broken too.
> 
> Since it isn't, or isn't reported to be, you might as well 
> assume it is large enough.

Ah yes, of course.

In terms of computing the mask, I'm thinking of using something
like this:

  sign_mask = 1 << (sizeof (rav) * TARGET_CHAR_BIT - 1);
  zero_mask = sign_mask ^ -1;

Are there better ways of computing these masks?

> > How are these sort of checks usually done in GDB?
> 
> In gcc-land we have a "need_64bit_hwint" bit in config.gcc, and it
> is set for targets that require the equivalent of LONGEST be at 
> least 64 bits, or we error out of configure.
> 
> Dunno what's done in gdb.

I just noticed in extract_signed_integer() that we actually do a size
check before doing the extraction, so we would get an error if LONGEST
was not large enough.

Thanks,
-- 
Joel


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