From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22572 invoked by alias); 19 Apr 2010 23:46:19 -0000 Received: (qmail 22549 invoked by uid 22791); 19 Apr 2010 23:46:16 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=BAYES_00,MSGID_MULTIPLE_AT,TW_EG,TW_GW X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.156) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Apr 2010 23:46:10 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o3JNk3pO089117 ; Tue, 20 Apr 2010 01:46:03 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms1.u-strasbg.fr [IPv6:2001:660:2402:d::10]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id o3JNk3gt052003 ; Tue, 20 Apr 2010 01:46:03 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o3JNk2DY044409 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) ; Tue, 20 Apr 2010 01:46:02 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Pedro Alves'" Cc: References: <000f01cae013$79556340$6c0029c0$@muller@ics-cnrs.unistra.fr> <201004200014.30032.pedro@codesourcery.com> In-Reply-To: <201004200014.30032.pedro@codesourcery.com> Subject: RE: [RFA] [1/4] Mingw64 gdbserver support Date: Mon, 19 Apr 2010 23:46:00 -0000 Message-ID: <002101cae01a$82284850$8678d8f0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00592.txt.bz2 > -----Message d'origine----- > De=A0: Pedro Alves [mailto:pedro@codesourcery.com] > Envoy=E9=A0: Tuesday, April 20, 2010 1:14 AM > =C0=A0: Pierre Muller > Cc=A0: gdb-patches@sourceware.org > Objet=A0: Re: [RFA] [1/4] Mingw64 gdbserver support >=20 > On Monday 19 April 2010 23:55:57, Pierre Muller wrote: > > It would be nice if someone could check that this > > patch works for mingwce targets, I cannot do this myself. >=20 > Don't worry about it. I'll do that after the patch is applied, if > noone beats me to it. It may take me a while, but I'll surely test > on CE before the next release. OK, great! > > gdbserver ChangeLog entry: > > > > 2010-04-19 Pierre Muller > > > > * win32-low.c: Adapt to support also 64-bit architecture. > > (child_xfer_memory): Use uintptr_t type for local variable > `addr'. > > (get_image_name): Use SIZE_T type for local variable `done'. > > (psapi_get_dll_name): Use uintptr_t type for parameter > > `BaseAddress'. > > (toolhelp_get_dll_name): Idem. > > (handle_load_dll): Use uintptr_t type for local variable > > `load_addr'. > > (handle_unload_dll): Use unitptr_t typecast to avoid warning. >=20 > Typo: unitptr_t. Fixed.=20 > > (handle_exception): Use phex_nz to avoid warning. > > (win32_wait): Remove unused local variable `process'. > > > > Index: gdbserver/win32-low.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v > > retrieving revision 1.46 > > diff -u -p -r1.46 win32-low.c > > --- gdbserver/win32-low.c 16 Apr 2010 07:49:37 -0000 1.46 > > +++ gdbserver/win32-low.c 17 Apr 2010 22:08:36 -0000 > > @@ -280,7 +280,7 @@ child_xfer_memory (CORE_ADDR memaddr, ch > > int write, struct target_ops *target) > > { > > SIZE_T done; > > - long addr =3D (long) memaddr; > > + uintptr_t addr =3D (uintptr_t) memaddr; > > > > if (write) > > { > > @@ -941,7 +941,7 @@ get_image_name (HANDLE h, void *address, > > char *address_ptr; > > int len =3D 0; > > char b[2]; > > - DWORD done; > > + SIZE_T done; > > > > /* Attempt to read the name of the dll that was detected. > > This is documented to work only when actively debugging > > @@ -1019,7 +1019,7 @@ load_psapi (void) > > } > > > > static int > > -psapi_get_dll_name (DWORD BaseAddress, char *dll_name_ret) > > +psapi_get_dll_name (uintptr_t BaseAddress, char *dll_name_ret) >=20 > Make this one above, >=20 > > @@ -1134,7 +1134,7 @@ load_toolhelp (void) > > } > > > > static int > > -toolhelp_get_dll_name (DWORD BaseAddress, char *dll_name_ret) > > +toolhelp_get_dll_name (uintptr_t BaseAddress, char *dll_name_ret) >=20 > and this one, take an LPVOID/void* instead, like the > equivalent gdb/windows-nat.c code, and most of the casts > disappear. Again, please remember that gdb/windows-nat.c has all > these problems fixed already. Remember to take a look there.. I used LPVOID as you suggested. =20 > > { > > HANDLE snapshot_module; > > MODULEENTRY32 modEntry =3D { sizeof (MODULEENTRY32) }; > > @@ -1151,7 +1151,7 @@ toolhelp_get_dll_name (DWORD BaseAddress > > /* Ignore the first module, which is the exe. */ > > if (win32_Module32First (snapshot_module, &modEntry)) > > while (win32_Module32Next (snapshot_module, &modEntry)) > > - if ((DWORD) modEntry.modBaseAddr =3D=3D BaseAddress) > > + if ((uintptr_t) modEntry.modBaseAddr =3D=3D BaseAddress) >=20 > ... like this one... >=20 > > { > > #ifdef UNICODE > > wcstombs (dll_name_ret, modEntry.szExePath, MAX_PATH + 1); > > @@ -1176,21 +1176,21 @@ handle_load_dll (void) > > LOAD_DLL_DEBUG_INFO *event =3D ¤t_event.u.LoadDll; > > char dll_buf[MAX_PATH + 1]; > > char *dll_name =3D NULL; > > - DWORD load_addr; > > + uintptr_t load_addr; > > > > dll_buf[0] =3D dll_buf[sizeof (dll_buf) - 1] =3D '\0'; > > > > /* Windows does not report the image name of the dlls in the debug > > event on attaches. We resort to iterating over the list of > > loaded dlls looking for a match by image base. */ > > - if (!psapi_get_dll_name ((DWORD) event->lpBaseOfDll, dll_buf)) > > + if (!psapi_get_dll_name ((uintptr_t) event->lpBaseOfDll, dll_buf)) >=20 > and this one... >=20 > > { > > if (!server_waiting) > > /* On some versions of Windows and Windows CE, we can't > create > > toolhelp snapshots while the inferior is stopped in a > > LOAD_DLL_DEBUG_EVENT due to a dll load, but we can while > > Windows is reporting the already loaded dlls. */ > > - toolhelp_get_dll_name ((DWORD) event->lpBaseOfDll, dll_buf); > > + toolhelp_get_dll_name ((uintptr_t) event->lpBaseOfDll, > dll_buf); >=20 > and this one. >=20 > > } > > > > dll_name =3D dll_buf; > > @@ -1205,7 +1205,7 @@ handle_load_dll (void) > > the offset from 0 of the first byte in an image - because > > of the file header and the section alignment. */ > > > > - load_addr =3D (DWORD) event->lpBaseOfDll + 0x1000; > > + load_addr =3D (uintptr_t) event->lpBaseOfDll + 0x1000; > > win32_add_one_solib (dll_name, load_addr); > > } > > > > @@ -1213,7 +1213,7 @@ static void > > handle_unload_dll (void) > > { > > CORE_ADDR load_addr =3D > > - (CORE_ADDR) (DWORD) current_event.u.UnloadDll.lpBaseOfDll; > > + (CORE_ADDR) (uintptr_t) > current_event.u.UnloadDll.lpBaseOfDll; > > load_addr +=3D 0x1000; > > unloaded_dll (NULL, load_addr); > > } > > @@ -1314,10 +1314,10 @@ handle_exception (struct target_waitstat > > ourstatus->kind =3D TARGET_WAITKIND_SPURIOUS; > > return; > > } > > - OUTMSG2 (("gdbserver: unknown target exception 0x%08lx at > 0x%08lx", > > + OUTMSG2 (("gdbserver: unknown target exception 0x%08lx at > 0x%s", > > > current_event.u.Exception.ExceptionRecord.ExceptionCode, > > - (DWORD) current_event.u.Exception.ExceptionRecord. > > - ExceptionAddress)); > > + phex_nz ((uintptr_t) > > current_event.u.Exception.ExceptionRecord. > > + ExceptionAddress, sizeof(uintptr_t)))); >=20 > Missing space before parens. Fixed.=20 > > ourstatus->value.sig =3D TARGET_SIGNAL_UNKNOWN; > > break; > > } > > @@ -1577,7 +1577,6 @@ get_child_debug_event (struct target_wai > > static ptid_t > > win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int > options) > > { > > - struct process_info *process; > > struct regcache *regcache; > > > > while (1) > > New version below. Pierre gdbserver ChangeLog entry: 2010-04-19 Pierre Muller * win32-low.c: Adapt to support also 64-bit architecture. (child_xfer_memory): Use uintptr_t type for local variable `addr'. (get_image_name): Use SIZE_T type for local variable `done'. (psapi_get_dll_name): Use LPVOID type for parameter `BaseAddress'. (toolhelp_get_dll_name): Idem. (handle_load_dll): Use CORE_ADDR type for local variable `load_addr'. Use uintptr_t typecast to avoid warning. (handle_unload_dll): Use uintptr_t typecast to avoid warning. (handle_exception): Use phex_nz to avoid warning. (win32_wait): Remove unused local variable `process'. Index: gdbserver/win32-low.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v retrieving revision 1.46 diff -u -p -r1.46 win32-low.c --- gdbserver/win32-low.c 16 Apr 2010 07:49:37 -0000 1.46 +++ gdbserver/win32-low.c 19 Apr 2010 23:30:05 -0000 @@ -280,7 +280,7 @@ child_xfer_memory (CORE_ADDR memaddr, ch int write, struct target_ops *target) { SIZE_T done; - long addr =3D (long) memaddr; + uintptr_t addr =3D (uintptr_t) memaddr; =20 if (write) { @@ -941,7 +941,7 @@ get_image_name (HANDLE h, void *address, char *address_ptr; int len =3D 0; char b[2]; - DWORD done; + SIZE_T done; =20 /* Attempt to read the name of the dll that was detected. This is documented to work only when actively debugging @@ -1019,7 +1019,7 @@ load_psapi (void) } =20 static int -psapi_get_dll_name (DWORD BaseAddress, char *dll_name_ret) +psapi_get_dll_name (LPVOID BaseAddress, char *dll_name_ret) { DWORD len; MODULEINFO mi; @@ -1064,7 +1064,7 @@ psapi_get_dll_name (DWORD BaseAddress, c (int) err, strwinerror (err)); } =20 - if ((DWORD) (mi.lpBaseOfDll) =3D=3D BaseAddress) + if (mi.lpBaseOfDll =3D=3D BaseAddress) { len =3D (*win32_GetModuleFileNameExA) (current_process_handle, DllHandle[i], @@ -1134,7 +1134,7 @@ load_toolhelp (void) } =20 static int -toolhelp_get_dll_name (DWORD BaseAddress, char *dll_name_ret) +toolhelp_get_dll_name (LPVOID BaseAddress, char *dll_name_ret) { HANDLE snapshot_module; MODULEENTRY32 modEntry =3D { sizeof (MODULEENTRY32) }; @@ -1151,7 +1151,7 @@ toolhelp_get_dll_name (DWORD BaseAddress /* Ignore the first module, which is the exe. */ if (win32_Module32First (snapshot_module, &modEntry)) while (win32_Module32Next (snapshot_module, &modEntry)) - if ((DWORD) modEntry.modBaseAddr =3D=3D BaseAddress) + if (modEntry.modBaseAddr =3D=3D BaseAddress) { #ifdef UNICODE wcstombs (dll_name_ret, modEntry.szExePath, MAX_PATH + 1); @@ -1176,21 +1176,21 @@ handle_load_dll (void) LOAD_DLL_DEBUG_INFO *event =3D ¤t_event.u.LoadDll; char dll_buf[MAX_PATH + 1]; char *dll_name =3D NULL; - DWORD load_addr; + CORE_ADDR load_addr; =20 dll_buf[0] =3D dll_buf[sizeof (dll_buf) - 1] =3D '\0'; =20 /* Windows does not report the image name of the dlls in the debug event on attaches. We resort to iterating over the list of loaded dlls looking for a match by image base. */ - if (!psapi_get_dll_name ((DWORD) event->lpBaseOfDll, dll_buf)) + if (!psapi_get_dll_name (event->lpBaseOfDll, dll_buf)) { if (!server_waiting) /* On some versions of Windows and Windows CE, we can't create toolhelp snapshots while the inferior is stopped in a LOAD_DLL_DEBUG_EVENT due to a dll load, but we can while Windows is reporting the already loaded dlls. */ - toolhelp_get_dll_name ((DWORD) event->lpBaseOfDll, dll_buf); + toolhelp_get_dll_name (event->lpBaseOfDll, dll_buf); } =20 dll_name =3D dll_buf; @@ -1205,7 +1205,7 @@ handle_load_dll (void) the offset from 0 of the first byte in an image - because of the file header and the section alignment. */ =20 - load_addr =3D (DWORD) event->lpBaseOfDll + 0x1000; + load_addr =3D (CORE_ADDR) (uintptr_t) event->lpBaseOfDll + 0x1000; win32_add_one_solib (dll_name, load_addr); } =20 @@ -1213,7 +1213,7 @@ static void handle_unload_dll (void) { CORE_ADDR load_addr =3D - (CORE_ADDR) (DWORD) current_event.u.UnloadDll.lpBaseOfDll; + (CORE_ADDR) (uintptr_t) current_event.u.UnloadDll.lpBaseOfDll; load_addr +=3D 0x1000; unloaded_dll (NULL, load_addr); } @@ -1314,10 +1314,10 @@ handle_exception (struct target_waitstat ourstatus->kind =3D TARGET_WAITKIND_SPURIOUS; return; } - OUTMSG2 (("gdbserver: unknown target exception 0x%08lx at 0x%08lx", + OUTMSG2 (("gdbserver: unknown target exception 0x%08lx at 0x%s", current_event.u.Exception.ExceptionRecord.ExceptionCode, - (DWORD) current_event.u.Exception.ExceptionRecord. - ExceptionAddress)); + phex_nz ((uintptr_t) current_event.u.Exception.ExceptionRecord. + ExceptionAddress, sizeof (uintptr_t)))); ourstatus->value.sig =3D TARGET_SIGNAL_UNKNOWN; break; } @@ -1577,7 +1577,6 @@ get_child_debug_event (struct target_wai static ptid_t win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options) { - struct process_info *process; struct regcache *regcache; =20 while (1)