This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: gdb code review, pointer madness
- From: Jim Blandy <jimb at red-bean dot com>
- To: NZG <ngustavson at emacinc dot com>
- Cc: gdb-patches at sourceware dot org, uClinux development list <uclinux-dev at uclinux dot org>
- Date: Mon, 23 Jan 2006 12:51:49 -0800
- Subject: Re: gdb code review, pointer madness
- References: <200601231438.26040.ngustavson@emacinc.com>
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?