Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [RFA] Fix cygwin compilation failure due to nameless LOAD_DLL_DEBUG_EVENT causes ntdll.dll to be missing
Date: Mon, 16 Dec 2013 02:21:00 -0000	[thread overview]
Message-ID: <52AE633E.9020604@codesourcery.com> (raw)
In-Reply-To: <002f01cef853$f44500e0$dccf02a0$@muller@ics-cnrs.unistra.fr>

On 12/14/2013 06:37 AM, Pierre Muller wrote:
> introduced a failure for cygwin native build.
> The problem is that __USEWIDE is not considered in the patch.
> 

For the record, the build failure is this:

cc1: warnings being treated as errors
../../git/gdb/windows-nat.c: In function ‘windows_ensure_ntdll_loaded’:
../../git/gdb/windows-nat.c:1773:11: error: passing argument 3 of ‘GetModuleFileNameEx’ from incompatible pointer type
../../git/gdb/windows-nat.c:1773:11: note: expected ‘LPWSTR’ but argument is of type ‘char *’
Makefile:998: recipe for target `windows-nat.o' failed

> The patch below fixes this compilation error
> and should allow cygwin to work as mingw.
> 
> Pierre Muller
> 
> 
> ChangeLog entry:
> 
> 2013-12-13  Pierre Muller  <muller@sourceware.org>
> 
> 	Fix compilation error for cygwin native build.
> 	* windows-nat.c (windows_ensure_ntdll_loaded): Add
> 	code using wchar_t type and conversion to char string
> 	if __USEWIDE is defined.

Probably, we can write

	(windows_ensure_ntdll_loaded) [__USEWIDE]: Call
	wcstombs.

> 
> 
> diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
> index f0545fc..dda9d8e 100644
> --- a/gdb/windows-nat.c
> +++ b/gdb/windows-nat.c
> @@ -1764,17 +1764,27 @@ windows_ensure_ntdll_loaded (void)
>    for (i = 0; i < (int) (cb_needed / sizeof (HMODULE)); i++)
>      {
>        MODULEINFO mi;
> +#ifdef __USEWIDE
> +      wchar_t dll_name[__PMAX];
> +      char name[__PMAX];
> +#else
>        char dll_name[__PMAX];
> -
> +      char *name;
> +#endif
>        if (GetModuleInformation (current_process_handle, hmodules[i],
>                                 &mi, sizeof (mi)) == 0)
>         continue;
>        if (GetModuleFileNameEx (current_process_handle, hmodules[i],
>                                dll_name, sizeof (dll_name)) == 0)
>         continue;
> -      if (FILENAME_CMP (lbasename (dll_name), "ntdll.dll") == 0)
> +#ifdef __USEWIDE
> +      wcstombs (name, dll_name, __PMAX);
> +#else
> +      name = dll_name;
> +#endif
> +      if (FILENAME_CMP (lbasename (name), "ntdll.dll") == 0)
>         {
> -         solib_end->next = windows_make_so (dll_name, mi.lpBaseOfDll);
> +         solib_end->next = windows_make_so (name, mi.lpBaseOfDll);
>           solib_end = solib_end->next;
>           return;
>         }

GetModuleFileNameEx is also used in get_module_name, so probably we can
copy its pattern here too

#ifdef __CYGWIN__
  len = GetModuleFileNameEx (current_process_handle, DllHandle,
			     pathbuf, __PMAX);
  if (cygwin_conv_path (CCP_WIN_W_TO_POSIX, pathbuf, dll_name_ret,
			__PMAX) < 0)
     ...
#else
  len = GetModuleFileNameEx (current_process_handle,
			     DllHandle, dll_name_ret, __PMAX);
#endif

and code is more consistent on using GetModuleFileNameEx.
-- 
Yao (齐尧)


  reply	other threads:[~2013-12-16  2:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-13 22:41 Pierre Muller
2013-12-16  2:21 ` Yao Qi [this message]
2013-12-16 18:05   ` Pedro Alves
2013-12-17  0:43     ` Yao Qi
2013-12-17  8:43       ` Pierre Muller
2013-12-18  3:37 ` Yao Qi
     [not found] <52ab8d0e.8aa2420a.30ff.ffffd8f1SMTPIN_ADDED_BROKEN@mx.google.com>
2013-12-16 17:13 ` Pedro Alves
2013-12-16 22:50   ` Pierre Muller
2013-12-18 11:20   ` Corinna Vinschen
     [not found]     ` <83bo0ecgdw.fsf@gnu.org>
2013-12-18 16:07       ` Corinna Vinschen
2013-12-18 17:03         ` Eli Zaretskii
2013-12-18 17:18           ` Corinna Vinschen
2013-12-18 17:29             ` Eli Zaretskii
2013-12-18 17:31               ` Corinna Vinschen
2013-12-18 18:19                 ` Eli Zaretskii
2013-12-18 19:18                   ` Corinna Vinschen
2013-12-18 20:01                     ` Eli Zaretskii
2013-12-18 20:54                       ` Corinna Vinschen
2013-12-19 18:33                         ` Eli Zaretskii
2013-12-28  3:17                           ` Joel Brobecker
2013-12-28  9:02                             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52AE633E.9020604@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox