Newsgroups: comp.sources.x
Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
From: pierre@la.tce.com (Pierre Willard)
Subject: v16i093: patch xxgdb 1.06 from 1.05, Patch1, Part01/01
Message-ID: <1992Feb22.183636.4583@msi.com>
Originator: dcmartin@fascet
Sender: dcmartin@msi.com (David C. Martin - Moderator)
Organization: Molecular Simulations, Inc.
References: <csx-16i093-olvwm-3.0@uunet.UU.NET>
Date: Sat, 22 Feb 1992 18:36:36 GMT
Approved: dcmartin@msi.com

Submitted-by: pierre@la.tce.com (Pierre Willard)
Posting-number: Volume 16, Issue 93
Archive-name: xxgdb/patch6
Patch-To: xxgdb: Volume 14, Issue 100


	XXGDB version 1.06 ( X window interface to the GDB debugger )
	-------------------------------------------------------------

Posting history :
January 91 : xxgdb 1.01 complete source files (Volume 11, Issue 42-55),
May 91 :     xxgdb 1.03 (patch from 1.01) (Volume 12, Issue 78),
July 91 :    xxgdb 1.04 (patch from 1.03) (Volume 13, Issue 80).
Sept 91 :    xxgdb 1.05 (patch from 1.04) (Volume 14, Issue 100).
Feb 92:	     xxgdb 1.06 (patch from 1.05) (Volume 16, Issue 93).

Please find in the following the differences from version
1.05 to 1.06.

Please post this complete message to comp.sources.x

NEW FEATURES OF VERSION 1.06  :

	Fix bug in creating more than 16 popup windows.
	Edit defs.h for X11R5.
	Remove xxgdb start-up error message with no file specified.
	Fix bug display arrays.
	Port to SysVr4 and miscellaneous improvements (Mark J. Hewitt)
	Fix bug for directories in filemenu (Norbert Kiesel)
	Fix bug pointers in arrays in popup windows.
	Add option -nx for xxgdb.
	Color for scrollbar is black in resource file.	
	Fix pb when no image file is loaded at startup (Tom Pavel)

TO PATCH XXGDB FROM VERSION 1.05 TO VERSION 1.06 :

	cd <original xxgdb 1.05 source directory>
	chmod +rw *
	patch < <patch_file>
	
THE FOLLOWING IS THE PATCH FILE FOR XXGDB 1.06 FROM XXGDB 1.05 :
diff -rc2 v1.05/Imakefile v1.06/Imakefile
*** v1.05/Imakefile	Tue May 14 09:00:24 1991
--- v1.06/Imakefile	Thu Oct 31 16:31:44 1991
***************
*** 8,11 ****
--- 8,13 ----
  #endif
  
+ CC = gcc -v
+ 
  #if defined(SunArchitecture)
  #if OSMajorVersion >= 4
diff -rc2 v1.05/Makefile v1.06/Makefile
*** v1.05/Makefile	Wed Aug 28 18:35:53 1991
--- v1.06/Makefile	Thu Oct 31 16:31:52 1991
***************
*** 42,46 ****
                 AR = ar cq
    BOOTSTRAPCFLAGS =
!                CC = gcc -v
  
           COMPRESS = compress
--- 42,46 ----
                 AR = ar cq
    BOOTSTRAPCFLAGS =
!                CC = cc
  
           COMPRESS = compress
***************
*** 227,230 ****
--- 227,232 ----
  
  DEFGDB =  -DGDB -g
+ 
+ CC = gcc -v
  
          DEFINES = -DSUNOS4 $(DEFGDB)
diff -rc2 v1.05/README v1.06/README
*** v1.05/README	Tue Jan 15 12:32:09 1991
--- v1.06/README	Mon Dec 23 16:49:06 1991
***************
*** 1,4 ****
  
! This is the source files for xxgdb v1.01 (and xdbx 2.1 patch level 2)
  ----------------------------------------------------------------------
  
--- 1,4 ----
  
! This is the source files for xxgdb v1.06 (and xdbx 2.1)
  ----------------------------------------------------------------------
  
diff -rc2 v1.05/XDbx.ad v1.06/XDbx.ad
*** v1.05/XDbx.ad	Thu May 30 17:51:39 1991
--- v1.06/XDbx.ad	Mon Nov 11 15:12:41 1991
***************
*** 8,12 ****
  *messageWindow.background:		snow2
  *commandWindow.background: 		snow2
! *Scrollbar.foreground: 			snow3
  
  *allowShellResize:              	True
--- 8,12 ----
  *messageWindow.background:		snow2
  *commandWindow.background: 		snow2
! *Scrollbar.foreground: 			black
  
  *allowShellResize:              	True
diff -rc2 v1.05/XXGDB_README v1.06/XXGDB_README
*** v1.05/XXGDB_README	Mon Sep 23 16:13:14 1991
--- v1.06/XXGDB_README	Thu Dec  5 13:10:02 1991
***************
*** 105,115 ****
  
  	Pierre Willard
! 	pierre@tce.com
  	Thomson Consumer Electronics, Inc.
  
! XXGDB version 1.05
  ------------------
  
  	>> SEE ALSO XDBX DOCUMENTATION <<
  	
  	XXGDB is a X window interface to the GDB debugger.
--- 105,116 ----
  
  	Pierre Willard
! 	pierre@la.tce.com
  	Thomson Consumer Electronics, Inc.
  
! XXGDB version 1.06
  ------------------
  
  	>> SEE ALSO XDBX DOCUMENTATION <<
+ 	>> SEE ALSO xxgdb.man DOCUMENTATION <<
  	
  	XXGDB is a X window interface to the GDB debugger.
***************
*** 255,259 ****
  				Fix bug in search window.
  				Update for gdb 4.0 (PW)(SH).
! 				
  
  Acknowledgement
--- 256,270 ----
  				Fix bug in search window.
  				Update for gdb 4.0 (PW)(SH).
! 	1.06	October 1991
! 				Fix bug in creating more than 16 popup windows.
! 				Edit defs.h for X11R5.
! 				Remove xxgdb start-up error message with no file specified.
! 				Fix bug display arrays.
! 				Port to SysVr4 and miscellaneous improvements (MJH)
! 				Fix bug for directories in filemenu (Norbert Kiesel)
! 				Fix bug pointers in arrays in popup windows.
! 				Add option -nx for xxgdb.
! 				Color for scrollbar is black in resource file.	
! 				Fix pb when no image file is loaded at startup (Tom Pavel)
  
  Acknowledgement
***************
*** 265,268 ****
--- 276,280 ----
  	generic BSD machines.
  	Thanks to Stephan Heuer (SH) for some updates to gdb 4.0.
+ 	Thanks to Mark J. Hewitt (MJH) for porting to SysVr4.
  
  	
diff -rc2 v1.05/calldbx.c v1.06/calldbx.c
*** v1.05/calldbx.c	Thu Jul 18 17:44:08 1991
--- v1.06/calldbx.c	Thu Oct 31 13:56:17 1991
***************
*** 81,89 ****
  
  #ifdef SYSV 
  #ifdef sco
  #  include	<sys/fcntl.h>
! #endif
! #endif
  
  FILE   	    	*dbxfp = NULL;		/* file pointer to dbx */
  int    	    	dbxpid = 0;		/* dbx process id */
--- 81,101 ----
  
  #ifdef SYSV 
+ #ifdef SVR4				/* (MJH) Need to use STREAMS pseudo-ttys */
+ #define MASTER_CLONE "/dev/ptmx"
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/stropts.h>
+ #include <fcntl.h>
+ #include <stdio.h>
+ #include <signal.h>
+ #else
  #ifdef sco
  #  include	<sys/fcntl.h>
! #endif /* sco */
! #endif /* SVR4 */
! #endif /* SYSV */
  
+ extern char *progname;		/* (MJH) */
+ 
  FILE   	    	*dbxfp = NULL;		/* file pointer to dbx */
  int    	    	dbxpid = 0;		/* dbx process id */
***************
*** 94,99 ****
--- 106,113 ----
  
  static int	dbxInputId;		/* dbx input id */
+ #ifndef SVR4				/* (MJH) */
  static char 	pty[11] = "/dev/pty??";	/* master side of pseudo-terminal */
  static char 	tty[11] = "/dev/tty??";	/* slave side of pseudo-terminal */
+ #endif /* SVR4 */
  extern char	*dbxprompt;
  
***************
*** 105,109 ****
  static int open_master()
  {
!     int  i, master; 
      char c;
  
--- 119,132 ----
  static int open_master()
  {
!     int master;
!     
! #ifdef SVR4				/* (MJH) Use STREAMS */
! 
!     if((master = open(MASTER_CLONE, O_RDWR)) < 0)
! 	perror(MASTER_CLONE);
!     else
! 	return master;
! #else
!     int  i;
      char c;
  
***************
*** 123,126 ****
--- 146,150 ----
  	}
  #endif
+ #endif /* SVR4 */
  
  #ifdef GDB
***************
*** 132,145 ****
  }
  
! static int open_slave()
  {
      int slave;
  
      tty[8] = pty[8];
      tty[9] = pty[9];
!     if ((slave = open(tty, O_RDWR)) >= 0)
! 	return (slave);
!     fprintf(stderr, "open: cannot open slave pty %s", tty);
!     exit(1);
  }
  
--- 156,192 ----
  }
  
! /*ARGSUSED*/
! static int open_slave(master)
!     int master;
  {
      int slave;
  
+ #ifdef SVR4				/* (MJH) */
+     char *slave_name;
+     extern char *ptsname(int master);
+     void (*handler)();
+ 
+     if((handler = signal(SIGCHLD, SIG_DFL) != SIG_ERR) &&
+        (grantpt(master) == 0) &&
+        (signal(SIGCHLD, handler) == SIG_DFL) &&
+        (unlockpt(master) == 0) &&
+        ((slave_name = ptsname(master)) != NULL) &&
+        ((slave = open(slave_name, O_RDWR)) >= 0) &&
+        (ioctl(slave, I_PUSH, "ptem") >= 0) &&
+        (ioctl(slave, I_PUSH, "ldterm") >= 0))
+ 	return slave;
+     perror("Pseudo-tty slave");
+     fprintf(stderr, "open: cannot open slave pty %s", slave_name);
+     exit(1);
+ #else
      tty[8] = pty[8];
      tty[9] = pty[9];
!     if ((slave = open(tty, O_RDWR)) < 0)
! 	    {
! 		perror(tty);
! 		exit(1);
! 	    }
!     return slave;
! #endif /* SVR4 */
  }
  
***************
*** 190,193 ****
--- 237,243 ----
  	sprintf(dbxprompt, "(%s) ", debugger);
      }
+     
+ 	if (debug)
+ 		fprintf(stderr,"debugger=\"%s\"\nprompt=\"%s\"\n",debugger,dbxprompt);
    
      /*
***************
*** 196,210 ****
       * controlling tty.
       */
!     if ((fd = open("/dev/tty", O_RDWR)) > 0) {
  #ifndef SYSV 
! 	ioctl(fd, TIOCNOTTY, 0);
  #endif /* SYSV */
! 	close(fd);
!     }
  
      master = open_master();
      
! #ifndef SYSV 
!     slave = open_slave();
  #endif
  
--- 246,269 ----
       * controlling tty.
       */
! 
! #if defined(SVR4)	/* (MJH) */
!     if ((tcgetsid(0) != tcgetpgrp(0)) && /* Check if fore- or back-ground  */
! 	(fd = open("/dev/tty", O_RDWR|O_NDELAY)) > 0) {
!   	ioctl(fd, TIOCNOTTY, 0);
!   	close(fd);
!   	}
! #else	/* not SVR4 */
! 	if ((fd = open("/dev/tty", O_RDWR)) > 0) {
  #ifndef SYSV 
!   	ioctl(fd, TIOCNOTTY, 0);
  #endif /* SYSV */
!   	close(fd);
!   	}
! #endif	/* SVR4 */
  
      master = open_master();
      
! #if defined(SVR4) || !defined(SYSV)
!     slave = open_slave(master);
  #endif
  
***************
*** 211,219 ****
      dbxpid = fork();
      if (dbxpid == -1) {
! #ifdef GDB
! 	perror("xxgdb error: cannot fork process");
! #else
! 	perror("xdbx error: cannot fork process");
! #endif
  	exit(1);
      }
--- 270,275 ----
      dbxpid = fork();
      if (dbxpid == -1) {
! 	sprintf(errmsg, "%s error: Cannot fork %s\n", progname, debugger);	/* (MJH) */
! 	perror(errmsg);
  	exit(1);
      }
***************
*** 227,231 ****
--- 283,291 ----
  	 *	    register dbx input with X
  	 */
+ 
+ #if defined(SVR4) || !defined(SYSV)		/* (MJH) */
  	close(slave);
+ #endif /* SYSV */
+ 
  	close(0);
  	close(1);
***************
*** 232,236 ****
  	fcntl(master, F_SETFL, FNDELAY);
  	
! 	dbxfp = fdopen(master, "r+");
      
      /* (PW)10APR91 : I use 'setvbuf' instead of 'setlinebuf',
--- 292,300 ----
  	fcntl(master, F_SETFL, FNDELAY);
  	
! 	if((dbxfp = fdopen(master, "r+")) == NULL)	/* (MJH) */
! 	{
! 	    perror("Associating stdio stream with pty master");
! 	    exit(1);
! 	}
      
      /* (PW)10APR91 : I use 'setvbuf' instead of 'setlinebuf',
***************
*** 245,249 ****
     
  #ifdef SYSV
! 	setvbuf(dbxfp, dbxfbuf, _IONBF, BUFSIZ); */
  #else
  #ifdef BSD
--- 309,313 ----
     
  #ifdef SYSV
! 	setvbuf(dbxfp, dbxfbuf, _IONBF, BUFSIZ);
  #else
  #ifdef BSD
***************
*** 265,271 ****
  	 */
        
! #ifdef SYSV 
          setpgrp();
!         slave = open_slave();
  #endif
  	close(master);
--- 329,335 ----
  	 */
        
! #if defined(SYSV) && !defined(SVR4)		/* (MJH) */
          setpgrp();
!         slave = open_slave(master);
  #endif
  	close(master);
***************
*** 317,327 ****
  #endif /* not SYSV */
  
  	argv[0] = debugger;
  	execvp(debugger, argv);
! #ifdef GDB
! 	sprintf(errmsg, "xxgdb error: cannot exec %s", debugger);
! #else
! 	sprintf(errmsg, "xdbx error: cannot exec %s", debugger);
! #endif
  	perror(errmsg);
  	exit(1);
--- 381,392 ----
  #endif /* not SYSV */
  
+ #ifdef SVR4						/* (MJH) */
+ 	tcsetpgrp(0, tcgetpgrp(0));
+ 	tcsetpgrp(0, getpid());
+ #endif /* SVR4 */
+ 
  	argv[0] = debugger;
  	execvp(debugger, argv);
! 	sprintf(errmsg, "%s error: cannot exec %s", progname, debugger);
  	perror(errmsg);
  	exit(1);
diff -rc2 v1.05/command.c v1.06/command.c
*** v1.05/command.c	Mon Sep 23 13:59:50 1991
--- v1.06/command.c	Thu Oct 31 16:31:23 1991
***************
*** 339,345 ****
      XtDestroyApplicationContext(app_context);
      kill(dbxpid, SIGKILL);
! #ifdef SYSV 
!     waitpid(&status, NULL, WNOHANG);
  #else
      wait3(&status, WNOHANG, NULL);
  #endif /* SYSV */
--- 339,349 ----
      XtDestroyApplicationContext(app_context);
      kill(dbxpid, SIGKILL);
! #ifdef SYSV
! #ifdef SVR4 
! 	status = waitpid(dbxpid, (int *)0, WNOHANG);	/* (MJH) */
  #else
+ 	waitpid(&status, NULL, WNOHANG);
+ #endif	/* SVR4 */
+ #else	/* not SYSV */
      wait3(&status, WNOHANG, NULL);
  #endif /* SYSV */
***************
*** 818,822 ****
--- 822,830 ----
      }
  
+ #ifdef GDB
  	write_dbx_available();
+ #else
+     write_dbx(command);
+ #endif /* GDB */
  }
  
diff -rc2 v1.05/datadpy.c v1.06/datadpy.c
*** v1.05/datadpy.c	Fri Sep 20 14:34:56 1991
--- v1.06/datadpy.c	Thu Oct 31 10:23:51 1991
***************
*** 207,210 ****
--- 207,225 ----
      p = dataDpy->buf + dataDpy->linepos[fromLine];
  
+ #ifdef GDB	/* (PW)  we now use a new parser which should work better,
+ 	in particular for arrays */
+ 	{
+ 	char *parse_gdb_print();
+ 	char *newcommand;
+ 	
+     newcommand = parse_gdb_print(command, dataDpy->buf, dataDpy->buf + left );
+     if (*newcommand)
+     	{
+ 		PopupMode = True;
+     	query_gdb(newcommand, PARSE_ON | ECHO_OFF | FILTER_OFF);
+     	}
+     }
+ #else	/* not GDB */
+ 
      if (re_match(dataPattern[D_FIELD].buf, p, strlen(p), 0, &regs) >= 0) {
  	r = dataPattern[D_FIELD].reg_token[TK_POINTER];
***************
*** 240,243 ****
--- 255,259 ----
  	else
  	    strcpy(name, field[0]);
+ 	    
  	for (i=1; field[i]; i++) {
  	    strcat(name, ".");
***************
*** 250,255 ****
  #else
  	query_dbx(command);
! #endif
      }
  }
  
--- 266,272 ----
  #else
  	query_dbx(command);
! #endif	/* GDB */
      }
+ #endif /* GDB */
  }
  
***************
*** 632,637 ****
  
      /* Searches the table for an unused or empty slot */
!     for (i=0; dataDpyTable && dataDpyTable[i] && dataDpyTable[i]->state == USED 
! 	      && i < dataDpyTableSize; i++);
      if (i == dataDpyTableSize) {			/* Table full */
  	dataDpyTableSize += ADD_SIZE;
--- 649,655 ----
  
      /* Searches the table for an unused or empty slot */
!     /* (PW)17OCT91 : test i < dataDpyTableSize first (else segment violation)*/
!     for (i=0; dataDpyTable && i < dataDpyTableSize && dataDpyTable[i]
!     	&& dataDpyTable[i]->state == USED ; i++);
      if (i == dataDpyTableSize) {			/* Table full */
  	dataDpyTableSize += ADD_SIZE;
***************
*** 674,675 ****
--- 692,952 ----
      XUndefineCursor(display, XtWindow(toplevel));
  }
+ 
+ 
+ #ifdef GDB
+ #include <string.h>
+ 
+ #define GOODCHARNAME(c)							\
+ 			(	(((c) >='a') &&  ((c) <= 'z'))	\
+ 			||	(((c) >='A') &&  ((c) <= 'Z'))	\
+ 			||	(((c) >='0') &&  ((c) <= '9'))	\
+ 			||	((c) == '_')					\
+ 			||	((c) == '$')					\
+ 			)
+ 
+ static char *result;		/* start of result buffer */
+ static int result_index;	/* current index in result buffer */
+ static char *start_txt;		/* pointer 1st char of output to parse */
+ static char *curr_txt;		/* current pointer in output to parse */
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Store a character into the buffer.										|
+ |																			|
+ |	Note that characters are added to the buffer RIGHT TO LEFT !			|
+ |	This is because we parse the output from right to left.					|
+ |																			|
+ |	If the result buffer is full, we set result to "".						|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ static void add_char(c)
+ char c;
+ {
+ int i;
+ 
+ 	if (result_index == 0)	/* buffer full */
+ 		{
+ 		*result = 0;
+ 		return;
+ 		}
+ 	
+ 	result_index--;
+ 	*(result+result_index) = c;
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Store a string into the buffer.											|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ static void add_string(s)
+ char *s;
+ {
+ int nbchar;
+ 
+ 	nbchar = strlen(s);
+ 	
+ 	/* copy number from last digit */
+ 	
+ 	while (nbchar > 0)
+ 		add_char(*(s + (--nbchar)));
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Store a number into the buffer.											|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ static void add_num(number)
+ int number;
+ {
+ char tmpnum[128];
+ 
+ 	sprintf(tmpnum,"%d",number);
+ 	add_string(tmpnum);
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Init buffer.															|
+ |																			|
+ |	Store a NULL character (as end of string).								|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ static void init_result(buffer,buflen)
+ char *buffer;
+ int buflen;
+ {
+ 	result = buffer;
+ 	result_index = buflen;
+ 	add_char(0);			/* end result by null char */
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Store the current variable or struct name.								|
+ |																			|
+ |	input :		curr_txt points to '=' character,							|
+ |				start_txt points to beginning of the parse string.			|
+ |																			|
+ |	output :	curr_txt points to character before 1st character of		|
+ |					name.													|
+ |																			|
+ |	Note : we have to test for the beginning of the parse string,			|
+ |	because add_name() is called also for adding the "$n" name				|
+ |	of the gdb output.														|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ static void add_name ()
+ {
+ 	curr_txt--;								/* point before '=' */
+ 	while (*curr_txt == ' ') curr_txt--;	/* skip spaces */
+ 	
+ 	/* loop over name */
+ 	while ((curr_txt >= start_txt) && GOODCHARNAME(*curr_txt))
+ 		add_char(*curr_txt--);
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Skip all previous characters until corresponding " or ' character.		|
+ |																			|
+ |	input : curr_txt points before ' or " character							|
+ |																			|
+ |	output : curr_txt points before corresponding ' or " character.			|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ void search_char(c)
+ char c;
+ {
+ 	while(1)
+ 		{
+ 		while(c != *(curr_txt--));
+ 		
+ 		/* make sure there is not a '\' just before */
+ 		
+ 		if (*curr_txt != '\\')
+ 			return;
+ 		}
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Skip all previous characters until previous corresponding '{'.			|
+ |	All "{...}" sequences are skip.											|
+ |	Return the array item number (if applicable)							|
+ |																			|
+ |	input :		curr_txt points to string.									|
+ |																			|
+ |	output :	curr_txt points to character before '{'						|
+ |				return number of commas										|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ static int skip_level()
+ {
+ int nbcommas;
+ char c;
+ 
+ 	nbcommas = 0;
+ 	
+ 	while(1)
+ 		{
+ 		switch (c = *(curr_txt--))
+ 			{
+ 			case '{' :
+ 				return nbcommas;
+ 			
+ 			case ',' :
+ 				nbcommas++;
+ 				break;
+ 				
+ 			case '}' :
+ 				skip_level();
+ 				break;
+ 			
+ 			case '"' :
+ 			case '\'' :
+ 				search_char(c);
+ 				break;
+ 				
+ 			default:
+ 				break;
+ 			}
+ 		}
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Function to parse an output of a gdb print from							|
+ |	a pointer (0x...) and return a command line to							|
+ |	print *(0x...)															|
+ |																			|
+ |	input : command line pointer (LINESIZ size),							|
+ |			pointer print output,											|
+ |			pointer 0x...													|
+ |																			|
+ |	output : command line (stored RIGHT justified in commandline)			|
+ |																			|
+ |	example																	|
+ |																			|
+ |		start = "$1 = { (struct foo *) 0x1224}"								|
+ |		current points to 0x1224 in start,									|
+ |																			|
+ |		commandline = "print *($1)"											|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ char *parse_gdb_print (commandline, start, current)
+ char *commandline;
+ char *start;
+ char *current;
+ {
+ char *begin;
+ 
+ 	start_txt = start;		/* in static variables */
+ 	curr_txt = current;
+ 
+ 	begin = strchr(start,'=');	/* find '=' in "$n =" */
+ 	
+ 	if (!begin)
+ 		return;
+ 		
+ 	init_result(commandline,LINESIZ);
+ 
+ 	add_string(")\n");
+ 	
+ 	while (begin <= curr_txt)
+ 		{
+ 		switch (*curr_txt)
+ 			{
+ 			case '=':
+ 				add_name();
+ 				
+ 				/* stop now if we just parsed the '=' in "$n =" */
+ 				if (curr_txt >= start_txt)
+ 					{
+ 					add_char('.');
+ 					skip_level();
+ 					}
+ 				break;
+ 			
+ 			case ',':
+ 			case '{':
+ 				add_char(']');
+ 				add_num(skip_level());
+ 				add_char('[');
+ 				break;
+ 		
+ 			default:
+ 				curr_txt--;
+ 			}
+ 		}
+ 		
+ 	add_string("print *(");
+ 	
+ 	if (debug)
+ 		fprintf(stderr,"datadpy=%s\n",result+result_index);
+ 	
+ 	return result+result_index;
+ }
+ 
+ #endif /* GDB */
diff -rc2 v1.05/defs.h v1.06/defs.h
*** v1.05/defs.h	Fri Sep 20 16:04:42 1991
--- v1.06/defs.h	Thu Oct 31 16:00:52 1991
***************
*** 88,91 ****
--- 88,92 ----
  #include <X11/cursorfont.h>
  
+ #if XtVersion < 11005
  /* incompatibility of header file with X11R4 documentation */
  #define XawChainTop	XtChainTop
***************
*** 93,96 ****
--- 94,98 ----
  #define XawChainLeft	XtChainLeft
  #define XawChainRight	XtChainRight
+ #endif
  
  #ifndef AssignMax
***************
*** 150,153 ****
--- 152,157 ----
      String    db_name;  	/* name for dbx child */
      String    db_prompt;	/* prompt for dbx child */
+ 
+ 	Boolean   nx;			/* if True, do not execute gdbinit */
  
      Pixel     stop_color;	/* color of stop sign */
diff -rc2 v1.05/dialog.c v1.06/dialog.c
*** v1.05/dialog.c	Mon Sep 23 14:36:07 1991
--- v1.06/dialog.c	Thu Oct 31 16:31:22 1991
***************
*** 207,210 ****
--- 207,211 ----
      if (Prompt)
      	{
+ #ifdef GDB
  		/* When we send \n to gdb, it executes the last command,
  		so better tell xxgdb what gdb is doing */
***************
*** 218,221 ****
--- 219,223 ----
  			AppendDialogText(gdb_command);
  			}
+ #endif /* GDB */
  		send_command (s);
  		}
***************
*** 268,272 ****
--- 270,278 ----
  {
      FalseSignal = TRUE;
+ #ifdef SVR4		/* (MJH) */		/* (PW) is this true for all SYSV ? */
+     kill(-(dbxpid), SIGQUIT);
+ #else
      killpg(dbxpid, SIGQUIT);
+ #endif /* SVR4 */
  }
  
diff -rc2 v1.05/filemenu.c v1.06/filemenu.c
*** v1.05/filemenu.c	Mon Sep 23 13:51:58 1991
--- v1.06/filemenu.c	Wed Oct 30 09:12:52 1991
***************
*** 152,156 ****
--- 152,166 ----
      sprintf(command, "cd %s\n", store);
  #ifdef GDB
+    /* because silly gdb 4.0 displays nothing with cd command when
+       confirm is on (possibly a gdb bug) , I just reset confirm to on
+       just for this command !. */
+    
+    if (new_gdb4()) 
+      query_gdb("set confirm on\n",	PARSE_OFF | ECHO_OFF | FILTER_OFF);
+    
      query_gdb(command, PARSE_ON | ECHO_OFF | FILTER_OFF);
+     
+    if (new_gdb4()) /* reset confirm to off */
+      query_gdb("set confirm off\n",	PARSE_OFF | ECHO_OFF | FILTER_OFF);
  #else
      query_dbx(command);
diff -rc2 v1.05/gdb_handler.c v1.06/gdb_handler.c
*** v1.05/gdb_handler.c	Mon Sep 23 16:00:42 1991
--- v1.06/gdb_handler.c	Thu Dec  5 13:10:28 1991
***************
*** 156,160 ****
   	query_gdb("list ,main\n", PARSE_ON | ECHO_OFF | FILTER_ON); 
  
!     if (LoadCurrentFile() == 0)
      	{
  		arrow.line = 0;			/* clear arrow sign */
--- 156,161 ----
   	query_gdb("list ,main\n", PARSE_ON | ECHO_OFF | FILTER_ON); 
  
! 	if (displayedFile && LoadCurrentFile() == 0)
! 		/* Only if there is a current displayedFile (pavel 4-Dec-1991) */
      	{
  		arrow.line = 0;			/* clear arrow sign */
***************
*** 550,554 ****
  			}
  			
! 		close(fp);
  		}
  }
--- 551,555 ----
  			}
  			
! 		fclose(fp);
  		}
  }
diff -rc2 v1.05/gdb_parser.c v1.06/gdb_parser.c
*** v1.05/gdb_parser.c	Mon Sep 23 15:06:55 1991
--- v1.06/gdb_parser.c	Fri Oct 25 18:37:19 1991
***************
*** 548,557 ****
  		p = p2;						/* skip display text */
  					
! 		if (begin_struct)
  			{
! 			/* try to find end of display structure */
  			
! 			if (p1 = strstr(p,"\n}\n"))
! 				p = p1 + strlen("\n}\n");
  			}
  		}
--- 548,569 ----
  		p = p2;						/* skip display text */
  					
! 		if (begin_struct)	/* skip the whole data displayed */
  			{
! 			do				/* find the last '}' */
! 				{
! 				switch(*(p++))
! 					{
! 					case '{':
! 						begin_struct++;
! 						break;
! 					case '}':
! 						begin_struct--;
! 						break;
! 					}
! 				}
! 			while (begin_struct);
  			
! 			/* now skip until end of line */
! 			while (*(p++) != '\n');
  			}
  		}
diff -rc2 v1.05/gdb_regex.h v1.06/gdb_regex.h
*** v1.05/gdb_regex.h	Mon Sep 23 15:07:04 1991
--- v1.06/gdb_regex.h	Fri Oct 25 18:37:07 1991
***************
*** 287,291 ****
  #ifndef NeXT  /* if standard GDB */
      /* exec with Message after */
!     {"\\(.*\n\\)*\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\):0x.+\n\\([ ]*[^0-9\n].*\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
       NULL,
       {6, -1, -1, 3, 2, 7}
--- 287,291 ----
  #ifndef NeXT  /* if standard GDB */
      /* exec with Message after */
!     {"\\(.*\n\\)*\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\):0x.+\n\\([ ]*[^0-9\n].*\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*[ }]*}\n\\)?\\)*\\)",
       NULL,
       {6, -1, -1, 3, 2, 7}
***************
*** 292,296 ****
      },
      /* exec with Message before */
!     {"\\(.*\n\\)*\\([ ]*[^ \n].*\n\\)\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\):0x.+\n\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
       NULL,
       {2, -1, -1, 4, 3, 7}	
--- 292,296 ----
      },
      /* exec with Message before */
!     {"\\(.*\n\\)*\\([ ]*[^ \n].*\n\\)\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\):0x.+\n\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*[ }]*}\n\\)?\\)*\\)",
       NULL,
       {2, -1, -1, 4, 3, 7}	
***************
*** 297,301 ****
      },
      /* exec without Message */
!     {"\\(.*\n\\)*\032\032\\(\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\):0x.+\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
       NULL,
       {2, -1, -1, 4, 3, 7}
--- 297,301 ----
      },
      /* exec without Message */
!     {"\\(.*\n\\)*\032\032\\(\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\):0x.+\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*[ }]*}\n\\)?\\)*\\)",
       NULL,
       {2, -1, -1, 4, 3, 7}
***************
*** 304,308 ****
  #else  /* NeXT is a special case : same as standard except that ":0x.+" are removed. */
      /* exec with Message after */
!     {"\\(.*\n\\)*\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\)\n\\([ ]*[^0-9\n].*\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
       NULL,
       {6, -1, -1, 3, 2, 7}
--- 304,308 ----
  #else  /* NeXT is a special case : same as standard except that ":0x.+" are removed. */
      /* exec with Message after */
!     {"\\(.*\n\\)*\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\)\n\\([ ]*[^0-9\n].*\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*[ }]*}\n\\)?\\)*\\)",
       NULL,
       {6, -1, -1, 3, 2, 7}
***************
*** 309,313 ****
      },
      /* exec with Message before */
!     {"\\(.*\n\\)*\\([ ]*[^ \n].*\n\\)\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\)\n\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
       NULL,
       {2, -1, -1, 4, 3, 7}	
--- 309,313 ----
      },
      /* exec with Message before */
!     {"\\(.*\n\\)*\\([ ]*[^ \n].*\n\\)\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\)\n\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*[ }]*}\n\\)?\\)*\\)",
       NULL,
       {2, -1, -1, 4, 3, 7}	
***************
*** 314,318 ****
      },
      /* exec without Message */
!     {"\\(.*\n\\)*\032\032\\(\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\)\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
       NULL,
       {2, -1, -1, 4, 3, 7}
--- 314,318 ----
      },
      /* exec without Message */
!     {"\\(.*\n\\)*\032\032\\(\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\)\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*[ }]*}\n\\)?\\)*\\)",
       NULL,
       {2, -1, -1, 4, 3, 7}
***************
*** 367,373 ****
      },
      /* info line */
!     {"\\(Line \\(number \\)?[0-9]+ \\(of\\|is out of range for\\) \"\\([^ \n]+\\)\".*\\)\n",
       NULL,
!      {-1, -1, -1, -1, 4, -1}
      },
      /* print */
--- 367,373 ----
      },
      /* info line */
!     {"\\(\\(Line \\(number \\)?[0-9]+ \\(of\\|is out of range for\\) \"\\([^ \n]+\\)\".*\\)\\|\\(No symbol table is loaded.*\\)\\|\\(No source file specified.*\\)\\)\n",
       NULL,
!      {-1, -1, -1, -1, 5, -1}
      },
      /* print */
***************
*** 402,406 ****
      },
      /* info display */
!     {"\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)\\(\\(.*\n\\)*\\)",
       NULL,
       {  5, -1, -1, -1, -1, 1}
--- 402,406 ----
      },
      /* info display */
!     {"\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*[ }]*}\n\\)?\\)*\\)\\(\\(.*\n\\)*\\)",
       NULL,
       {  5, -1, -1, -1, -1, 1}
diff -rc2 v1.05/patchlevel.h v1.06/patchlevel.h
*** v1.05/patchlevel.h	Wed Sep 11 16:53:48 1991
--- v1.06/patchlevel.h	Mon Dec 23 16:53:12 1991
***************
*** 1 ****
! #define PATCHLEVEL 3
--- 1 ----
! #define PATCHLEVEL 4
diff -rc2 v1.05/regex.c v1.06/regex.c
*** v1.05/regex.c	Tue Apr  2 08:58:56 1991
--- v1.06/regex.c	Tue Oct 29 08:57:04 1991
***************
*** 123,126 ****
--- 123,131 ----
  #endif
  
+ #ifdef __STDC__
+ static int bcmp_translate (unsigned char *, unsigned char *s2,
+                            int len, unsigned char *translate);	/* (MJH) */
+ #endif /* __STDC__ */
+ 
  #ifdef emacs
  
***************
*** 1202,1206 ****
--- 1207,1219 ----
  		  mcnt = dend2 - d2;
  		/* Compare that many; failure if mismatch, else skip them. */
+ #ifndef __STDC__	/* (MJH) */
  		if (translate ? bcmp_translate (d, d2, mcnt, translate) : bcmp (d, d2, mcnt))
+ #else
+ 		if (translate ? bcmp_translate ((unsigned char *)d,
+ 						(unsigned char *)d2,
+ 						mcnt,
+ 						translate)
+ 		    : bcmp (d, d2, mcnt))
+ #endif	/* __STDC__ */
  		  goto fail;
  		d += mcnt, d2 += mcnt;
diff -rc2 v1.05/signals.c v1.06/signals.c
*** v1.05/signals.c	Tue Apr  2 08:59:04 1991
--- v1.06/signals.c	Tue Oct 29 09:44:03 1991
***************
*** 83,87 ****
--- 83,91 ----
       */
  #ifdef SYSV 
+ #ifdef SVR4
+ 	waitpid((pid_t)0, &status, WNOHANG|WUNTRACED);	/* (MJH) */
+ #else
      waitpid(&status, NULL , WNOHANG|WUNTRACED);
+ #endif /* SVR4 */
  #else
      wait3(&status, WNOHANG|WUNTRACED, NULL);
diff -rc2 v1.05/xdbx.c v1.06/xdbx.c
*** v1.05/xdbx.c	Wed Sep 11 16:57:35 1991
--- v1.06/xdbx.c	Mon Dec 23 16:50:23 1991
***************
*** 72,76 ****
  
  #ifdef GDB
! #define XGDBVERSION	"1.05"
  #endif
  
--- 72,76 ----
  
  #ifdef GDB
! #define XGDBVERSION	"1.06"
  #endif
  
***************
*** 87,90 ****
--- 87,92 ----
  #define Offset(field) (XtOffset(XdbxResources *, field))
  
+ char *progname;
+ 
  char            cwd[MAXPATHLEN];        /* The current working directory */
  XtAppContext  	app_context; 		/* application context */
***************
*** 112,115 ****
--- 114,120 ----
  	Offset(db_prompt), XtRImmediate, (caddr_t)NULL},
  
+     {"nx", "nx", XtRBoolean, sizeof(Boolean), 
+ 	Offset(nx), XtRImmediate, (caddr_t)False},
+ 
      {"delimiters", "Delimiters", XtRString, sizeof(char *), 
  	Offset(delimiters), XtRImmediate, (caddr_t)NULL},
***************
*** 204,207 ****
--- 209,213 ----
  #ifdef GDB
      {"-d",	"includeDir",	XrmoptionSepArg, NULL},
+     {"-nx",	"nx",			XrmoptionNoArg, "True"},
  #else
      {"-r",	"dbxopt_r",	XrmoptionNoArg, "True"},
***************
*** 290,296 ****
  
  #ifdef GDB
!     strcpy(xdbxinit, ".gdbinit");
!     if (access(xdbxinit, R_OK) == -1) {
!     	sprintf(xdbxinit, "%s/%s", (char *) getenv("HOME"), ".gdbinit");
  #else
      strcpy(xdbxinit, ".dbxinit");
--- 296,311 ----
  
  #ifdef GDB
! 	if (app_resources.nx)
! 		strcpy(xdbxinit, "");
! 	else
! 		{
! 	    strcpy(xdbxinit, ".gdbinit");
! 	    if (access(xdbxinit, R_OK) == -1)
! 	    	{
! 	    	sprintf(xdbxinit, "%s/%s", (char *) getenv("HOME"), ".gdbinit");
!     		if (access(xdbxinit, R_OK) == -1)
! 	    		strcpy(xdbxinit, "");
! 	    	}
!     	}
  #else
      strcpy(xdbxinit, ".dbxinit");
***************
*** 297,305 ****
      if (access(xdbxinit, R_OK) == -1) {
      	sprintf(xdbxinit, "%s/%s", (char *) getenv("HOME"), ".dbxinit");
! #endif	/* not GDB */
!     	if (access(xdbxinit, R_OK) == -1) {
! 	    strcpy(xdbxinit, "");
! 	}
      }
      source_init();
      signs_init();
--- 312,319 ----
      if (access(xdbxinit, R_OK) == -1) {
      	sprintf(xdbxinit, "%s/%s", (char *) getenv("HOME"), ".dbxinit");
!     	if (access(xdbxinit, R_OK) == -1)
! 	    	strcpy(xdbxinit, "");
      }
+ #endif	/* not GDB */
      source_init();
      signs_init();
***************
*** 360,369 ****
       *  instead.
       */
-      /* for GDB, just use option -nx */
       
-     if (strcmp(xdbxinit, "")) {		/* .dbxinit or ~/.dbxinit exists */
  #ifdef GDB
  	dbxargv[i++] = "-nx";
  #else
  #ifdef BSD
  	dbxargv[i++] = "-c";
--- 374,383 ----
       *  instead.
       */
       
  #ifdef GDB
+      /* for GDB, always use option -nx */
  	dbxargv[i++] = "-nx";
  #else
+     if (strcmp(xdbxinit, "")) {		/* .dbxinit or ~/.dbxinit exists */
  #ifdef BSD
  	dbxargv[i++] = "-c";
***************
*** 372,377 ****
  #endif
  	dbxargv[i++] = (char *) mktemp(temp);
- #endif	/* not GDB */
      }
      if (app_resources->startup) {	/* overwrites dbxinit */
  	Tstartup = False;
--- 386,391 ----
  #endif
  	dbxargv[i++] = (char *) mktemp(temp);
      }
+ #endif	/* not GDB */
      if (app_resources->startup) {	/* overwrites dbxinit */
  	Tstartup = False;
***************
*** 399,403 ****
  {
      char 	**dbxargv;
! 
  #ifdef SYSV 
      getcwd((char *)cwd, MAXPATHLEN);
--- 413,420 ----
  {
      char 	**dbxargv;
!     char *p;
!     
!     progname = argv[0];			/* (MJH) */
!         
  #ifdef SYSV 
      getcwd((char *)cwd, MAXPATHLEN);

-- 
--
Molecular Simulations, Inc.			mail: dcmartin@msi.com
796 N. Pastoria Avenue				uucp: uunet!dcmartin
Sunnyvale, California 94086			at&t: 408/522-9236
