[RFA] Re: [RFC-v2] Reenable compilation with cygwin 1.5 versions

Pierre Muller
2010-03-08T16:02:26Z

Thanks Christopher,

your patch is almost enough to
get GDB to compile again for 1.5 version Cygwins.

There are three little problems left:
canonicalize_file_name function seems new to the new Cygwin API
as well as CW_SET_DOS_FILE_WARNING macro.
After fixing these two, I also got one warning about
cygallargs local that could be used un-initialized.

The patch below fixes those three errors.

Ideally, the cygwin_internal macro used
should rather be of the form
#ifdef __NEW_CYGWIN_API
but Christopher did not seem to like such a macro...

Are these patches OK?

Pierre
(Of course the remote-fileio.c patch also
still needs to be accepted.)

2010-03-08 Pierre Muller <muller@ics.u-strasbg.fr>

* windows-nat.c (canonicalize_file_name): New macro
for old cygwin API support.
(windows_create_inferior): Add missing cygallargs setting.
(_initialize_windows_nat): Only call cygwin_internal
CW_SET_DOS_FILE_WARNING for new Cygwin API.

Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.205
diff -u -p -r1.205 windows-nat.c
--- windows-nat.c 6 Mar 2010 19:27:09 -0000 1.205
+++ windows-nat.c 8 Mar 2010 15:41:26 -0000
@@ -115,6 +115,7 @@ static struct target_ops windows_ops;
# define GetModuleFileNameEx_name "GetModuleFileNameExW"
# define bad_GetModuleFileNameEx bad_GetModuleFileNameExW
# else
+# define canonicalize_file_name(name) alloca(PATH_MAX);
cygwin_conv_to_full_posix_path (name, rname)
# define cygwin_conv_path(op, from, to, size)
cygwin_conv_to_full_posix_path (from, to)
typedef char cygwin_buf_t;
static DWORD WINAPI (*GetModuleFileNameEx) (HANDLE, HMODULE, LPSTR,
DWORD);
@@ -1945,6 +1946,10 @@ windows_create_inferior (struct target_o
error (_("Error starting executable: %d"), errno);
cygallargs = (wchar_t *) alloca (len * sizeof (wchar_t));
mbstowcs (cygallargs, allargs, len);
+#else
+ len = strlen (allargs) + 1;
+ cygallargs = (char *) alloca (len);
+ strcpy (cygallargs, allargs);
#endif
}
else
@@ -2335,8 +2340,10 @@ _initialize_windows_nat (void)
init_windows_ops ();

#ifdef __CYGWIN__
+#ifdef __USEWIDE
cygwin_internal (CW_SET_DOS_FILE_WARNING, 0);
#endif
+#endif

c = add_com ("dll-symbols", class_files, dll_symbol_command,
_("Load dll library symbols from FILE."));