Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA/win32] Change the DLL base address type to LPVOID
@ 2009-01-07 11:46 Joel Brobecker
  2009-01-07 14:43 ` Jan Kratochvil
  2009-01-07 17:04 ` Christopher Faylor
  0 siblings, 2 replies; 4+ messages in thread
From: Joel Brobecker @ 2009-01-07 11:46 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 789 bytes --]

This patch changes the type used to manipulate the DLL base address from
DWORD to LPVOID.  The Windows headers declare this address as an LPVOID,
and using DWORD causes problems on x86_64-windows because the types do
not have the same size.

2009-01-07  Joel Brobecker  <brobecker@adacore.com>

        * win32-nat.c (get_module_name): Change the type of parameter
        "base_address" to LPVOID.  Remove unnecessary cast.
        (struct lm_info): Change type of load_addr to LPVOID.
        (win32_make_so): Change the type of parameter "load_addr"
        to LPVOID.  Remove some unnecessary casts.
        (handle_unload_dll): Change the type of "lpBaseOfDll" to LPVOID.
        (win32_xfer_shared_libraries): Add missing cast.

Tested on x86-windows.
OK to apply?

Thanks,
-- 
Joel

[-- Attachment #2: farproc.diff --]
[-- Type: text/plain, Size: 1677 bytes --]

diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c
index 1b15dfb..5300731 100644
--- a/gdb/win32-nat.c
+++ b/gdb/win32-nat.c
@@ -1600,11 +1600,11 @@ has_detach_ability (void)
   if (kernel32)
     {
       if (!kernel32_DebugSetProcessKillOnExit)
-	kernel32_DebugSetProcessKillOnExit = GetProcAddress (kernel32,
-						 "DebugSetProcessKillOnExit");
+	kernel32_DebugSetProcessKillOnExit =
+	  (void *) GetProcAddress (kernel32, "DebugSetProcessKillOnExit");
       if (!kernel32_DebugActiveProcessStop)
-	kernel32_DebugActiveProcessStop = GetProcAddress (kernel32,
-						 "DebugActiveProcessStop");
+	kernel32_DebugActiveProcessStop =
+	  (void *) GetProcAddress (kernel32, "DebugActiveProcessStop");
       if (kernel32_DebugSetProcessKillOnExit
 	  && kernel32_DebugActiveProcessStop)
 	return 1;
@@ -1641,13 +1641,14 @@ set_process_privilege (const char *privilege, BOOL enable)
       if (!(advapi32 = LoadLibrary ("advapi32.dll")))
 	goto out;
       if (!OpenProcessToken)
-	OpenProcessToken = GetProcAddress (advapi32, "OpenProcessToken");
+	OpenProcessToken =
+          (void *) GetProcAddress (advapi32, "OpenProcessToken");
       if (!LookupPrivilegeValue)
-	LookupPrivilegeValue = GetProcAddress (advapi32,
-					       "LookupPrivilegeValueA");
+	LookupPrivilegeValue =
+          (void *) GetProcAddress (advapi32, "LookupPrivilegeValueA");
       if (!AdjustTokenPrivileges)
-	AdjustTokenPrivileges = GetProcAddress (advapi32,
-						"AdjustTokenPrivileges");
+	AdjustTokenPrivileges =
+          (void *) GetProcAddress (advapi32, "AdjustTokenPrivileges");
       if (!OpenProcessToken || !LookupPrivilegeValue || !AdjustTokenPrivileges)
 	{
 	  advapi32 = NULL;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA/win32] Change the DLL base address type to LPVOID
  2009-01-07 11:46 [RFA/win32] Change the DLL base address type to LPVOID Joel Brobecker
@ 2009-01-07 14:43 ` Jan Kratochvil
  2009-01-07 17:04 ` Christopher Faylor
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2009-01-07 14:43 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Wed, 07 Jan 2009 12:46:20 +0100, Joel Brobecker wrote:
> 2009-01-07  Joel Brobecker  <brobecker@adacore.com>
> 
>         * win32-nat.c (get_module_name): Change the type of parameter
>         "base_address" to LPVOID.  Remove unnecessary cast.
>         (struct lm_info): Change type of load_addr to LPVOID.
>         (win32_make_so): Change the type of parameter "load_addr"
>         to LPVOID.  Remove some unnecessary casts.
>         (handle_unload_dll): Change the type of "lpBaseOfDll" to LPVOID.
>         (win32_xfer_shared_libraries): Add missing cast.
...

[ farproc.diff ]
> -	kernel32_DebugSetProcessKillOnExit = GetProcAddress (kernel32,
> -						 "DebugSetProcessKillOnExit");
> +	kernel32_DebugSetProcessKillOnExit =
> +	  (void *) GetProcAddress (kernel32, "DebugSetProcessKillOnExit");

You have attached a different patch file, the LPVOID patch file is missing.


Regards,
Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA/win32] Change the DLL base address type to LPVOID
  2009-01-07 11:46 [RFA/win32] Change the DLL base address type to LPVOID Joel Brobecker
  2009-01-07 14:43 ` Jan Kratochvil
@ 2009-01-07 17:04 ` Christopher Faylor
  2009-01-09 10:55   ` Joel Brobecker
  1 sibling, 1 reply; 4+ messages in thread
From: Christopher Faylor @ 2009-01-07 17:04 UTC (permalink / raw)
  To: gdb-patches, Joel Brobecker

On Wed, Jan 07, 2009 at 03:46:20PM +0400, Joel Brobecker wrote:
>2009-01-07  Joel Brobecker  <brobecker@adacore.com>
>
>        * win32-nat.c (get_module_name): Change the type of parameter
>        "base_address" to LPVOID.  Remove unnecessary cast.
>        (struct lm_info): Change type of load_addr to LPVOID.
>        (win32_make_so): Change the type of parameter "load_addr"
>        to LPVOID.  Remove some unnecessary casts.
>        (handle_unload_dll): Change the type of "lpBaseOfDll" to LPVOID.
>        (win32_xfer_shared_libraries): Add missing cast.
>
>Tested on x86-windows.
>OK to apply?

Yes.

cgf


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA/win32] Change the DLL base address type to LPVOID
  2009-01-07 17:04 ` Christopher Faylor
@ 2009-01-09 10:55   ` Joel Brobecker
  0 siblings, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2009-01-09 10:55 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 717 bytes --]

> >2009-01-07  Joel Brobecker  <brobecker@adacore.com>
> >
> >        * win32-nat.c (get_module_name): Change the type of parameter
> >        "base_address" to LPVOID.  Remove unnecessary cast.
> >        (struct lm_info): Change type of load_addr to LPVOID.
> >        (win32_make_so): Change the type of parameter "load_addr"
> >        to LPVOID.  Remove some unnecessary casts.
> >        (handle_unload_dll): Change the type of "lpBaseOfDll" to LPVOID.
> >        (win32_xfer_shared_libraries): Add missing cast.
> >
> >Tested on x86-windows.
> >OK to apply?
> 
> Yes.

Thank you. Checked in. And since I posted the wrong patch, I'm attaching
the patch I just checked in (Thanks to Jan for noticing).

-- 
Joel

[-- Attachment #2: lpvoid.diff --]
[-- Type: text/plain, Size: 2913 bytes --]

diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c
index 5300731..66ebdd6 100644
--- a/gdb/win32-nat.c
+++ b/gdb/win32-nat.c
@@ -481,7 +481,7 @@ static DWORD WINAPI (*psapi_GetModuleFileNameExA) (HANDLE, HMODULE, LPSTR,
    is zero return the first loaded module (which is always the name of the
    executable).  */
 static int
-get_module_name (DWORD base_address, char *dll_name_ret)
+get_module_name (LPVOID base_address, char *dll_name_ret)
 {
   DWORD len;
   MODULEINFO mi;
@@ -524,7 +524,7 @@ get_module_name (DWORD base_address, char *dll_name_ret)
 				       &mi, sizeof (mi)))
 	error (_("Can't get module info"));
 
-      if (!base_address || (DWORD) (mi.lpBaseOfDll) == base_address)
+      if (!base_address || mi.lpBaseOfDll == base_address)
 	{
 	  /* Try to find the name of the given module */
 	  len = psapi_GetModuleFileNameExA (current_process_handle,
@@ -560,7 +560,7 @@ struct safe_symbol_file_add_args
 /* Maintain a linked list of "so" information. */
 struct lm_info
 {
-  DWORD load_addr;
+  LPVOID load_addr;
 };
 
 static struct so_list solib_start, *solib_end;
@@ -619,7 +619,7 @@ safe_symbol_file_add (char *name, int from_tty,
 }
 
 static struct so_list *
-win32_make_so (const char *name, DWORD load_addr)
+win32_make_so (const char *name, LPVOID load_addr)
 {
   struct so_list *so;
   char buf[MAX_PATH + 1];
@@ -746,7 +746,7 @@ handle_load_dll (void *dummy)
 
   dll_buf[0] = dll_buf[sizeof (dll_buf) - 1] = '\0';
 
-  if (!get_module_name ((DWORD) event->lpBaseOfDll, dll_buf))
+  if (!get_module_name (event->lpBaseOfDll, dll_buf))
     dll_buf[0] = dll_buf[sizeof (dll_buf) - 1] = '\0';
 
   dll_name = dll_buf;
@@ -757,11 +757,11 @@ handle_load_dll (void *dummy)
   if (!dll_name)
     return 1;
 
-  solib_end->next = win32_make_so (dll_name, (DWORD) event->lpBaseOfDll);
+  solib_end->next = win32_make_so (dll_name, event->lpBaseOfDll);
   solib_end = solib_end->next;
 
   DEBUG_EVENTS (("gdb: Loading dll \"%s\" at 0x%lx.\n", solib_end->so_name,
-		 (DWORD) solib_end->lm_info->load_addr));
+		 solib_end->lm_info->load_addr));
 
   return 1;
 }
@@ -777,7 +777,7 @@ win32_free_so (struct so_list *so)
 static int
 handle_unload_dll (void *dummy)
 {
-  DWORD lpBaseOfDll = (DWORD) current_event.u.UnloadDll.lpBaseOfDll;
+  LPVOID lpBaseOfDll = current_event.u.UnloadDll.lpBaseOfDll;
   struct so_list *so;
 
   for (so = &solib_start; so->next != NULL; so = so->next)
@@ -2082,7 +2082,8 @@ win32_xfer_shared_libraries (struct target_ops *ops,
   obstack_init (&obstack);
   obstack_grow_str (&obstack, "<library-list>\n");
   for (so = solib_start.next; so; so = so->next)
-    win32_xfer_shared_library (so->so_name, so->lm_info->load_addr, &obstack);
+    win32_xfer_shared_library (so->so_name, (CORE_ADDR) so->lm_info->load_addr,
+                               &obstack);
   obstack_grow_str0 (&obstack, "</library-list>\n");
 
   buf = obstack_finish (&obstack);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-09 10:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-07 11:46 [RFA/win32] Change the DLL base address type to LPVOID Joel Brobecker
2009-01-07 14:43 ` Jan Kratochvil
2009-01-07 17:04 ` Christopher Faylor
2009-01-09 10:55   ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox