This is the mail archive of the gdb-testers@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gdb-4.16.85 fails to compile with native SunOs 4.1.x cc


This change

Fri Apr  4 08:21:21 1997  Stu Grossman  (grossman@critters.cygnus.com)

	* (remote_ops extended_remote_ops remote_desc remote_write_size):
	Make static.

causes a SunOs 4.1.x (m68k and sparc) build with native cc to fail with:

cc -c -g     -I. -I. -I./config -DHAVE_CONFIG_H -I./../include/opcode -I./../readline  -I../bfd -I./../bfd  -I./../include  remote.c
"remote.c", line 1885: redeclaration of remote_ops
"remote.c", line 1930: redeclaration of extended_remote_ops

Native cc on DEC MIPS Ultrix 4.4 barfs on the forward decl as well.
Moving the static definition to the top of the file and omitting the
forward declaration gets rid of the problem.


gdb/tracepoint.c contains three ANSI string concatenations which are
not understood by pre-ANSI Compilers.


gdb/config/m68k/xm-sun3os4.h adds explicit declarations for malloc and
friends, which now clash with the definition in stdlib.h (earlier
versions of GDB didn't include stdlib.h). As the autoconf process now
detects the need for malloc declarations, the extra declarations in the
xm file should get removed.


It had been possible in the past to compile GDB with native tools
and pre-ANSI Compilers, perhaps we should keep this tradition.

Here is a patch for the problems:

	* config/m68k/xm-sun3os4.h:  Remove malloc declarations, they
	are handled via autoconf now.
	* remote.c (remote_ops, extended_remote_ops):  Replace static
	forward declaration by moving the static definition to the top of
	the file, for old K&R compilers.
	* tracepoint.c (collect_symbol, trace_start_command):
	Replace ANSI string concatenation with K&R compatible simple string.

*** gdb-4.16.85/gdb/config/m68k/xm-sun3os4.h.orig	Thu Jul 11 09:41:13 1996
--- gdb-4.16.85/gdb/config/m68k/xm-sun3os4.h	Wed Feb 11 18:58:07 1998
***************
*** 19,27 ****
  
  #include "m68k/xm-sun3.h"
  #define FPU
- 
- /* Prevent type conflicts between yacc malloc decls and defs.h */
- #define MALLOC_INCOMPATIBLE
- extern char *malloc();
- extern char *realloc();
- extern void free();
--- 19,21 ----
*** gdb-4.16.85/gdb/remote.c.orig	Tue Nov 25 00:18:10 1997
--- gdb-4.16.85/gdb/remote.c	Thu Feb 12 10:35:54 1998
***************
*** 275,283 ****
  
  static int hexnumlen PARAMS ((ULONGEST num));
  
- static struct target_ops remote_ops;	/* Forward decl */
- static struct target_ops extended_remote_ops;	/* Forward decl */
- 
  /* exported functions */
  
  extern int fromhex PARAMS ((int a));
--- 275,280 ----
***************
*** 284,290 ****
--- 281,381 ----
  extern void getpkt PARAMS ((char *buf, int forever));
  extern int putpkt PARAMS ((char *buf));
  
+ /* Define the target subroutine names */
  
+ static struct target_ops remote_ops =
+ {
+   "remote",			/* to_shortname */
+   "Remote serial target in gdb-specific protocol",	/* to_longname */
+   "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
+ Specify the serial device it is connected to (e.g. /dev/ttya).",  /* to_doc */
+   remote_open,			/* to_open */
+   remote_close,			/* to_close */
+   NULL,				/* to_attach */
+   remote_detach,		/* to_detach */
+   remote_resume,		/* to_resume */
+   remote_wait,			/* to_wait */
+   remote_fetch_registers,	/* to_fetch_registers */
+   remote_store_registers,	/* to_store_registers */
+   remote_prepare_to_store,	/* to_prepare_to_store */
+   remote_xfer_memory,		/* to_xfer_memory */
+   remote_files_info,		/* to_files_info */
+   remote_insert_breakpoint,	/* to_insert_breakpoint */
+   remote_remove_breakpoint,	/* to_remove_breakpoint */
+   NULL,				/* to_terminal_init */
+   NULL,				/* to_terminal_inferior */
+   NULL,				/* to_terminal_ours_for_output */
+   NULL,				/* to_terminal_ours */
+   NULL,				/* to_terminal_info */
+   remote_kill,			/* to_kill */
+   generic_load,			/* to_load */
+   NULL,				/* to_lookup_symbol */
+   NULL,				/* to_create_inferior */
+   remote_mourn,			/* to_mourn_inferior */
+   0,				/* to_can_run */
+   0,				/* to_notice_signals */
+   remote_thread_alive,		/* to_thread_alive */
+   0,				/* to_stop */
+   process_stratum,		/* to_stratum */
+   NULL,				/* to_next */
+   1,				/* to_has_all_memory */
+   1,				/* to_has_memory */
+   1,				/* to_has_stack */
+   1,				/* to_has_registers */
+   1,				/* to_has_execution */
+   NULL,				/* sections */
+   NULL,				/* sections_end */
+   OPS_MAGIC			/* to_magic */
+ };
+ 
+ static struct target_ops extended_remote_ops =
+ {
+   "extended-remote",			/* to_shortname */
+   "Extended remote serial target in gdb-specific protocol",/* to_longname */
+   "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
+ Specify the serial device it is connected to (e.g. /dev/ttya).",  /* to_doc */
+   extended_remote_open,			/* to_open */
+   remote_close,			/* to_close */
+   NULL,				/* to_attach */
+   remote_detach,		/* to_detach */
+   remote_resume,		/* to_resume */
+   remote_wait,			/* to_wait */
+   remote_fetch_registers,	/* to_fetch_registers */
+   remote_store_registers,	/* to_store_registers */
+   remote_prepare_to_store,	/* to_prepare_to_store */
+   remote_xfer_memory,		/* to_xfer_memory */
+   remote_files_info,		/* to_files_info */
+ 
+   remote_insert_breakpoint,	/* to_insert_breakpoint */
+   remote_remove_breakpoint,	/* to_remove_breakpoint */
+ 
+   NULL,				/* to_terminal_init */
+   NULL,				/* to_terminal_inferior */
+   NULL,				/* to_terminal_ours_for_output */
+   NULL,				/* to_terminal_ours */
+   NULL,				/* to_terminal_info */
+   remote_kill,			/* to_kill */
+   generic_load,			/* to_load */
+   NULL,				/* to_lookup_symbol */
+   extended_remote_create_inferior,/* to_create_inferior */
+   extended_remote_mourn,	/* to_mourn_inferior */
+   0,				/* to_can_run */
+   0,				/* to_notice_signals */
+   remote_thread_alive,		/* to_thread_alive */
+   0,				/* to_stop */
+   process_stratum,		/* to_stratum */
+   NULL,				/* to_next */
+   1,				/* to_has_all_memory */
+   1,				/* to_has_memory */
+   1,				/* to_has_stack */
+   1,				/* to_has_registers */
+   1,				/* to_has_execution */
+   NULL,				/* sections */
+   NULL,				/* sections_end */
+   OPS_MAGIC			/* to_magic */
+ };
+ 
+ 
  /* This was 5 seconds, which is a long time to sit and wait.
     Unless this is going though some terminal server or multiplexer or
     other form of hairy serial connection, I would think 2 seconds would
***************
*** 1879,1978 ****
    return memory_remove_breakpoint (addr, contents_cache);
  #endif /* REMOTE_BREAKPOINT */
  }
- 
- /* Define the target subroutine names */
- 
- static struct target_ops remote_ops =
- {
-   "remote",			/* to_shortname */
-   "Remote serial target in gdb-specific protocol",	/* to_longname */
-   "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
- Specify the serial device it is connected to (e.g. /dev/ttya).",  /* to_doc */
-   remote_open,			/* to_open */
-   remote_close,			/* to_close */
-   NULL,				/* to_attach */
-   remote_detach,		/* to_detach */
-   remote_resume,		/* to_resume */
-   remote_wait,			/* to_wait */
-   remote_fetch_registers,	/* to_fetch_registers */
-   remote_store_registers,	/* to_store_registers */
-   remote_prepare_to_store,	/* to_prepare_to_store */
-   remote_xfer_memory,		/* to_xfer_memory */
-   remote_files_info,		/* to_files_info */
-   remote_insert_breakpoint,	/* to_insert_breakpoint */
-   remote_remove_breakpoint,	/* to_remove_breakpoint */
-   NULL,				/* to_terminal_init */
-   NULL,				/* to_terminal_inferior */
-   NULL,				/* to_terminal_ours_for_output */
-   NULL,				/* to_terminal_ours */
-   NULL,				/* to_terminal_info */
-   remote_kill,			/* to_kill */
-   generic_load,			/* to_load */
-   NULL,				/* to_lookup_symbol */
-   NULL,				/* to_create_inferior */
-   remote_mourn,			/* to_mourn_inferior */
-   0,				/* to_can_run */
-   0,				/* to_notice_signals */
-   remote_thread_alive,		/* to_thread_alive */
-   0,				/* to_stop */
-   process_stratum,		/* to_stratum */
-   NULL,				/* to_next */
-   1,				/* to_has_all_memory */
-   1,				/* to_has_memory */
-   1,				/* to_has_stack */
-   1,				/* to_has_registers */
-   1,				/* to_has_execution */
-   NULL,				/* sections */
-   NULL,				/* sections_end */
-   OPS_MAGIC			/* to_magic */
- };
- 
- static struct target_ops extended_remote_ops =
- {
-   "extended-remote",			/* to_shortname */
-   "Extended remote serial target in gdb-specific protocol",/* to_longname */
-   "Use a remote computer via a serial line, using a gdb-specific protocol.\n\
- Specify the serial device it is connected to (e.g. /dev/ttya).",  /* to_doc */
-   extended_remote_open,			/* to_open */
-   remote_close,			/* to_close */
-   NULL,				/* to_attach */
-   remote_detach,		/* to_detach */
-   remote_resume,		/* to_resume */
-   remote_wait,			/* to_wait */
-   remote_fetch_registers,	/* to_fetch_registers */
-   remote_store_registers,	/* to_store_registers */
-   remote_prepare_to_store,	/* to_prepare_to_store */
-   remote_xfer_memory,		/* to_xfer_memory */
-   remote_files_info,		/* to_files_info */
- 
-   remote_insert_breakpoint,	/* to_insert_breakpoint */
-   remote_remove_breakpoint,	/* to_remove_breakpoint */
- 
-   NULL,				/* to_terminal_init */
-   NULL,				/* to_terminal_inferior */
-   NULL,				/* to_terminal_ours_for_output */
-   NULL,				/* to_terminal_ours */
-   NULL,				/* to_terminal_info */
-   remote_kill,			/* to_kill */
-   generic_load,			/* to_load */
-   NULL,				/* to_lookup_symbol */
-   extended_remote_create_inferior,/* to_create_inferior */
-   extended_remote_mourn,	/* to_mourn_inferior */
-   0,				/* to_can_run */
-   0,				/* to_notice_signals */
-   remote_thread_alive,		/* to_thread_alive */
-   0,				/* to_stop */
-   process_stratum,		/* to_stratum */
-   NULL,				/* to_next */
-   1,				/* to_has_all_memory */
-   1,				/* to_has_memory */
-   1,				/* to_has_stack */
-   1,				/* to_has_registers */
-   1,				/* to_has_execution */
-   NULL,				/* sections */
-   NULL,				/* sections_end */
-   OPS_MAGIC			/* to_magic */
- };
  
  /* Some targets are only capable of doing downloads, and afterwards they switch
     to the remote serial protocol.  This function provides a clean way to get
--- 1970,1975 ----
*** gdb-4.16.85/gdb/tracepoint.c.orig	Fri Jan  2 18:09:12 1998
--- gdb-4.16.85/gdb/tracepoint.c	Wed Feb 11 10:04:14 1998
***************
*** 1222,1229 ****
    case LOC_STATIC:
      offset = SYMBOL_VALUE_ADDRESS (sym); 
      if (info_verbose)
!       printf_filtered ("LOC_STATIC %s: collect %d bytes "
! 		       "at 0x%08x\n",
  		       SYMBOL_NAME (sym), len, offset);
      add_memrange (collect, 0, offset, len);	/* 0 == memory */
      break;
--- 1222,1228 ----
    case LOC_STATIC:
      offset = SYMBOL_VALUE_ADDRESS (sym); 
      if (info_verbose)
!       printf_filtered ("LOC_STATIC %s: collect %d bytes at 0x%08x\n",
  		       SYMBOL_NAME (sym), len, offset);
      add_memrange (collect, 0, offset, len);	/* 0 == memory */
      break;
***************
*** 1564,1571 ****
  	      if (tdp_actions)
  		{
  		  if (strlen (buf) + strlen (tdp_actions) >= sizeof (buf))
! 		    error ("Actions for tracepoint %d too complex; "
! 			   "please simplify.", t->number);
  		  strcat (buf, tdp_actions);
  		}
  	      if (stepping_actions)
--- 1563,1570 ----
  	      if (tdp_actions)
  		{
  		  if (strlen (buf) + strlen (tdp_actions) >= sizeof (buf))
! 		    error ("Actions for tracepoint %d too complex; please simplify.",
! 			   t->number);
  		  strcat (buf, tdp_actions);
  		}
  	      if (stepping_actions)
***************
*** 1572,1579 ****
  		{
  		  strcat (buf, "S");
  		  if (strlen (buf) + strlen (stepping_actions) >= sizeof (buf))
! 		    error ("Actions for tracepoint %d too complex; "
! 			   "please simplify.", t->number);
  		  strcat (buf, stepping_actions);
  		}
  	    }
--- 1571,1578 ----
  		{
  		  strcat (buf, "S");
  		  if (strlen (buf) + strlen (stepping_actions) >= sizeof (buf))
! 		    error ("Actions for tracepoint %d too complex; please simplify.",
! 			   t->number);
  		  strcat (buf, stepping_actions);
  		}
  	    }

-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de