* [gdbserver] compiling latest server.c (rev. 1.76) with MinGW for running on win32
@ 2008-07-18 17:33 Dr. Rolf Jansen
2008-07-18 19:32 ` Pedro Alves
0 siblings, 1 reply; 5+ messages in thread
From: Dr. Rolf Jansen @ 2008-07-18 17:33 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2373 bytes --]
The latest server.c rev 1.76 does produce warnings when compiled with
the MinGW tools:
server.c: In function 'start_inferior':
server.c:107: warning: implicit declaration of function 'alloca'
server.c:107: warning: incompatible implicit declaration of built-in
function 'alloca'
server.c: In function 'handle_search_memory_1':
server.c:356: warning: implicit declaration of function 'memmem'
server.c:356: warning: assignment makes pointer from integer without a
cast
In addition, linking of gdbserver.exe fails because of undefined
references:
remote-utils.o:remote-utils.c:(.text+0x1057): undefined reference to
`_disable_packet_Tthread'
server.o:server.c:(.text+0x9c6): undefined reference to
`_disable_packet_qC'
server.o:server.c:(.text+0xa6f): undefined reference to
`_disable_packet_qfThreadInfo'
server.o:server.c:(.text+0x20b4): undefined reference to
`_disable_packet_vCont'
server.o:server.c:(.text+0x264a): undefined reference to
`_disable_packet_vCont'
server.o:server.c:(.text+0x2670): undefined reference to
`_disable_packet_Tthread'
server.o:server.c:(.text+0x2696): undefined reference to
`_disable_packet_qC'
server.o:server.c:(.text+0x26bc): undefined reference to
`_disable_packet_qfThreadInfo'
server.o:server.c:(.text+0x26df): undefined reference to
`_disable_packet_vCont'
server.o:server.c:(.text+0x26e9): undefined reference to
`_disable_packet_Tthread'
server.o:server.c:(.text+0x26f3): undefined reference to
`_disable_packet_qC'
server.o:server.c:(.text+0x26fd): undefined reference to
`_disable_packet_qfThreadInfo'
collect2: ld returned 1 exit status
MinGW defines alloca() in <malloc.h> and memmem() is not built-in. I
think this should eventually be addressed in the configure script,
however, as a quick fix, I added at the top of server.c:
#if USE_WIN32API
#include <malloc.h>
void *memmem (const void *haystack_start, size_t haystack_len, const
void *needle_start, size_t needle_len);
#endif
In order to resolve the linking errors, the definition of the
respective variables must be moved out of the conditional block
(#ifdef SIGTTOU ... #endif), because they are used also within non-
conditional code in remote-utils.c and in server.c.
I attached a .diff to this message, wich addresses both issues,
although, there might be better ways to address 'em.
Best regards
Rolf Jansen
[-- Attachment #2: server.diff --]
[-- Type: application/octet-stream, Size: 1878 bytes --]
*** HEAD/src/gdb/gdbserver/server.c Fri Jul 18 14:07:19 2008
--- LOCAL/src/gdb/gdbserver/server.c Fri Jul 18 14:07:01 2008
***************
*** 28,33 ****
--- 28,37 ----
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
+ #if USE_WIN32API
+ #include <malloc.h>
+ void *memmem (const void *haystack_start, size_t haystack_len, const void *needle_start, size_t needle_len);
+ #endif
unsigned long cont_thread;
unsigned long general_thread;
*************** int terminal_fd;
*** 67,80 ****
/* TERMINAL_FD's original foreground group. */
pid_t old_foreground_pgrp;
- /* Set if you want to disable optional thread related packets support
- in gdbserver, for the sake of testing GDB against stubs that don't
- support them. */
- int disable_packet_vCont;
- int disable_packet_Tthread;
- int disable_packet_qC;
- int disable_packet_qfThreadInfo;
-
/* Hand back terminal ownership to the original foreground group. */
static void
--- 71,76 ----
*************** restore_old_foreground_pgrp (void)
*** 84,89 ****
--- 80,93 ----
}
#endif
+ /* Set if you want to disable optional thread related packets support
+ in gdbserver, for the sake of testing GDB against stubs that don't
+ support them. */
+ int disable_packet_vCont = 0;
+ int disable_packet_Tthread = 0;
+ int disable_packet_qC = 0;
+ int disable_packet_qfThreadInfo = 0;
+
static int
target_running (void)
{
*************** main (int argc, char *argv[])
*** 1299,1304 ****
--- 1303,1309 ----
gdbserver_show_disableable (stdout);
exit (0);
}
+ #ifdef SIGTTOU
else if (strncmp (*next_arg,
"--disable-packet=",
sizeof ("--disable-packet=") - 1) == 0)
*************** main (int argc, char *argv[])
*** 1334,1339 ****
--- 1339,1345 ----
}
}
}
+ #endif
else
{
fprintf (stderr, "Unknown argument: %s\n", *next_arg);
[-- Attachment #3: Type: text/plain, Size: 3 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [gdbserver] compiling latest server.c (rev. 1.76) with MinGW for running on win32
2008-07-18 17:33 [gdbserver] compiling latest server.c (rev. 1.76) with MinGW for running on win32 Dr. Rolf Jansen
@ 2008-07-18 19:32 ` Pedro Alves
2008-07-18 20:17 ` Dr. Rolf Jansen
0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2008-07-18 19:32 UTC (permalink / raw)
To: gdb-patches; +Cc: Dr. Rolf Jansen
Hi Rolf,
On Friday 18 July 2008 18:32:32, Dr. Rolf Jansen wrote:
> The latest server.c rev 1.76 does produce warnings when compiled with
> the MinGW tools:
>
> server.c: In function 'start_inferior':
> server.c:107: warning: implicit declaration of function 'alloca'
> server.c:107: warning: incompatible implicit declaration of built-in
> function 'alloca'
> server.c: In function 'handle_search_memory_1':
> server.c:356: warning: implicit declaration of function 'memmem'
> server.c:356: warning: assignment makes pointer from integer without a
> cast
> MinGW defines alloca() in <malloc.h> and memmem() is not built-in. I
> think this should eventually be addressed in the configure script,
> however, as a quick fix, I added at the top of server.c:
> #if USE_WIN32API
> #include <malloc.h>
This bit be done with...
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
... instead. We're already doing that in utils.c.
> void *memmem (const void *haystack_start, size_t haystack_len, const
> void *needle_start, size_t needle_len);
> #endif
Hmmm, shouldn't we be picking up memmem's definition from gnulib's string.h,
since we're using memmem from gnulib?
> In addition, linking of gdbserver.exe fails because of undefined
> references:
>
> remote-utils.o:remote-utils.c:(.text+0x1057): undefined reference to
> `_disable_packet_Tthread'
> In order to resolve the linking errors, the definition of the
> respective variables must be moved out of the conditional block
> (#ifdef SIGTTOU ... #endif), because they are used also within non-
> conditional code in remote-utils.c and in server.c.
>
Ooops. Yes, it should move out of the #if block. It was just an
oversight. No need to add the SIGTTOU checks around the
--disable-packet handling.
--
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gdbserver] compiling latest server.c (rev. 1.76) with MinGW for running on win32
2008-07-18 19:32 ` Pedro Alves
@ 2008-07-18 20:17 ` Dr. Rolf Jansen
2008-07-31 16:19 ` Pedro Alves
0 siblings, 1 reply; 5+ messages in thread
From: Dr. Rolf Jansen @ 2008-07-18 20:17 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Hi Pedro,
many thanks for the reply!
Am 18.07.2008 um 16:32 schrieb Pedro Alves:
> Hi Rolf,
>
> On Friday 18 July 2008 18:32:32, Dr. Rolf Jansen wrote:
>> The latest server.c rev 1.76 does produce warnings when compiled with
>> the MinGW tools:
>>
>> ...
>>
>> MinGW defines alloca() in <malloc.h> and memmem() is not built-in. I
>> think this should eventually be addressed in the configure script,
>> however, as a quick fix, I added at the top of server.c:
>>
>>
>> #if USE_WIN32API
>> #include <malloc.h>
>
> This bit be done with...
>
> #if HAVE_MALLOC_H
> #include <malloc.h>
> #endif
>
> ... instead. We're already doing that in utils.c.
YES, I can confirm this, this works for server.c too.
Great!
>> void *memmem (const void *haystack_start, size_t haystack_len, const
>> void *needle_start, size_t needle_len);
>> #endif
>
> Hmmm, shouldn't we be picking up memmem's definition from gnulib's
> string.h,
> since we're using memmem from gnulib?
Ah, now I got it.
I fear gnulib's string.h will not work in my case, because I am
compiling gdb at a Mac OS X box using the Mac gcc-4.2-tool chain with
host=powerpc-apple-darwin9.4.0 and target=i386-mingw32msvc. And from
the same source tree I am cross-compiling gdbserver using the MinGW-
gcc-4.3.1-tool chain with build=powerpc-apple-darwin9.4.0 and host/
target=i386-pc-mingw32msvc.
Since gnulib belongs to the gdb source tree, and Mac OS X has memmem()
and the other stuff built-in, gnulib's string.h would never be built.
This kind of issue with gnulib when compiling gdb and cross-compiling
gdbserver was discussed recently already, and it only came back into
my mind now. So, I am sorry about reporting a false issue.
In my local code I simply keep the declaration of memmem(), however it
is probably not a good idea to patch HEAD.server.c with that.
>> In order to resolve the linking errors, the definition of the
>> respective variables must be moved out of the conditional block
>> (#ifdef SIGTTOU ... #endif), because they are used also within non-
>> conditional code in remote-utils.c and in server.c.
> Ooops. Yes, it should move out of the #if block. It was just an
> oversight. No need to add the SIGTTOU checks around the
> --disable-packet handling.
OK, I took it out, and I confirm that this works too.
Best regards
Rolf Jansen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gdbserver] compiling latest server.c (rev. 1.76) with MinGW for running on win32
2008-07-18 20:17 ` Dr. Rolf Jansen
@ 2008-07-31 16:19 ` Pedro Alves
2008-07-31 16:48 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2008-07-31 16:19 UTC (permalink / raw)
To: Dr. Rolf Jansen; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 169 bytes --]
Hi Rolf,
Sorry for dropping out on you.
I checked that gdbserver now builds OK with the attached patch
on mingw32 and linux.
Daniel, OK to check in?
--
Pedro Alves
[-- Attachment #2: memmem.diff --]
[-- Type: text/x-diff, Size: 2892 bytes --]
2008-07-31 Rolf Jansen <rj@surtec.com>
Pedro Alves <pedro@codesourcery.com>
* configure.ac: Check for memmem declaration.
* server.c [HAVE_MALLOC_H]: Include malloc.h.
(disable_packet_vCont, disable_packet_Tthread, disable_packet_qC)
(disable_packet_qfThreadInfo): Unconditionally compile.
* server.h [!HAVE_DECL_MEMMEM]: Declare memmem.
* configure, config.in: Regenerate.
---
gdb/gdbserver/configure.ac | 2 +-
gdb/gdbserver/server.c | 19 +++++++++++--------
gdb/gdbserver/server.h | 4 ++++
3 files changed, 16 insertions(+), 9 deletions(-)
Index: src/gdb/gdbserver/configure.ac
===================================================================
--- src.orig/gdb/gdbserver/configure.ac 2008-06-06 12:25:11.000000000 +0100
+++ src/gdb/gdbserver/configure.ac 2008-07-31 17:10:46.000000000 +0100
@@ -61,7 +61,7 @@ AC_TRY_LINK([
[AC_MSG_RESULT(no)])
fi
-AC_CHECK_DECLS([strerror, perror])
+AC_CHECK_DECLS([strerror, perror, memmem])
AC_CHECK_TYPES(socklen_t, [], [],
[#include <sys/types.h>
Index: src/gdb/gdbserver/server.c
===================================================================
--- src.orig/gdb/gdbserver/server.c 2008-07-08 00:05:33.000000000 +0100
+++ src/gdb/gdbserver/server.c 2008-07-31 17:10:46.000000000 +0100
@@ -28,6 +28,9 @@
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
+#if HAVE_MALLOC_H
+#include <malloc.h>
+#endif
unsigned long cont_thread;
unsigned long general_thread;
@@ -67,14 +70,6 @@ int terminal_fd;
/* TERMINAL_FD's original foreground group. */
pid_t old_foreground_pgrp;
-/* Set if you want to disable optional thread related packets support
- in gdbserver, for the sake of testing GDB against stubs that don't
- support them. */
-int disable_packet_vCont;
-int disable_packet_Tthread;
-int disable_packet_qC;
-int disable_packet_qfThreadInfo;
-
/* Hand back terminal ownership to the original foreground group. */
static void
@@ -84,6 +79,14 @@ restore_old_foreground_pgrp (void)
}
#endif
+/* Set if you want to disable optional thread related packets support
+ in gdbserver, for the sake of testing GDB against stubs that don't
+ support them. */
+int disable_packet_vCont;
+int disable_packet_Tthread;
+int disable_packet_qC;
+int disable_packet_qfThreadInfo;
+
static int
target_running (void)
{
Index: src/gdb/gdbserver/server.h
===================================================================
--- src.orig/gdb/gdbserver/server.h 2008-07-02 12:35:07.000000000 +0100
+++ src/gdb/gdbserver/server.h 2008-07-31 17:10:46.000000000 +0100
@@ -50,6 +50,10 @@ extern void perror (const char *);
#endif
#endif
+#if !HAVE_DECL_MEMMEM
+extern void *memmem (const void *, size_t , const void *, size_t);
+#endif
+
#ifndef ATTR_NORETURN
#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
#define ATTR_NORETURN __attribute__ ((noreturn))
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [gdbserver] compiling latest server.c (rev. 1.76) with MinGW for running on win32
2008-07-31 16:19 ` Pedro Alves
@ 2008-07-31 16:48 ` Daniel Jacobowitz
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2008-07-31 16:48 UTC (permalink / raw)
To: Pedro Alves; +Cc: Dr. Rolf Jansen, gdb-patches
On Thu, Jul 31, 2008 at 05:18:40PM +0100, Pedro Alves wrote:
> Hi Rolf,
>
> Sorry for dropping out on you.
>
> I checked that gdbserver now builds OK with the attached patch
> on mingw32 and linux.
>
> Daniel, OK to check in?
This is OK, thanks.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-07-31 16:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-18 17:33 [gdbserver] compiling latest server.c (rev. 1.76) with MinGW for running on win32 Dr. Rolf Jansen
2008-07-18 19:32 ` Pedro Alves
2008-07-18 20:17 ` Dr. Rolf Jansen
2008-07-31 16:19 ` Pedro Alves
2008-07-31 16:48 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox