Path: uunet!sun-barr!cronkite.Central.Sun.COM!exodus!la.tce.com
From: pierre@la.tce.com (Pierre Willard)
Newsgroups: comp.sources.x
Subject: v14i100: xxgdb, Patch3, Part01/01
Message-ID: <22139@exodus.Eng.Sun.COM>
Date: 25 Oct 91 16:31:44 GMT
References: <csx-14i100-xxgdb@uunet.UU.NET>
Sender: news@exodus.Eng.Sun.COM
Lines: 1867
Approved: argv@sun.com

Submitted-by: pierre@la.tce.com (Pierre Willard)
Posting-number: Volume 14, Issue 100
Archive-name: xxgdb/patch3
Patch-To: xxgdb: Volume 11, Issue 42-55
Patch-To: xxgdb: Volume 12, Issue 78
Patch-To: xxgdb: Volume 13, Issue 80


	XXGDB version 1.05 ( 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).

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

Please post this complete message to comp.sources.x

NEW FEATURES OF VERSION 1.05  :

	RUNS WITH GDB-4.0 (and versions 3.xx too),
	Fix tiny bug in search function.


I did not test xxgdb with the new gdb-4.1, I hope it works.
I would welcome any comments and bug reports.

I would also appreciate if anyone out there using xxgdb
could drop me a mail (at pierre@la.tce.com) so I know
how many you are.

Also, if you know a site where is kept the complete source
of xxgdb, I would like you to tell me because this is a
question I am often asked.

TO PATCH XXGDB FROM VERSION 1.04 TO VERSION 1.05 :

	cd <original xxgdb 1.04 source directory>
	chmod +rw *
	patch < <patch_file>
	
THE FOLLOWING IS THE PATCH FILE FOR XXGDB 1.05 FROM XXGDB 1.04 :
diff -rc2 v1.04/Makefile v1.05/Makefile
*** v1.04/Makefile	Thu May 30 15:39:41 1991
--- v1.05/Makefile	Wed Aug 28 18:35:53 1991
***************
*** 42,46 ****
                 AR = ar cq
    BOOTSTRAPCFLAGS =
!                CC = cc
  
           COMPRESS = compress
--- 42,46 ----
                 AR = ar cq
    BOOTSTRAPCFLAGS =
!                CC = gcc -v
  
           COMPRESS = compress
diff -rc2 v1.04/XXGDB_README v1.05/XXGDB_README
*** v1.04/XXGDB_README	Tue Jul  9 13:36:08 1991
--- v1.05/XXGDB_README	Mon Sep 23 16:13:14 1991
***************
*** 108,112 ****
  	Thomson Consumer Electronics, Inc.
  
! XXGDB version 1.03
  ------------------
  
--- 108,112 ----
  	Thomson Consumer Electronics, Inc.
  
! XXGDB version 1.05
  ------------------
  
***************
*** 117,120 ****
--- 117,122 ----
  	GDB must be accessible in the current path.
  	
+ 	xxgdb should run the new gdb 4.0 (as well as the older versions).
+ 	
  	This X window interface has been adapted to GDB from the source
  	distribution files of XDBX version 2.1 (patch level 2) which
***************
*** 138,149 ****
      the R4 release of X11 for both.
  			
! 	- XXGDB changes the GDB default 'set prettyprint' to ON. This is
! 	necessary to be able to display the pointed object when clicking
! 	a pointer value in a popup window (see also 'Displaying C Data
! 	Structures' in xdbx documentation). Except for this feature,
! 	xxgdb works with 'set prettyprint off'.
  	
! 	- XXGDB changes the GDB default 'set screensize' to 0.
  
  	- With the 'list' command, XXGDB will put the cursor at the last 
  	listed line and will make sure that this last line is visible
--- 140,155 ----
      the R4 release of X11 for both.
  			
! 	- XXGDB changes the GDB default 'set prettyprint' to ON (or 'set
! 	p pretty' if gdb 4.0). This is necessary to be able to display
! 	the pointed object when clicking a pointer value in a popup window
! 	(see also 'Displaying C Data Structures' in xdbx documentation).
! 	Except for this feature, xxgdb works with 'set prettyprint off'.
  	
! 	- XXGDB changes the GDB default 'set screensize' to 0 (or 
! 	'set height' and 'set width' to 0 if gdb 4.0).
  
+ 	- XXGDB changes the GDB default 'set confirm' to off (if gdb 4.0).
+ 	THIS IS IMPORTANT. DO NOT SET CONFIRM TO OFF OR XXGDB MIGHT HANG. 
+ 
  	- With the 'list' command, XXGDB will put the cursor at the last 
  	listed line and will make sure that this last line is visible
***************
*** 200,203 ****
--- 206,211 ----
  		because xxgdb does not interpret what the defined commands
  		do.
+ 		
+ 	- 'set confirm off' might hang xxgdb later on.
  	
  	- 'source' command of XXGDB behaves slighlty differently from 
***************
*** 204,208 ****
  	the one in GDB. The specified file is read line by line by xxgdb
  	and each line is sent to gdb. Thus gdb will ask confirmation of
! 	some commands. 
  	This is also the case for the execution of the '.gdbinit' file.
  	
--- 212,217 ----
  	the one in GDB. The specified file is read line by line by xxgdb
  	and each line is sent to gdb. Thus gdb will ask confirmation of
! 	some commands (except for gdb 4.0 because of 'set confirm off'
! 	used by xxgdb).
  	This is also the case for the execution of the '.gdbinit' file.
  	
***************
*** 209,219 ****
  	- Repeat command of XXGDB behaves slighlty differently from the one
  	in GDB.
- 	
- 	- Clicking too rapidly on the buttons will sometimes hang gdb.
- 	It is WISE to wait for the completion of the previous command
- 	before sending any new command to gdb. Note that sending the
- 	SIGCONT (19) signal to gdb seems to fix this problem.
- 	
  
  XXGDB history
  -------------
--- 218,224 ----
  	- Repeat command of XXGDB behaves slighlty differently from the one
  	in GDB.
  
+ 
+ 
  XXGDB history
  -------------
***************
*** 247,250 ****
--- 252,258 ----
  				fix problem scrolling symbols while scrolling with keys (GWC).
  				fix bug displaying arrow when up/down in recursive function.
+ 	1.05	July - September 1991
+ 				Fix bug in search window.
+ 				Update for gdb 4.0 (PW)(SH).
  				
  
***************
*** 254,261 ****
  	Thanks to Guy Cherry (GWC) for his numerous bug reports and
  	suggestions, and to all of you who helped improve xxgdb.
- 	
  	Thanks to j braham levy (JBL) for his modifications for
  	generic BSD machines.
! 	
  	
  				--------------------------
--- 262,269 ----
  	Thanks to Guy Cherry (GWC) for his numerous bug reports and
  	suggestions, and to all of you who helped improve xxgdb.
  	Thanks to j braham levy (JBL) for his modifications for
  	generic BSD machines.
! 	Thanks to Stephan Heuer (SH) for some updates to gdb 4.0.
! 
  	
  				--------------------------
diff -rc2 v1.04/command.c v1.05/command.c
*** v1.04/command.c	Fri Apr 12 17:04:49 1991
--- v1.05/command.c	Mon Sep 23 13:59:50 1991
***************
*** 456,482 ****
      searchlength = strlen(searchstring);
      searchsize = strlen(text) - searchlength;
!     for (i=startpos; i < searchsize; i++) {
  	n = searchlength;
  	s1 = &text[i];
  	s2 = searchstring;
! 	while (--n >= 0 && *++s1 == *s2++);
  	if (n < 0) break;
      }
      if (n < 0) {
!     	*left = i+1;
!     	*right = i+1+searchlength;
      	return 1;
      }
      else {
! 	for (i=0; i < startpos; i++) {
  	    n = searchlength;
  	    s1 = &text[i];
  	    s2 = searchstring;
! 	    while (--n >= 0 && *++s1 == *s2++);
  	    if (n < 0) break;
  	}
  	if (n < 0) {
! 	    *left = i+1;
! 	    *right = i+1+searchlength;
  	    return 1;
  	}
--- 456,482 ----
      searchlength = strlen(searchstring);
      searchsize = strlen(text) - searchlength;
!     for (i=startpos+1; i < searchsize; i++) {
  	n = searchlength;
  	s1 = &text[i];
  	s2 = searchstring;
! 	while (--n >= 0 && *s1++ == *s2++);
  	if (n < 0) break;
      }
      if (n < 0) {
!     	*left = i;
!     	*right = i+searchlength;
      	return 1;
      }
      else {
! 	for (i=0; i <= startpos; i++) {
  	    n = searchlength;
  	    s1 = &text[i];
  	    s2 = searchstring;
! 	    while (--n >= 0 && *s1++ == *s2++);
  	    if (n < 0) break;
  	}
  	if (n < 0) {
! 	    *left = i;
! 	    *right = i+searchlength;
  	    return 1;
  	}
***************
*** 498,502 ****
  
      searchlength = strlen(searchstring);
!     for (i=startpos; i > searchlength; i--) {
  	n = searchlength;
  	s1 = &text[i];
--- 498,502 ----
  
      searchlength = strlen(searchstring);
!     for (i=startpos; i >= searchlength; i--) {
  	n = searchlength;
  	s1 = &text[i];
***************
*** 511,515 ****
      }
      else {
! 	for (i=strlen(text)-1; i > startpos; i--) {
  	    n = searchlength;
  	    s1 = &text[i];
--- 511,515 ----
      }
      else {
! 	for (i=strlen(text); i > startpos; i--) {
  	    n = searchlength;
  	    s1 = &text[i];
***************
*** 817,823 ****
  	q->next = p;
      }
!     write_dbx(command);
!     
!     Prompt = FALSE;		/* (PW)12APR91 : no more Prompt now. */
  }
  
--- 817,822 ----
  	q->next = p;
      }
! 
! 	write_dbx_available();
  }
  
diff -rc2 v1.04/datadpy.c v1.05/datadpy.c
*** v1.04/datadpy.c	Mon Apr 15 09:19:39 1991
--- v1.05/datadpy.c	Fri Sep 20 14:34:56 1991
***************
*** 246,250 ****
--- 246,254 ----
  	sprintf(command, "print *(%s)\n", name);
  	PopupMode = True;
+ #ifdef GDB
+     query_gdb(command, PARSE_ON | ECHO_OFF | FILTER_OFF);
+ #else
  	query_dbx(command);
+ #endif
      }
  }
diff -rc2 v1.04/dbx.c v1.05/dbx.c
*** v1.04/dbx.c	Tue May  7 14:59:14 1991
--- v1.05/dbx.c	Fri Sep 20 16:04:33 1991
***************
*** 135,138 ****
--- 135,139 ----
  }
  
+ #ifndef GDB
  /*
   *  This is a callback procedure invoked everytime when input is pending
***************
*** 183,192 ****
  	command = get_command();
  		
- #ifdef GDB
- 	if (Echo || Filter)
- 	    filter(string, output, command);
- 	if (Echo && Prompt)
- 	    AppendDialogText(xdbxprompt);
- #else
  	if (Echo) {
  	    filter(string, output, command);
--- 184,187 ----
***************
*** 193,197 ****
  	    if (Prompt) AppendDialogText(xdbxprompt);
  	}
- #endif
  	if (string) {
  	    XtFree(string);
--- 188,191 ----
***************
*** 211,214 ****
--- 205,209 ----
      }
  }
+ #endif /* not GDB */
  
  /*  Write string s to dbx, and flush the output.  */
***************
*** 224,238 ****
  }
  
! #ifdef GDB
! /*  Sends a command to dbx and read the corresponding output, directly
!  *  invoking the Xt input procedure, read_dbx().
!  */
! void query_dbx(command)
! char *command;
! {
! 	query_dbx_echo(command, False, False);
! }
! 
! #else
  /*  Sends a command to dbx and read the corresponding output, directly
   *  invoking the Xt input procedure, read_dbx().
--- 219,223 ----
  }
  
! #ifndef GDB
  /*  Sends a command to dbx and read the corresponding output, directly
   *  invoking the Xt input procedure, read_dbx().
diff -rc2 v1.04/defs.h v1.05/defs.h
*** v1.04/defs.h	Fri Apr 12 10:06:28 1991
--- v1.05/defs.h	Fri Sep 20 16:04:42 1991
***************
*** 256,257 ****
--- 256,268 ----
      char 	func[MAXNAME];		/* function name associated with */
  } Bomb;
+ 
+ 
+ #ifdef GDB
+ /* defined flags for query_gdb_gen() and read_gdb() */
+ #define PARSE_ON	1
+ #define PARSE_OFF	0
+ #define ECHO_ON		2
+ #define ECHO_OFF	0
+ #define FILTER_ON	4
+ #define FILTER_OFF	0
+ #endif
diff -rc2 v1.04/dialog.c v1.05/dialog.c
*** v1.04/dialog.c	Mon Mar 11 15:59:05 1991
--- v1.05/dialog.c	Mon Sep 23 14:36:07 1991
***************
*** 196,200 ****
      static char gdb_command[LINESIZ] = " \n";
  #endif
!     char s[LINESIZ];
  
      strcpy(s, DialogText + StartPos);
--- 196,200 ----
      static char gdb_command[LINESIZ] = " \n";
  #endif
! char s[LINESIZ];
  
      strcpy(s, DialogText + StartPos);
***************
*** 205,227 ****
  #endif
  
!     if (Prompt) {
! #ifdef GDB
! 	if (gdb_source_command(s,FALSE))	/* filter source command (& do not display source command) */
! 		{
! 		strcpy(gdb_command," \n");	/* do not execute anything if next command is '\n' */
! 		return;
  		}
! 	/* When we send \n to gdb, it executes the last command,
! 	so better tell xxgdb what gdb is doing */
!     if (strcmp(s, "\n"))
! 		strcpy(gdb_command,s);
!     else
! 		strcpy(s,gdb_command);
! #endif /* GDB */
! 	send_command(s);
!     }
!     else {
      	write_dbx(s);
-     }
  }
  
--- 205,226 ----
  #endif
  
!     if (Prompt)
!     	{
! 		/* When we send \n to gdb, it executes the last command,
! 		so better tell xxgdb what gdb is doing */
! 	    if (strcmp(s, "\n"))
! 			strcpy(gdb_command,s);	/* if not "\n" ! */
! 	    else
! 	    	{
! 	    	/* copy previous command in new command, and
! 	    	echo the command in the dialog window. */
! 			strcpy(s,gdb_command);
! 			AppendDialogText(gdb_command);
! 			}
! 		send_command (s);
  		}
! 	else
! 		/* this string is for the application, not for gdb */
      	write_dbx(s);
  }
  
diff -rc2 v1.04/filemenu.c v1.05/filemenu.c
*** v1.04/filemenu.c	Wed Apr  3 14:12:30 1991
--- v1.05/filemenu.c	Mon Sep 23 13:51:58 1991
***************
*** 136,140 ****
  	LASTCH(cwd) = '\0';
      }
! #else
      if(!strcmp(dir,"../"))
         {
--- 136,140 ----
  	LASTCH(cwd) = '\0';
      }
! #else	/* not BSD */
      if(!strcmp(dir,"../"))
         {
***************
*** 151,156 ****
        }
      sprintf(command, "cd %s\n", store);
      query_dbx(command);
! #endif
  }
  
--- 151,160 ----
        }
      sprintf(command, "cd %s\n", store);
+ #ifdef GDB
+     query_gdb(command, PARSE_ON | ECHO_OFF | FILTER_OFF);
+ #else
      query_dbx(command);
! #endif	/* not GDB */
! #endif	/* BSD */
  }
  
***************
*** 318,347 ****
      	UpdateMessageWindow("",NULL);
  #ifdef GDB
- 	/* for GDB, we send the commands : exec-file & symbol-file */
- 	
- 	/* (PW)21DEC90 : this button is special because it has to send
- 	TWO commands to GDB. We should wait for the prompt before
- 	sending the second command !. 
- 	I think it is cleaner to send this 2nd command in the parser
- 	after it matches 'exec-file' command.
- 	But do that latter
- 	*/
- 	
  	strcpy(string, filename);
  	LASTCH(string) = '\0';
- 	
- 	sprintf(command, "exec-file %s\n", string);
- 	send_command(command);
-     	AppendDialogText(command);
-     	
-     Echo = True;
-     Parse = True;
-     Prompt = False;
-     while (!Prompt)
-         read_dbx();
  
! 	sprintf(command, "symbol-file %s\n", string);
  	send_command(command);
!     	AppendDialogText(command);
  #else
  #ifndef BSD
--- 322,346 ----
      	UpdateMessageWindow("",NULL);
  #ifdef GDB
  	strcpy(string, filename);
  	LASTCH(string) = '\0';
  
! 	/* for GDB 4.xx, we send the command : file */
! 	if (new_gdb4())
! 		sprintf(command, "file %s\n", string);
! 	else
! 		{
! 		/* for GDB 3.xx, we send the commands : exec-file & symbol-file */
! 		
! 		/* (PW)21DEC90 : this button is special because it has to send
! 		TWO commands to GDB. */
! 		
! 		sprintf(command, "exec-file %s\n", string);
! 		send_command(command);
! 	    	AppendDialogText(command);
! 	    	
! 		sprintf(command, "symbol-file %s\n", string);
! 		}
  	send_command(command);
! 	AppendDialogText(command);
  #else
  #ifndef BSD
***************
*** 446,450 ****
      SetUpFileMenu(cwd);
  #ifdef GDB
!     query_dbx("info directories\n");
  #else
      query_dbx("use\n");
--- 445,449 ----
      SetUpFileMenu(cwd);
  #ifdef GDB
!     query_gdb_directories();  /* defined in gdb_handler.c */
  #else
      query_dbx("use\n");
diff -rc2 v1.04/gdb_handler.c v1.05/gdb_handler.c
*** v1.04/gdb_handler.c	Tue May  7 14:59:11 1991
--- v1.05/gdb_handler.c	Mon Sep 23 16:00:42 1991
***************
*** 83,87 ****
   *    done_handler():		Progrm execution completed, clear breakpoints
   *    source_handler():		Exec commands of source file specified.
!  *    query_dbx_echo():		Send command with echo on or off, filter on/off.
   */
  
--- 83,87 ----
   *    done_handler():		Progrm execution completed, clear breakpoints
   *    source_handler():		Exec commands of source file specified.
!  *    query_gdb():			Send command to gdb.
   */
  
***************
*** 90,94 ****
  #endif
  
- void query_dbx_echo();
  
  /*  
--- 90,93 ----
***************
*** 129,146 ****
  void debug_handler()
  {
! 	/* debug_handler is executed at start-up and with 'symbol-file' command */
  	
!     query_dbx("set screensize 0\n");
!     query_dbx("set prettyprint on\n");
!     query_dbx("info directories\n");
      
      displayedFile = NULL;		/* force reloading of source file */
   
!  	/* here we use query_dbx_echo instead of query_dbx so that any
!  	error message will be displayed ! (because Filter is True) */
!  	
!  	query_dbx_echo("list ,main\n", False, True);	/* tell gdb to use main file 
!  								and get line number of main(). (,main will end at main) */
!    
      if (LoadCurrentFile() == 0)
      	{
--- 128,159 ----
  void debug_handler()
  {
! 	/* debug_handler is executed at start-up and with 'symbol-file' command and
! 	with 'file' command (gdb 4.0) */
  	
! 	info_source_handler(NULL);	/* say no current compilation directory */
! 	
!     query_gdb_directories();
! 
! 	if (new_gdb4()) /* (PW)28AUG91: test for gdb 4.0 */
! 		{
! 		/* (SH) for gdb 4.0 */
! 	    query_gdb("set height 0\n",		PARSE_OFF | ECHO_OFF | FILTER_OFF);	
! 	    query_gdb("set width 0\n", 		PARSE_OFF | ECHO_OFF | FILTER_OFF);
!     	query_gdb("set p pretty on\n",	PARSE_OFF | ECHO_OFF | FILTER_OFF);
!     	query_gdb("set confirm off\n",	PARSE_OFF | ECHO_OFF | FILTER_OFF);
! 		}
! 	else
! 		{
! 	    query_gdb("set screensize 0\n",		PARSE_OFF | ECHO_OFF | FILTER_OFF);
!     	query_gdb("set prettyprint on\n",	PARSE_OFF | ECHO_OFF | FILTER_OFF);
!     	}
      
      displayedFile = NULL;		/* force reloading of source file */
   
!  	/* here we use FILTER_ON so that any error message will be displayed ! */
! 	/* tell gdb to use main file and get line number of main(). (,main will end at main) */
! 	
!  	query_gdb("list ,main\n", PARSE_ON | ECHO_OFF | FILTER_ON); 
! 
      if (LoadCurrentFile() == 0)
      	{
***************
*** 156,160 ****
  		
  	UpdateMessageWindow("Ready for execution",NULL);
! 	query_dbx("display\n");		/* clear display window */
  }
  
--- 169,176 ----
  		
  	UpdateMessageWindow("Ready for execution",NULL);
! 	
! 	/* clear display window */
! 	
! 	query_gdb("display\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  }
  
***************
*** 274,278 ****
  	directory only. GDB requires confirmation */
  	
!     query_dbx("info directories\n");	
  }
  
--- 290,294 ----
  	directory only. GDB requires confirmation */
  	
!     query_gdb_directories();
  }
  
***************
*** 285,288 ****
--- 301,308 ----
      if (line)
  		{
+ 		/* update compilation directory (if gdb 4.0) before loading source file */
+ 		if (new_gdb4())
+ 			query_gdb("info source\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
+ 		
  		/* We will display the last line listed. 
  		Since we used 'list ,main' we will effectively display main in that case. */
***************
*** 317,321 ****
  void delete_handler()
  {
!     query_dbx("info break\n");	/* update breakpoints */
  }
  
--- 337,342 ----
  void delete_handler()
  {
! 	/* update breakpoints */
!     query_gdb("info break\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  }
  
***************
*** 322,326 ****
  void display_handler()	/* display or undisplay */
  {
!     query_dbx_echo("display\n",False, True);	/* update display */
  }
  
--- 343,348 ----
  void display_handler()	/* display or undisplay */
  {
! 	/* update display */
!     query_gdb("display\n", PARSE_ON | ECHO_OFF | FILTER_ON);
  }
  
***************
*** 434,442 ****
  	/* because of tbreak, we have to call info break here */
  	
!     query_dbx("info break\n");	/* update breakpoints */
  
  	if (func == NULL)
  		{
! 		query_dbx("frame\n"); /* this will just update funcname (see frame_curr_handler) */
  		func = funcname;
  		if (func == NULL)
--- 456,476 ----
  	/* because of tbreak, we have to call info break here */
  	
!      query_gdb("info break\n", PARSE_ON | ECHO_OFF | FILTER_OFF); /* update breakpoints */
  
  	if (func == NULL)
  		{
! 		/* because silly gdb 4.0 displays nothing with frame 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);
! 			
! 		/* this will just update funcname (see frame_curr_handler()) */
! 		query_gdb("frame\n", 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);
! 			
  		func = funcname;
  		if (func == NULL)
***************
*** 472,475 ****
--- 506,510 ----
   *  change the file variable to the file name displayed.
   */
+ /* ARGSUSED */
  void done_handler(message,signal)
  char *message;
***************
*** 485,489 ****
  /*--------------------------------------------------------------------------+
  |																			|
! |	Function to read the .dgbinit file or any source file.					|
  |																			|
  |	input : file name.														|
--- 520,524 ----
  /*--------------------------------------------------------------------------+
  |																			|
! |	Function to read the .gdbinit file or any source file.					|
  |																			|
  |	input : file name.														|
***************
*** 510,521 ****
  			if ((*s != '#') && strcmp(s,"\n"))	
  				{
! 				if (gdb_source_command(s,TRUE) || gdb_define_command(s,fp))
! 					{
! 		   		 	Prompt = False;
! 		    		while (!Prompt)
! 						read_dbx();
! 					}
! 				else
! 					query_dbx_echo (s, TRUE, TRUE);
  				}
  			}
--- 545,550 ----
  			if ((*s != '#') && strcmp(s,"\n"))	
  				{
! 				if (!(gdb_source_command(s,TRUE) || gdb_define_command(s,fp)))
! 					query_gdb(s, PARSE_ON | ECHO_ON | FILTER_ON);
  				}
  			}
***************
*** 549,578 ****
  }
  
- /*  Sends a command to dbx and read the corresponding output, directly
-  *  invoking the Xt input procedure, read_dbx().
-  *
-  *	Same as query_dbx() in dbx.c except that Echo = True or False.
-  *  and in case Echo = False, filter says if filter() must be called.
-  */
- Boolean Filter; /* filter dbx output (if Echo == false) ? */
- 
- void query_dbx_echo(command, echo, filter)
- char *command;
- int echo;
- int filter;
- {
-     write_dbx(command);
-     insert_command(command);
- 
-     Echo = echo;
-     Filter = filter;
-     Prompt = False;
-     while (!Prompt)
-         read_dbx();
- 
-     Parse = True;	/* Always reset Parse and Echo to True */
-     Echo = True;
- }
- 
  /*  core-file  
   *  gdb does not display current line, file, func ..., so we send
--- 578,581 ----
***************
*** 588,594 ****
  	signal = Token.stop;					/* signal number received */
  	
! 	query_dbx("frame 0\n"); /* this will update updown.line, updown.func and
! 								updown.file. (see updown_handler) */
  	
  	line = updown.line;
  	updown.line = 0;
--- 591,608 ----
  	signal = Token.stop;					/* signal number received */
  	
! 	/* because silly gdb 4.0 displays nothing with frame 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);
! 
! 	/* this will update updown.line, updown.func and updown.file.
! 	(see updown_handler) */
! 	query_gdb("frame 0\n", 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);
+ 
  	line = updown.line;
  	updown.line = 0;
***************
*** 612,613 ****
--- 626,709 ----
      AdjustText(line); 
  }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Function to get the current source path directories.					|
+ |																			|
+ |	 WARNING : this function is called at startup of xxgdb					|
+ |	 to test for gdb 4.0 or earlier versions.								|
+ |	 The 1st time that query_gdb_directories() is called,					|
+ |	 new_gdb is true, and 'show directories' command is						|
+ |	 issued to gdb. Then parse() in gdb_parser.c will test for				|
+ |	 'show Unknown command' answer from gdb, and in that case				|
+ |	 will set new_gdb to false. See show_is_undefined() below.				|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ void query_gdb_directories()
+ {
+ 	if (new_gdb4()) /* (PW)28AUG91: test for gdb 4.0 */
+ 		query_gdb("show directories\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
+ 	else
+ 		query_gdb("info directories\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Function to know if we are running the NEW gdb							|
+ |																			|
+ |	return TRUE if we are running gdb 4.0 (or 3.9x or higher)				|
+ |																			|
+ |	WARNING : it is important that the default is gdb 4.0.					|
+ |			  (see comments on query_gdb_directories() above).				|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ static int new_gdb = True; /* default : we are running gdb 4.0 */
+ 
+ int new_gdb4()
+ {
+ 	return new_gdb;
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Function to say that 'show' command is undefined and thus				|
+ |	that we are running an old version of gdb.								|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ void show_is_undefined()
+ {
+ 	new_gdb = False;
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Update compilation directory											|
+ |																			|
+ |	This function is used for gdb 4.0 which uses the compilation			|
+ |	directory in the source path.											|
+ |																			|
+ |	input : current compilation directory									|
+ |		(returned from 'info source' gdb command).							|
+ |																			|
+ |	output : none.															|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ char cdir[MAXPATHLEN];       /* The compilation directory */
+ 
+ void info_source_handler(compile_dir)
+ char * compile_dir;
+ {
+ 	if (compile_dir == NULL) {
+ 		cdir[0] = 0;
+ 		return;
+ 	}
+ 
+ 	if (strlen (compile_dir) < MAXPATHLEN) 		/* check length */
+ 		strcpy(cdir,compile_dir);
+ 		
+ 	if (LASTCH(cdir) == '/')          		    /* remove last '/' */
+ 		LASTCH(cdir) = '\0';
+ }
+ 
+ 
+ 
diff -rc2 v1.04/gdb_parser.c v1.05/gdb_parser.c
*** v1.04/gdb_parser.c	Wed May 22 16:46:47 1991
--- v1.05/gdb_parser.c	Mon Sep 23 15:06:55 1991
***************
*** 75,80 ****
--- 75,134 ----
  #include 	<string.h>
  
+ extern Boolean	Prompt;			/* True when gdb prompt arrives */
+ 
  /*--------------------------------------------------------------------------+
  |																			|
+ |	Function to output a message and ring bell when a answer				|
+ |	from gdb has not been recognized (possibly because of bug				|
+ |	in xxgdb which does not anticipate this particular answer).				|
+ |																			|
+ |	ECHO_ON means that all the output from gdb was displayed				|
+ |	on the dialog window (so no need to display any error message).			|
+ |	In particular we can arrive here because the user typed a				|
+ |	wrong command.															|
+ |																			|
+ |	ECHO_OFF means that the gdb command was issued internally by			|
+ |	xxgdb, and that the user has no knowledge of it.						|
+ |																			|
+ |	ECHO_ON and FILTER_ON means that only part of the						|
+ |	gdb answer to the command is displayed in the dialog window.			|
+ |	What is displayed or not is chosen by the filter() function.			|
+ |	In fact, filter() in this case will display gdb error messages			|
+ |	from the command sent internally by xxgdb.								|
+ |																			|
+ |	This function will only display error messages when echo and			|
+ |	filter are off. This is more for xxgdb debug than for the user.			|
+ |																			|
+ +--------------------------------------------------------------------------*/	
+ void unknown_output (outputstr, command, flags)
+ char *outputstr;
+ char *command;
+ int flags;
+ {
+ 	if (command)
+ 		{
+ 		if (debug)
+ 			fprintf(stderr, "\noutput from \"%s\" is not recognized\n", command);
+ 	
+ 		/* if the command was completely silent, we output this
+ 		error message */
+ 		
+ 		if ((flags & (ECHO_ON | FILTER_ON)) == 0)
+ 			{
+ 			AppendDialogText("xxgdb error: output from \"");
+ 			AppendDialogText(command);
+ 			AppendDialogText("\" command is not recognized.\n");
+ 			}
+ 		}
+ 		
+ 	if (outputstr)
+ 		if ((flags & (ECHO_ON | FILTER_ON)) == 0)
+ 			AppendDialogText(outputstr);
+ 
+ 	bell(0);	/* ring the bell in ALL cases */
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
  |	Function to remove all 'Reading in symbols' message						|
  |	from a string.															|
***************
*** 119,125 ****
  | *																			|
  +--------------------------------------------------------------------------*/
! void parse(output, command)
  char *output;
  char *command;
  {
      int  command_type;
--- 173,180 ----
  | *																			|
  +--------------------------------------------------------------------------*/
! void parse(output, command, flags)
  char *output;
  char *command;
+ int flags;
  {
      int  command_type;
***************
*** 129,133 ****
      char *temp;
      if(!command)temp="";else temp=command;
! 	fprintf(stderr, "parse(output = %s, command = %s)\n", output, temp);
      }
  
--- 184,188 ----
      char *temp;
      if(!command)temp="";else temp=command;
! 	fprintf(stderr, "parse(output = %s, command = %s, flags = %d)\n", output, temp, flags);
      }
  
***************
*** 136,147 ****
      if (output) strcpy(output, "");
  
      if (!command) {
! 	if (match(output_pattern, output_string, O_DEBUG) != -1)
  		{
! 	    debug_handler();
  	    if (match(output_pattern, output_string, O_CORE_FILE) != -1)
  			core_file_handler();
  	    }
! 	debug_init();
  	XtFree(output_string);
  	return;
--- 191,213 ----
      if (output) strcpy(output, "");
  
+ 	/* test for GDB start-up */
+ 
      if (!command) {
! /* (PW)28AUG91 : do no test for O_DEBUG pattern because of gdb 4.0
! who most of the times displays nothing before the promt.
! if (match(output_pattern, output_string, O_DEBUG) != -1)
! */
  		{
!    		query_gdb_directories();	/* will tell if running gdb 4.0 */
!    		
! 	    debug_handler();	/* some init to gdb, and try to display main() */
! 	    
! 	    /* test if a core file was used in input arguments,
! 	    an display bomb if necessary. */
! 	    
  	    if (match(output_pattern, output_string, O_CORE_FILE) != -1)
  			core_file_handler();
  	    }
! 	debug_init();			/* read .gdbinit file (if any) */
  	XtFree(output_string);
  	return;
***************
*** 148,160 ****
      }
      
!     if (!Parse)
!     	{
!     	XtFree(output_string);
! 		return;
! 		}
! 
  	if (match(output_pattern, output_string, O_BELL) != -1)
  		{
! 		bell(0);
      	XtFree(output_string);
  		return;
--- 214,229 ----
      }
      
!     /* if not GDB start-up */
!     
  	if (match(output_pattern, output_string, O_BELL) != -1)
  		{
! 		/* test if this is 'show undefined'. If yes then we are
! 		not executing the new gdb (4.0).
! 			(see show_is_undefined in gdb_handler.c)
! 		*/
! 		if (match(output_pattern, output_string, O_UNDEF_SHOW) != -1)
! 			show_is_undefined();
! 		else
! 			unknown_output (output_string,command, flags);
      	XtFree(output_string);
  		return;
***************
*** 194,198 ****
  				done_handler(message,signal);
  			else
! 				bell(0);
  			}
  			
--- 263,267 ----
  				done_handler(message,signal);
  			else
! 				unknown_output(output_string, command, flags);
  			}
  			
***************
*** 209,213 ****
  		updown_handler();
  	    else
! 		bell(0);
  	    break;
  	case C_SEARCH:
--- 278,282 ----
  		updown_handler();
  	    else
! 			unknown_output (output_string, command, flags);
  	    break;
  	case C_SEARCH:
***************
*** 215,219 ****
  		search_handler();
  	    else
! 		bell(0);
  	    break;
  	case C_DELETE:
--- 284,288 ----
  		search_handler();
  	    else
! 			unknown_output(output_string, command, flags);
  	    break;
  	case C_DELETE:
***************
*** 224,228 ****
  	        list_handler();
  	    else
! 		bell(0);
  	    break;
  	    
--- 293,297 ----
  	        list_handler();
  	    else
! 			unknown_output(output_string, command, flags);
  	    break;
  	    
***************
*** 231,235 ****
  			break_handler();
  	    else
! 		bell(0);
  	    break;
  	    
--- 300,304 ----
  			break_handler();
  	    else
! 			unknown_output(output_string, command, flags);
  	    break;
  	    
***************
*** 238,242 ****
  	        info_dir_handler();
  	    else
! 		bell(0);	
  		break;
  		
--- 307,311 ----
  	        info_dir_handler();
  	    else
! 			unknown_output(output_string, command, flags);
  		break;
  		
***************
*** 249,253 ****
  	    	info_line_handler();		/* command was 'info line' */
  	    else
! 		bell(0);
  	    break;
  	    
--- 318,322 ----
  	    	info_line_handler();		/* command was 'info line' */
  	    else
! 			unknown_output(output_string, command, flags);
  	    break;
  	    
***************
*** 262,266 ****
  	    	display_handler();
  	    else
! 		bell(0);
  		}
  	    break;
--- 331,335 ----
  	    	display_handler();
  	    else
! 			unknown_output(output_string, command, flags);
  		}
  	    break;
***************
*** 270,274 ****
  			display_handler();
  	    else
! 		bell(0);
  	    break;
  
--- 339,343 ----
  			display_handler();
  	    else
! 			unknown_output(output_string, command, flags);
  	    break;
  
***************
*** 279,283 ****
  	    	display_info_handler();
  	    else
! 		bell(0);
  		}
  	    break;
--- 348,352 ----
  	    	display_info_handler();
  	    else
! 			unknown_output(output_string, command, flags);
  		}
  	    break;
***************
*** 287,291 ****
  	    	cd_handler(Token.mesg); 
  	    else
! 		bell(0);
  	    break;
  	    
--- 356,360 ----
  	    	cd_handler(Token.mesg); 
  	    else
! 			unknown_output(output_string, command, flags);
  	    break;
  	    
***************
*** 294,298 ****
  			pwd_handler(Token.mesg);
  	    else
! 		bell(0);
  	    break;
  
--- 363,367 ----
  			pwd_handler(Token.mesg);
  	    else
! 			unknown_output(output_string, command, flags);
  	    break;
  
***************
*** 299,305 ****
  	case C_FRAME_CURR:
  	    if (match(output_pattern, output_string, O_FRAME_CURR) != -1)
! 		frame_curr_handler();
  	    else
! 		bell(0);
  	    break;
  
--- 368,374 ----
  	case C_FRAME_CURR:
  	    if (match(output_pattern, output_string, O_FRAME_CURR) != -1)
! 			frame_curr_handler();
  	    else
! 			unknown_output(output_string, command, flags);
  	    break;
  
***************
*** 324,328 ****
  	    	}
  	    else
! 		bell(0);
  		
  		/* if PopupMode was true but GDB found an error in print
--- 393,397 ----
  	    	}
  	    else
! 			unknown_output(output_string, command, flags);
  		
  		/* if PopupMode was true but GDB found an error in print
***************
*** 335,338 ****
--- 404,408 ----
  	    
  	case C_SYMBOL_FILE:
+ 	case C_FILE:
  		debug_handler(); 
  	    break;
***************
*** 346,354 ****
  	case C_CORE_FILE:
  	    if (match(output_pattern, output_string, O_CORE_FILE) != -1)
! 		core_file_handler();
  	    else
! 		bell(0);
  	    break;
  	    
  	default:
  	    break;
--- 416,434 ----
  	case C_CORE_FILE:
  	    if (match(output_pattern, output_string, O_CORE_FILE) != -1)
! 			core_file_handler();
  	    else
! 			unknown_output(output_string, command, flags);
  	    break;
  	    
+ 	/* in case of 'info source', we do not call unknown_output()
+ 	if the pattern is not matched, because we only test for the
+ 	'compilation directory' line. When there is no compilation
+ 	directory, there is no match and there is no error... */
+ 	
+ 	case C_INFO_SOURCE:
+ 	    if (match(output_pattern, output_string, O_INFO_SOURCE) != -1)
+ 	    	info_source_handler(Token.mesg); 
+ 	    break;
+ 
  	default:
  	    break;
***************
*** 662,666 ****
  			AppendDialogText(command);
  		source_handler();	
- 	    send_command(" \n");	/* ask GDB to redisplay its prompt */
  		return TRUE;
  		}
--- 742,745 ----
***************
*** 681,684 ****
--- 760,765 ----
  |																			|
  +--------------------------------------------------------------------------*/
+ static int command_sent = 0;	/* flag gdb is busy : send no more command to gdb. */
+ 
  int gdb_define_command(command,fp)
  char *command;
***************
*** 693,698 ****
  		{
  		AppendDialogText(command);
- 		send_command(command);
  		
  /*
  				gdb could ask :
--- 774,787 ----
  		{
  		AppendDialogText(command);
  		
+ 		/* because silly gdb 4.0 displays nothing with def/doc 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);
+ 
+ 		write_dbx (command);
+ 		
  /*
  				gdb could ask :
***************
*** 768,771 ****
--- 857,867 ----
  			}
  		
+ 		command_sent++;				/* flag gdb is busy (because of read_gdb) */
+ 		insert_command("end\n");	/* insert 'end' at head of queue */
+ 		read_until_prompt (PARSE_OFF | ECHO_ON | FILTER_OFF);	/* return when prompt */
+ 
+ 		if (new_gdb4()) /* reset confirm to off */
+ 			query_gdb("set confirm off\n",	PARSE_OFF | ECHO_OFF | FILTER_OFF);
+ 
  		return TRUE;
  		}
***************
*** 774,775 ****
--- 870,1073 ----
  }
  
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Read gdb output until fgets returns no string.							|
+ |																			|
+ |	The ouptut is process according to flags.								|
+ |																			|
+ |	In case the gdb prompt is found, the command on top of the				|
+ |	command queue (ie, the one which is assumed to correspond				|
+ |	to this output) is remove from the queue, and 'command_sent'			|
+ |	is decremented to say that gdb is no longer busy.						|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ static int parse_flags = PARSE_ON | ECHO_ON | FILTER_ON; /* last flags used in read_gdb */
+ 
+ void read_gdb (flags)
+ int flags;
+ {
+     static char *output = NULL; 	/* buffer for gdb output */
+     static char *next_string = NULL;
+     static char *command;
+     char 	*string = NULL;
+     char 	s[LINESIZ];
+     Boolean 	more;
+ 	
+ 	parse_flags = flags; 	/* just remember flags for read_dbx() */
+ 	
+     more = True;
+     while (more) {
+ 	Prompt = False;
+ 	/* keep reading until no more or until prompt arrives */
+ 	while (more = fgets(s, LINESIZ, dbxfp) && !Prompt)
+ 		{
+ 	    if (debug)
+ 			fprintf(stderr, "=>%s", s);
+ 			
+ 	    /* receive prompt? */
+ 	    if (strncmp(s, dbxprompt, strlen(dbxprompt)) == NULL)
+ 	    	{
+ 			Prompt = True;
+ 			
+ 			/* more stuff behind prompt? */
+ 			if (s[strlen(dbxprompt)])
+ 			    /* remember it */
+ 			    next_string = XtNewString(s+strlen(dbxprompt));
+ 			    
+ 			/* destroy contents */
+ 			strcpy(s, "");
+ 		    }
+ 		    
+ 	    string = concat(string, s);
+ 	    strcpy(s, "");
+ 		}
+ 		
+ 	output = concat(output, string);
+ 	
+ 	command = get_command();			/* read queue's top command  */
+ 		
+ 	if (flags & FILTER_ON)
+ 	    filter(string, output, command);
+ 	    
+ 	if ((flags & ECHO_ON) && Prompt)
+ 	    AppendDialogText(xdbxprompt);
+ 	    
+ 	if (string) {
+ 	    XtFree(string);
+ 	    string = NULL;
+ 	}
+ 	
+ 	if (next_string) {
+ 	    string = concat(string, next_string);
+ 	    XtFree(next_string);
+ 	    next_string = NULL;
+ 	}
+ 	
+ 	if ((flags & PARSE_ON) && Prompt) {
+ 	    parse (output, command, flags);
+ 	}
+ 	
+ 	/* note : it is important to decrement 'command_sent' AFTER
+ 	parse() is executed, so that no other commands will mix-up
+ 	the commands sent by the function handlers executed by parse().
+ 	*/
+ 	
+ 	if (Prompt) {
+ 	    delete_command();		/* remove top command from queue */
+ 	    if (command && command_sent)
+ 			command_sent--;
+ 	    XtFree(output);
+ 	    output = NULL;
+ 	}
+ 	}
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ | *																			|
+ | *	 This is a callback procedure invoked everytime when input is pending	|
+ | *	 on the file descriptor to dbx.											|
+ | *	 o reads all the data available on the file descriptor line by line		|
+ | *	   into local variable 'string' and global variable 'output'.			|
+ | *	   'output' records the entire dbx output whereas 'string' records		|
+ | *	   only the data read in this invocation of read_dbx().					|
+ | *	 o in Echo mode, the contents in 'string' is edited by filter()			|
+ | *	   before it gets displayed on the dialog window.						|
+ | *	 o once the dbx prompt is read, calls parse() to analyse the dbx output |
+ | *	   and take appropriate action.											|
+ | *																			|
+ +--------------------------------------------------------------------------*/
+ /* ARGSUSED */
+ void read_dbx(master, source, id)
+ XtPointer master;
+ int 	  *source;
+ XtInputId *id;
+ {
+ 	read_gdb (parse_flags);
+ 	
+ 	write_dbx_available ();
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Read gdb output until prompt.											|
+ |	The ouptut is process according to flags.								|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ void read_until_prompt (flags)
+ int flags;
+ {
+     Prompt = False;
+     while (!Prompt)
+         read_gdb (flags);
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ | *	 Sends a command to gdb and read the corresponding output, directly		|
+ | *	 invoking the Xt input procedure, read_gdb().							|
+ | *																			|
+ | * Same as query_dbx() in dbx.c except that echo, filter and parse.		|
+ | *	 are passed in argument flags:											|
+ | * PARSE_ON | PARSE_OFF | ECHO_ON | ECHO_OFF | FILTER_ON | FILTER_OFF		|
+ | *																			|
+ +--------------------------------------------------------------------------*/
+ void query_gdb(command, flags)
+ char *command;
+ int flags;
+ {
+ 	command_sent++;				/* flag gdb is busy */
+ 	
+     write_dbx(command);			/* send command to gdb */
+     
+     insert_command(command);	/* insert at head of queue */
+ 
+ 	read_until_prompt (flags);	/* return when prompt */
+ 	
+ 	/* test if we are at the top command, and if some commands are waiting */
+ 	
+ 	write_dbx_available ();	/* send next waiting command */
+ }
+ 
+ /*--------------------------------------------------------------------------+
+ |																			|
+ |	Function to send the first command of the command queue to gdb only in	|
+ |	case gdb is waiting for a command.										|
+ |																			|
+ |	WARNING : we must test for 'source' command.							|
+ |																			|
+ |	The commands in the command queue are from the keyboard and from		|
+ |	the buttons.															|
+ |																			|
+ +--------------------------------------------------------------------------*/
+ void write_dbx_available()
+ {
+ char *command;
+ 
+ 	if (command = get_command())
+ 		{
+ 		if (command_sent++ == 0)	
+ 			{
+ 			/* here, the source command is already displayed, say echo command = FALSE */
+ 			
+ 			if (gdb_source_command(command,FALSE))
+ 				{
+ 				delete_command();		/* remove source command from top of queue */
+ 				command_sent--;
+ 				/* tell gdb to send its prompt */
+ 				query_gdb(" \n", PARSE_OFF | ECHO_OFF | FILTER_OFF);
+ 				return;
+ 				}
+ 				
+ 			parse_flags = PARSE_ON | ECHO_ON | FILTER_ON; /* for read_gdb */
+ 			write_dbx (command);
+ 		    Prompt = False;
+ 			return;					/* return with command_sent incremented */
+ 			}
+ 		else
+ 			{
+ 			if (command_sent)	/* should never be zero ! (just to be safe) */
+ 				command_sent--;	/* command is not sent, restore previous value */
+ 			return;
+ 			}
+ 		}
+ }
diff -rc2 v1.04/gdb_regex.h v1.05/gdb_regex.h
*** v1.04/gdb_regex.h	Thu May 30 16:54:06 1991
--- v1.05/gdb_regex.h	Mon Sep 23 15:07:04 1991
***************
*** 103,106 ****
--- 103,108 ----
  #define O_READING_SYMBOLS	19			/* special for filter_reading_symbols */
  #define O_CORE_FILE			20
+ #define O_UNDEF_SHOW		21			/* test for undefined show command (for gdb 4.0) */
+ #define O_INFO_SOURCE		22			/* to get compilation directory (for gdb 4.0) */
  
  
***************
*** 131,134 ****
--- 133,138 ----
  #define C_DOCUMENT		23
  #define C_END			24
+ #define C_INFO_SOURCE	25			/* new for gdb 4.0 to get compilation directory */
+ #define C_FILE			26			/* new for gdb 4.0 : file command */
  
  /*--------------------------------------------------------------------------+
***************
*** 432,435 ****
--- 436,449 ----
       {  2, 3, -1, -1, -1, -1}
      },
+     /* Undefined show command (for test gdb 4.0) */
+     {"\\(Undefined command: \"show\".\n\\)",
+      NULL,
+      {-1, -1, -1, -1, -1}
+     },
+     /* info source (for gdb 4.0) */
+     {"\\(.*\n\\)*Compilation directory is \\([^ ]+\\)\n\\(.*\n\\)*",
+      NULL,
+      { 2, -1, -1, -1, -1, -1}
+     },
      NULL 
  };
***************
*** 450,455 ****
  	jump - until - u */
  	/* CRL mod 22 4/5/91 GWC - added attach to this list for gdbvx */
  	
!     {"[ ]*\\(run\\|r\\|cont\\|c\\|next\\|n\\|step\\|s\\|nexti\\|stepi\\|ni\\|si\\|ret[urn]*\\|j[ump]*\\|unt[il]*\\|u\\|at[tach]*\\)\\( .*\\)?\n",
  											NULL, {-1, -1, -1, -1, -1, -1}},
  	/* break - tbreak */
--- 464,470 ----
  	jump - until - u */
  	/* CRL mod 22 4/5/91 GWC - added attach to this list for gdbvx */
+ 	/* (PW) - added target to this list for gdb 4.0 */
  	
!     {"[ ]*\\(run\\|r\\|cont\\|c\\|next\\|n\\|step\\|s\\|nexti\\|stepi\\|ni\\|si\\|ret[urn]*\\|j[ump]*\\|unt[il]*\\|u\\|at[tach]*\\|ta[rget]*\\)\\( .*\\)?\n",
  											NULL, {-1, -1, -1, -1, -1, -1}},
  	/* break - tbreak */
***************
*** 456,460 ****
      {"[ ]*\\(t\\)?\\(b\\|br\\|bre\\|brea\\|break\\)\\( .*\\)?\n",
      										NULL, {-1, -1, -1, -1, -1, -1}},
!     {"[ ]*info[ ]+directories[ ]*\n",		NULL, {-1, -1, -1, -1, -1, -1}},
      
      /* 'frame' is special case of 'frame n' since it does not change the
--- 471,476 ----
      {"[ ]*\\(t\\)?\\(b\\|br\\|bre\\|brea\\|break\\)\\( .*\\)?\n",
      										NULL, {-1, -1, -1, -1, -1, -1}},
!     /* (PW)28AUG91 : add show for gdb 4.0 */
!     {"[ ]*\\(info\\|show\\)[ ]+directories[ ]*\n",		NULL, {-1, -1, -1, -1, -1, -1}},
      
      /* 'frame' is special case of 'frame n' since it does not change the
***************
*** 472,476 ****
      										NULL, {-1, -1, -1, -1, -1, -1}},
      										
! 	{"[ ]*fi[nish]*[ ]*\n",					NULL, {-1, -1, -1, -1, -1, -1}},
      {"[ ]*info[ ]+line[ ]*\n",				NULL, {-1, -1, -1, -1, -1, -1}},
      
--- 488,493 ----
      										NULL, {-1, -1, -1, -1, -1, -1}},
      										
!     /* because of gdb 4.0 use fin[ish] instead of fi[nish] */				
! 	{"[ ]*fin[ish]*[ ]*\n",					NULL, {-1, -1, -1, -1, -1, -1}},
      {"[ ]*info[ ]+line[ ]*\n",				NULL, {-1, -1, -1, -1, -1, -1}},
      
***************
*** 508,512 ****
  	
      /* exec-file (just used internally) */
!     {"[ ]*exec-file .*\n", 					NULL, {-1, -1, -1, -1, -1, -1}},
  
      /* core-file */
--- 525,529 ----
  	
      /* exec-file (just used internally) */
!     {"[ ]*ex[ec-file]*.*\n", 				NULL, {-1, -1, -1, -1, -1, -1}},
  
      /* core-file */
***************
*** 519,523 ****
--- 536,545 ----
      /* end of define or document */
      {"[ ]*end[ ]*.*", 						NULL, {-1, -1, -1, -1, -1, -1}},
+     
+     /* info source */
+     {"[ ]*info[ ]+source[ ]*\n",			NULL, {-1, -1, -1, -1, -1, -1}},
  
+     /* file */
+     {"[ ]*file .*\n", 						NULL, {-1, -1, -1, -1, -1, -1}},
      NULL
  };
diff -rc2 v1.04/global.h v1.05/global.h
*** v1.04/global.h	Tue May  7 14:59:20 1991
--- v1.05/global.h	Mon Sep 23 16:04:23 1991
***************
*** 207,213 ****
  extern PatternRec       dataPattern[]; 	/* data display pattern */
  
  extern Boolean 	Echo;			/* echo dbx output onto window ? */
- extern Boolean	Prompt;			/* command or program input ? */
  extern Boolean	Parse;			/* flag for parser */
  extern Boolean	FalseSignal;		/* real/false signal ? */
  extern Boolean	PopupMode;		/* True if graphical display */
--- 207,216 ----
  extern PatternRec       dataPattern[]; 	/* data display pattern */
  
+ #ifndef GDB
  extern Boolean 	Echo;			/* echo dbx output onto window ? */
  extern Boolean	Parse;			/* flag for parser */
+ #endif	/* not GDB */
+ extern Boolean	Prompt;			/* command or program input ? */
+ 
  extern Boolean	FalseSignal;		/* real/false signal ? */
  extern Boolean	PopupMode;		/* True if graphical display */
***************
*** 225,229 ****
  
  #ifdef GDB
- extern Boolean 	Filter;			/* filter dbx output (if Echo == false) ? */
  extern void 		display_info_handler();
  extern void 		break_handler();
--- 228,231 ----
***************
*** 232,234 ****
--- 234,245 ----
  extern void 		info_line_handler();
  extern void 		info_break_handler();
+ extern void 		info_source_handler();
+ extern void 		query_gdb();
+ extern void 		read_until_prompt();
+ extern void 		read_gdb();
+ extern void 		unknown_output();
+ extern void 		write_dbx_available();
+ extern void 		query_gdb_directories();
+ extern void 		show_is_undefined();
+ extern void 		read_source_file();
  #endif
diff -rc2 v1.04/handler.c v1.05/handler.c
*** v1.04/handler.c	Wed Apr  3 14:13:41 1991
--- v1.05/handler.c	Fri Sep 20 16:04:35 1991
***************
*** 89,94 ****
--- 89,96 ----
  #endif
  
+ #ifndef GDB
  Boolean		Echo = True;		/* display dbx output if true */
  static Boolean	Skip_func_handler = False;
+ #endif
  
  /*  Display text starting from the top position specified by pos */
diff -rc2 v1.04/parser.c v1.05/parser.c
*** v1.04/parser.c	Tue Jan 15 11:05:07 1991
--- v1.05/parser.c	Fri Sep 20 16:04:38 1991
***************
*** 95,99 ****
--- 95,101 ----
  
  Tokens 	Token;			/* gloabl token structure */
+ #ifndef GDB
  Boolean	Parse = True;		/* Parse flag for parse routine */
+ #endif
  
  /*
diff -rc2 v1.04/patchlevel.h v1.05/patchlevel.h
*** v1.04/patchlevel.h	Mon Jul 15 16:03:21 1991
--- v1.05/patchlevel.h	Wed Sep 11 16:53:48 1991
***************
*** 1 ****
! #define PATCHLEVEL 2
--- 1 ----
! #define PATCHLEVEL 3
diff -rc2 v1.04/source.c v1.05/source.c
*** v1.04/source.c	Thu May 30 17:53:57 1991
--- v1.05/source.c	Fri Sep 20 16:04:31 1991
***************
*** 619,624 ****
      for (i=0; dirList[i]; i++) {
      sprintf(command, "directory %s\n", dirList[i]);
!     Parse = False;
!     query_dbx(command);
      }
  #else /* not NeXT */
--- 619,623 ----
      for (i=0; dirList[i]; i++) {
      sprintf(command, "directory %s\n", dirList[i]);
!     query_gdb (command, PARSE_OFF | ECHO_OFF | FILTER_OFF);
      }
  #else /* not NeXT */
***************
*** 630,641 ****
  #ifdef GDB
      sprintf(command, "directory %s\n", list);
  #else
      sprintf(command, "use %s\n", list);
- #endif /* GDB */
      Parse = False;
      query_dbx(command);
  #endif /* not NeXT */
  }
  
  
  /*  Returns the full pathname of a given file.
--- 629,644 ----
  #ifdef GDB
      sprintf(command, "directory %s\n", list);
+     query_gdb (command, PARSE_OFF | ECHO_OFF | FILTER_OFF);
  #else
      sprintf(command, "use %s\n", list);
      Parse = False;
      query_dbx(command);
+ #endif /* GDB */
  #endif /* not NeXT */
  }
  
+ #ifdef GDB	/* (PW)11SEP91 : for gdb 4.0 */
+ extern char cdir[];	/* compilation directory */
+ #endif
  
  /*  Returns the full pathname of a given file.
***************
*** 659,662 ****
--- 662,673 ----
  	else if (strcmp(dirList[i], ".") == NULL)
  	     sprintf(pathname, "%s/%s", cwd, filename);
+ 	     
+ #ifdef GDB	/* (PW)(SH)11SEP91 : for gdb 4.0 */
+ 	else if (strcmp(dirList[i], "$cwd") == NULL)
+ 	     sprintf(pathname, "%s/%s", cwd, filename);
+ 	else if (strcmp(dirList[i], "$cdir") == NULL)
+ 	     sprintf(pathname, "%s/%s", cdir, filename);
+ #endif /* GDB */
+ 
  	else if (*dirList[i] == '/' || *dirList[i] == '~')
  	     sprintf(pathname, "%s/%s", dirList[i], filename);
***************
*** 730,734 ****
  {
  #ifdef GDB
!     query_dbx("info line\n");
  #else
      query_dbx("file\n");
--- 741,745 ----
  {
  #ifdef GDB
!     query_gdb ("info line\n", PARSE_ON | ECHO_OFF | FILTER_OFF);
  #else
      query_dbx("file\n");
diff -rc2 v1.04/xdbx.c v1.05/xdbx.c
*** v1.04/xdbx.c	Mon Jul 15 15:50:50 1991
--- v1.05/xdbx.c	Wed Sep 11 16:57:35 1991
***************
*** 72,76 ****
  
  #ifdef GDB
! #define XGDBVERSION	"1.04"
  #endif
  
--- 72,76 ----
  
  #ifdef GDB
! #define XGDBVERSION	"1.05"
  #endif
  

--
Dan Heller
Z-Code Software    O'Reilly && Associates       Comp-sources-x:
President          Senior Writer                comp-sources-x@uunet.uu.net
argv@z-code.com    argv@ora.com                 [^^^  this address only!]
