This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Patch : gdbserver get_image_name on CE
On Sat, 2009-07-04 at 19:15 +0100, Pedro Alves wrote:
> On Wednesday 01 July 2009 21:13:05, Pedro Alves wrote:
> > I'll see about cleaning up the bits of your patch that are OK and
> > apply them (you still aren't following the code conventions). Then
> > we can focus on just this bit.
>
> I've checked in the patch below, after giving it a testsuite
> run against a local Cygwin gdbserver without regressions.
I tried to debug gdbserver with gdbserver but the child didn't come to
life, don't know why, so I'm falling back to printf.
Changed the source (of get_image_name) in this way, output below.
#if 1
/* Add debug code here */
/* Find the length of the string */
int r;
while (1) {
r = ReadProcessMemory (h, address_ptr + len++ * size, &b,
size, &done);
if (r == 0) {
DWORD e = GetLastError();
printf("ReadProcessMemory (in loop) r %d done %d -> %c %c,
error %d\n",
r, done, b[0], b[1], e);
} else {
printf("ReadProcessMemory (in loop) r %d done %d -> %c %c
\n",
r, done, b[0], b[1]);
}
if (len > 30)
break;
if ((b[0] != 0 || b[size - 1] != 0) && done == size)
continue;
}
printf("ReadProcessMemory (after loop) r %d done %d -> %c\n",
r, done, b);
if (!unicode)
ReadProcessMemory (h, address_ptr, buf, len, &done);
else
{
WCHAR *unicode_address = (WCHAR *) alloca (len * sizeof (WCHAR));
ReadProcessMemory (h, address_ptr, unicode_address, len * sizeof
(WCHAR),
&done);
WideCharToMultiByte (CP_ACP, 0, unicode_address, len, buf, len, 0,
0);
}
#else
/* Original version, do not touch */
/* Find the length of the string */
Output of this debugging session :
\network\x86>
gdbserver :9999 /network/x86/hello2.exe
Process /network/x86/hello2.exe created; pid = 92733450
Yow(libstdc++-6.dll)
ReadProcessMemory (in loop) r 1 done 2 -> l
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (in loop) r 0 done 2 -> l , error 87
ReadProcessMemory (after loop) r 0 done 2 -> ï
Listening on port 9999
Remote debugging from host 172.17.1.10
Detaching from process 92733450
\network\x86>
Error 87 is ERROR_INVALID_PARAMETER. The MSDN page doesn't appear to
describe this.
It looks like ReadProcessMemory refuses to read from an address beyond
the pointer, but it does work from the pointer itself.
I've changed my code such that it loops, and tries to read a bigger
chunk of memory at each iteration.
I'm not bothering you with that code or its debug output right now.
In that way, the code appears to work, and it complies with the
documentation saying not to read more than required.
Shall I submit a new patch based on this ?
Danny
--
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info