Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [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

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