[RFA] Fix cygwin compilation failure due to nameless LOAD_DLL_DEBUG_EVENT causes ntdll.dll to be missing

Pierre Muller
2013-12-13T22:41:15Z

Following this thread
https://sourceware.org/ml/gdb-patches/2013-12/msg00073.html

The patch
https://sourceware.org/ml/gdb-cvs/2013-12/msg00054.html

introduced a failure for cygwin native build.
The problem is that __USEWIDE is not considered in the patch.

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.

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;
}