This is the mail archive of the gdb-patches@sourceware.org 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: gdb code review, pointer madness


On 1/23/06, NZG <ngustavson@emacinc.com> wrote:
> Specifically this loop doesn't seem to be executing correctly
>
>  for (p = startaddr; p < endaddr; ++p)
>         retval = (retval << 8) | *p;
>
> In the function call I'm watching,
> endaddr = startaddr+4,
> yet, when I step through the function the loop executes 8 times and overshoots
> the array.
>
> I don't see anything wrong with the code.
> Can anyone else see anything weird in the pointer math below?

I don't think there's anything wrong with the C code.  That's a
completely fundamental function in GDB, used everywhere, all the time.
 And it's hard for me to believe that both endiannesses aren't being
exercised.  If it were broken, we surely would have found out by now.

If the function is behaving as you say, then I'd say your compiler has
miscompiled GDB.  Why don't you look through the assembly code for the
function, and see if it's right?


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