[PR,build/23568] Fix gdb-7.12.1 MinGW/MSYS build issue

Message ID c9c8ff23-a8ca-6a19-bae5-be12dcb64ad9@gmail.com
State New, archived
Headers

Commit Message

SiZiOUS Dec. 2, 2018, 1:52 p.m. UTC
  Hello,

Long time no see, sorry for this delay.
Thanks for the information, about the 5.1.1 of the MinGW runtime and 
Win32 API headers.

This is really strange, I don't get it. The official mingw-get-setup 
tool from the official repo (https://fr.osdn.net/projects/mingw/) are 
using manifest files in date of 20170905, i.e. the MinGW runtime I use 
is 5.0.2.
So why making an update tool that doesn't do any updates sounds strange 
to me. So definitely my issue is related to the MinGW project update 
policy I guess.

By the way I finally moved from 7.12.1 to GDB 8.2 as I had a severe bug 
with remote debugging through a gdb stub (something related to a 'tp' 
thread assertion error).
So I tried to compile GDB 8.2 with that (outdated?! but out-of-the-box!) 
MinGW environment and still have errors related to winsock2.
So I made a diff patch to add some non-destructive instructions that 
you'll find attached. Feel free to use it or not.

If you wouldn't mind, I have a little question about remote debugging.
What's the proper way to tell the gdb client the fact that the remote 
process has ended?
If I understand well, I just need to close the connection (i.e. closing 
the socket). But sometimes it's working (i.e. gdb client shows "Remote 
connection ended") and sometimes it won't (gdb shows "Remote 
communication error: Not a directory" or "Remote communication error: No 
such file or directory").

I have the following:
target process ("hello.elf") <-----> application uploader/runner 
("dc-tool.exe") <-----> gdb client ("sh-elf-gdb")
target arch (sh-elf)                   |         host arch (pc win32)

dc-tool is a custom program which is reponsible to upload and execute 
the program on the target. gdb client passes through it to interact with 
the target program.
That means, the gdb server handling is in the dc-tool program.

I think part of the answer is the notification packet: 
https://sourceware.org/gdb/onlinedocs/gdb/Notification-Packets.html#Notification-Packets 

But I don't know if it's true and I don't know how to implement this.

Thank you for your time.

BR,
Mike
>
> Le 09/09/2018 à 22:06, Eli Zaretskii a écrit :
>>> From: SiZiOUS<sizious@gmail.com>
>>> Cc:gdb-patches@sourceware.org
>>> Date: Wed, 29 Aug 2018 10:04:20 +0200
>>>
>>> Just for your information, I tried to build gdb-8.1.1 under MinGW/MSYS
>>> and it doesn't work, due to a similar reason.
>>> I opened a bug:https://sourceware.org/bugzilla/show_bug.cgi?id=23583
>> FWIW, building GDB 8.2 with the latest version 5.1.1 of the MinGW
>> runtime and w32 API headers doesn't have this problem, it builds
>> cleanly (modulo a few harmless warnings).  So I suggest to upgrade to
>> the latest MinGW headers.
>
  

Patch

diff -ruN gdb-8.2/gdb/gnulib/import/strerror-override.c gdb-8.2-mingw/gdb/gnulib/import/strerror-override.c
--- gdb-8.2/gdb/gnulib/import/strerror-override.c	2018-09-05 07:44:28 +0000
+++ gdb-8.2-mingw/gdb/gnulib/import/strerror-override.c	2018-11-30 19:37:03 +0000
@@ -25,6 +25,9 @@ 
 
 #if GNULIB_defined_EWINSOCK /* native Windows platforms */
 # if HAVE_WINSOCK2_H
+#  ifdef __MINGW32__
+#  include <winerror.h>
+#  endif
 #  include <winsock2.h>
 # endif
 #endif
diff -ruN gdb-8.2/gdb/ser-mingw.c gdb-8.2-mingw/gdb/ser-mingw.c
--- gdb-8.2/gdb/ser-mingw.c	2018-09-05 07:44:28 +0000
+++ gdb-8.2-mingw/gdb/ser-mingw.c	2018-11-30 19:57:46 +0000
@@ -29,6 +29,10 @@ 
 #include <unistd.h>
 #include <sys/types.h>
 
+#ifndef ERROR_IO_PENDING
+#include <winerror.h>
+#endif
+
 #include "command.h"
 
 struct ser_windows_state