xxgdb-1.12.orig/ 40755 1012 1010 0 6224710536 12347 5ustar geyerAlgebraxxgdb-1.12.orig/Imakefile100644 1012 1010 4330 6224427400 14250 0ustar geyerAlgebra #define TARGET_IS_GDB 1 #if TARGET_IS_GDB DEFGDB = -DGDB -DCREATE_IO_WINDOW -g #else DEFGDB = #endif #CC = gcc #if mc68000 /* for SUN 3 */ CCOPTIONS=-m68881 #endif #if defined(SunArchitecture) #if OSMajorVersion >= 4 #if OSMajorVersion == 4 && OSMinorVersion >= 0 #if OSMinorVersion == 1 && OSTeenyVersion == 3 DEFINES = -DSUNOS4 $(DEFGDB) #else DEFINES = -DSUNOS4 -DNEED_STRSTR $(DEFGDB) #endif #else DEFINES = -DSYSV -DSVR4 -DSUNOS4 $(DEFGDB) SYS_LIBRARIES = -lm #endif #else DEFINES = -DOLDSUNOS -DNEED_STRSTR $(DEFGDB) #endif #endif #ifdef UltrixArchitecture #ifdef MipsArchitecture DEFINES = -DBSD -DMIPS $(DEFGDB) #else DEFINES = -DBSD $(DEFGDB) #endif #endif #ifdef PegasusArchitecture DEFINES = -DBSD $(DEFGDB) -DNEED_STRSTR #endif #ifdef AlphaArchitecture DEFINES = -D_BSD $(DEFGDB) #endif #ifdef HPArchitecture DEFINES = $(DEFGDB) -DHPUX -DREAD_ZERO_NOT_EOF #endif #ifdef SGIArchitecture DEFINES = $(DEFGDB) #endif #ifdef IBMArchitecture DEFINES = $(DEFGDB) -DREAD_ZERO_NOT_EOF #endif #ifdef LinuxArchitecture DEFINES = -DSYSV $(DEFGDB) #endif #if defined(NeXTArchitecture) || defined(NextArchitecture) #if OSMajorVersion == 3 #if OSMinorVersion == 0 DEFINES = -DOLDSUNOS $(DEFGDB) -DNEXTOS_3_0 #else DEFINES = -DOLDSUNOS $(DEFGDB) #endif #else DEFINES = -DOLDSUNOS $(DEFGDB) -DNEXTOS_2 #endif #endif # Add to use new multi window format #DEFINES+=-DNEW_INTERFACE # Add to open all windows at startup #DEFINES+=-DOPEN_ALL_WINDOWS mallocc = #malloc.c malloco = #malloc.o DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) SRCS = calldbx.c command.c dbx.c dialog.c datadpy.c filemenu.c \ handler.c parser.c regex.c signs.c signals.c source.c \ utils.c windows.c xdbx.c $(mallocc) OBJS = calldbx.o command.o dbx.o dialog.o datadpy.o filemenu.o \ handler.o parser.o regex.o signs.o signals.o source.o \ utils.o windows.o xdbx.o $(malloco) #if TARGET_IS_GDB ComplexProgramTarget(xxgdb) #else ComplexProgramTarget(xdbx) #endif /* not GDB */ InstallAppDefaults(XDbx) #if TARGET_IS_GDB handler.o: gdb_handler.c parser.o: gdb_parser.c gdb_regex.h #endif /* GDB */ xxgdb-1.12.orig/README100644 1012 1010 1053 6052667140 13324 0ustar geyerAlgebra This is the source files for xxgdb v1.12 (and xdbx 2.1) ---------------------------------------------------------------------- XXGDB is a X window interface to the GDB debugger. This X window interface has been adapted to GDB from the source distribution files of XDBX version 2.1 (patch level 2) which implements an X window interface to the DBX debugger. See XDBX_README for more information on xdbx. See XXGDB_README for more information on xxgdb. Imakefile defines 'TARGET_IS_GDB' to build xxgdb. Undefine this macro to build xdbx. xxgdb-1.12.orig/README.NEW_INTERFACE100644 1012 1010 2605 5667746655 15364 0ustar geyerAlgebraBy adding -DNEW_INTERFACE to the DEFGDB line in the Imakefile, you will be compiling xxgdb to use the new multi-window format. This format will let you choose which sections of xxgdb you wish to use by toggling the Source Display, Command Buttons, and Variable Display windows ON or OFF. The toggle buttons are located at the bottom of the main GDB interaction window. Along with these Toggle buttons for the windows. I have added another Quit button, so the Command Buttons window doesn't have to be activated just for a quick exit. There are two alternative to startup. If you want all of the display windows active at startup, add -DOPEN_ALL_WINDOWS to the DEFGDB line in the Imakefile, right after where you have added -DNEW_INTERFACE. This will open the Source Display, Command Buttons, and Variable Display windows at startup. If you don't just the main xxgdb window will be displayed. (I prefer this one). Oh yeah, don't forget to replace the XDbx.ad file with the new XDbx.NEW_INTERFACE file. Otherwise things will not look good at all and might not run. Dean. ------------------------------------------------------------------------ Dean Michaels - dean@trlabs.CA Phone: (403) 441-3818 Computer Systems Administrator Fax: (403) 441-3600 TRLabs - Telecommunications Research Laboratories #800 Park Plaza, 10611-98 Ave., Edmonton, Alberta, Canada, T5K 2P7 xxgdb-1.12.orig/XDBX_README100644 1012 1010 1710 5667746461 14170 0ustar geyerAlgebra Xdbx Version 2.1 ~~~~~~~~~~~~~~~~ This is the source distribution of xdbx, version 2.1 for X11R4 only. Xdbx implements an X window system interface to the dbx debugger. It uses X11R4 Xt Intrinsics and Athena widgets. Xdbx supports dbx on the Sun 3, Sun 4 workstations, and the DECstation 3100. Changes since version 2.0 + conversion to R4 + addition of icon + text selection behavior + bug fixes and enhancement Xdbx has been tested on the following platforms: o Sun 4 running SunOS 4.0.3 o Sun 3 running SunOS 4.1 o Sun 3 running SunOS 4.0.3 o DECStation 3100 running Ultrix 3.1 o OpenWindows 1.1, 2.0 o Window managers: mwm, twm, olwm Bugs: o xdbx may get into an infinte loop while running on the DECstation 3100 Please send comments and bug reports to: Po Cheung cheung@sw.mcc.com Microelectronics and Computer Technology Corporation -- or -- po@cerc.utexas.edu University of Texas at Austin xxgdb-1.12.orig/XDbx.ad100644 1012 1010 4346 6224427400 13621 0ustar geyerAlgebra! ! Xdbx 2.1 Application defaults file ! *background: snow1 *foreground: black *fileWindow*background: snow2 *messageWindow.background: snow2 *commandWindow.background: snow2 *Scrollbar.foreground: black *allowShellResize: True *borderWidth: 1 *font: fixed *vpane.width: 550 *fileWindow*font: variable *fileLabel.width: 500 *lineLabel.width: 50 *sourceForm.preferredPaneSize: 320 *sourceWindow.leftMargin: 35 *sourceWindow.scrollHorizontal: whenNeeded *sourceWindow.translations: #override \n\ : SelectStart() SelectWord() \n\ Shift: Update(warp) SelectEnd() PrintSelection() \n\ : Update(warp) SelectEnd() \n\ Down: next-line() Update()\n\ Up: previous-line() Update() \n\ CtrlL: redraw-display() Update() \n\ CtrlN: next-line() Update() \n\ CtrlP: previous-line() Update() \n\ CtrlV: next-page() Update() \n\ CtrlZ: scroll-one-line-up() Update() \n\ MetaV: previous-page() Update() \n\ MetaZ: scroll-one-line-down() Update() \n\ :Meta\>: end-of-file() Update() \n\ :Meta]: forward-paragraph() Update() \n\ :Meta[: backward-paragraph() Update() *messageWindow*font: variable *messageWindow.min: 30 *messageWindow.max: 30 *dialogWindow.preferredPaneSize: 200 *dialogWindow.resizeToPreferred: True *dialogWindow.translations: #override \n\ : SelectStart() SelectWord() \n\ Shift: SelectEnd() PrintSelection() \n\ : SelectEnd() \n *commandWindow.preferredPaneSize: 135 *commandWindow.skipAdjust: True !*commandWindow.hSpace: 14 !*commandWindow.vSpace: 10 !*Command.height: 20 !*Command.width: 60 *List.columnSpacing: 10 *displayWindow.preferredPaneSize: 50 *displayWindow.skipAdjust: True *displayWindow.scrollVertical: whenNeeded *displayWindow.scrollHorizontal: whenNeeded *displayWindow.translations: #override \n\ : SelectStart() SelectWord() \n\ Shift: SelectEnd() PrintSelection() \n\ : SelectEnd() \n *popup*showGrip: False xxgdb-1.12.orig/XXGDB_README100644 1012 1010 35415 6052666661 14320 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1994 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * ***************************************************************************** * * Modifications for use under System V * * Copyright 1990 Bull Worldwide Information Systems, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Bull Worldwide * Information Systems not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. Bull makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * BULL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL BULL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to SYSV: James Tsillas * March, 1991 * ***************************************************************************** * * Note that this software uses some files which are * Copyright (C) 1985 Free Software Foundation, Inc. * See copyright header in regex.c and regex.h. * *****************************************************************************/ Please send XDBX comments and bug reports to: Po Cheung cheung@sw.mcc.com Microelectronics and Computer Technology Corporation -- or -- po@cerc.utexas.edu University of Texas at Austin Please send XXGDB comments and bug reports to: Pierre Willard pierre@eng.sun.com Thomson Consumer Electronics, Inc. XXGDB version 1.12 ------------------ >> SEE ALSO XDBX DOCUMENTATION << >> SEE ALSO xxgdb.man DOCUMENTATION << XXGDB is a X window interface to the GDB debugger. GDB must be accessible in the current path. xxgdb should run gdb 4.x (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 implements an X window interface to the DBX debugger. See the XDBX_README file for more information on XDBX. XXGDB has been originally tested on Sparc workstation running Solaris It should also run on SUN OS. To build, xxgdb, first build the makefile by using 'xmkmf' or other shell script using 'imake'. Also, any System V should be able to build by setting the -DSYSV flag. SCO Unix also requires the -Dsco flag. Bull DPX/2 [23]00 requires the -Dncl_mr flag as well as -DSYSV. Some systems may also need to set -DUSG to use the GNU malloc instead of the native one. The GNU malloc works much quicker and is much more reliable. SCO Unix requires GNU malloc to work correctly. GNU malloc is not provided here, you should get malloc.c and getpagesize.h from the source of gdb. Also note that if building on SCO you must also link with -lsocket and if building on DPX/2 you must also link with -linet. You will need the R4 release of X11 for both. - When compiled with -DCREATE_IO_WINDOW, xxgdb will use a separate io window to talk to gdb, so program output is not confused with gdb output. This is not the default. Link with -lsocket is necessary in that case. Type command 'iowin' to create io window. Also the program xxgdbiowin has to be compiled because it is used for this io window. - When compiled with -DNEW_INTERFACE -DOPEN_ALL_WINDOWS, xxgdb uses a new interface with 4 different X windows for the source, the commands, the buttons and the display window. See README.NEW_INTERFACE and XDbx.NEW_INTERFACE. - When linking on SunOS 4.1, it could happen that you get the following error when linking : ld: Undefined symbol _get_wmShellWidgetClass _get_applicationShellWidgetClass It is a dynamic linking problem. I am not sure why it happens. Anyway, you can either do a static link (gcc -static), or just set the execution bit, and the program will run. - 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 in the source window. - The file button will execute 'core-file ' if the file is named 'core', 'list :1' if the file is not executable and 'exec-file symbol-file if the file is executable. Executable files are displayed with a trailing '*' character. - For systems which do not have the ANSI strstr function in their library, one is included in gdb_parser.c and is compiled if NEED_STRSTR is defined. - if you define UNDISPWIN when compiling, then the display window will disappear when there is nothing to display. (eg, add -DUNDISPWIN in DEFGDB definition in Imakefile). See display_info_handler function in gdb_handler.c - Copy the application default file (XDbx.ad) into your home directory or into the X '/usr/lib/X11/app-defaults' directory (without the .ad suffix) (eg, 'cp -p XDbx.ad ~/XDbx'). - The name of the debugger called by xxgdb is by default 'gdb'. It can be overridden with the environment variable XXGDB_DEBUGGER. WARNING : by default prompt is the name of the debugger enclosed in parenthesis followed by a space. So if the prompt is still "(gdb) ", you HAVE TO use -db_prompt "gdb" - DO NOT modify the gdb prompt (using the 'set prompt' command). XXGDB assumes that the gdb prompt is 'gdb' or the XXGDB_DEBUGGER environment variable if defined. There are new application resources and command line args: - db_name can be used to specify the name of the debugger to override the default "gdb" (instead of using an env. variable). - db_prompt can be used to specify to xgdb the string to be used by the debugger as a prompt. The default is to expect the prompt used by the debugger to be the name of the debugger enclosed in parenthesis. This is no good for gdbvx, which expects a prompt of (gdb). - i can be used the name of the command file automatically loaded by gdb. The default is ".gdbinit" file. To build xxgdb, 'Imakefile' defines : #define TARGET_IS_GDB 1 XXGDB version BUG LIST ---------------------- This version of XXGDB is pretty much working. The following bugs will probably be fixed in future versions. - 'define' command of GDB is not completely supported by xxgdb 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 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. - Repeat command of XXGDB behaves slighlty differently from the one in GDB. - '~' character in filename is not expanded by xxgdb. FAQ --- Why do ^M characters appear at the end of each line ? This is because the terminal settings are WRONG. The possible reason is that xxgdb was compiled with gcc and NON ANSI include files. Solution : run 'fixincludes' of gcc and/or check the '-I' options. In particular, on Sun, make sure you do not have /usr/include in the include path. SunOS 5.3: ---------- Compile with : gcc -O -I/usr/openwin/include -DSYSV -DSVR4 -DSUNOS4 -DGDB -DCREATE_IO_WINDOW Link with : -lXaw -lXmu -lXt -lXext -lX11 -lm -lsocket SunOS 4.1: ---------- Compile with : gcc -O -I/usr/openwin/include -DGDB -DCREATE_IO_WINDOW Link with : -lXaw -lXmu -lXt -lXext -lX11 -lm -static AIX 2.3 (RS6000): ----------------- Compile with : xlc -qlanglvl=ansi -I/usr/openwin/include -DSYSV -D_POSIX_SOURCE -D_ALL_SOURCE -DREAD_ZERO_NOT_EOF -DBSD=45 -DGDB -g Link with : -L/usr/openwin/lib/R5 -lXaw -lXmu -lXt -lXext -lX11 -lm -lc XXGDB history ------------- 1.0 December 1990. 1.01 January 1991 (posted to comp.sources.x news group) Fix bug with display command (when displaying structures). Fix bug with undisplay command (display window went blank). Add XXGDB no warranty message at start-up. 1.02 February 1991. Add source files selection in file button. Special test for core file in file button. Fix bug includeDir resource. Fix bug source file directories. Add patches for SUN-OS3. Add strstr function in gdb_parser.c (with #ifdef NEED_STRSTR) Remove bad test for MIPS and BSD in case of GDB. 1.03 April 1991 Miscellaneous patches for lint. Port to SYSV + SCO +SYSV32. Fix bug up/down/frame when arguments are on several lines. Fix bug in UpdateMessageWindow when arguments are too long. Fix bug define commands in .gdbinit or source files Add db_name and db_prompt option (GWC) 1.04 May 1991 display command print all error messages (if any). fix bug display C structures. several patches for more generic BSD machines (JBL) patches for NeXT because some GDB incompatibilities. display gdb messages when executing list command. 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). 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) 1.07 February 1992 Fix problem xxgdb for NeXT because of test for gdb-4.0. Fix 'info break' problem with gdb 4.5 (Ken Mandelberg) New buttons and misc. improvements (Amir J. Katz)(AJK) 1.08 November 1993 Update for gdb 4.11. Cleanup + Alpha port + NEW_INTERFACE from Dean Michaels, TRLabs. 1.09 April 1994 New -gdbinit resource and command line option to specify init filename. Fix problem 'Inappropriate ioctl for device' on Solaris. Fix bugs displaying C++ structures (Klamer). Use reliable signals on SYSV (Iand). Fix problem compiling with 'cc'. 1.10 August 1994 Cleanup calldbx.c (svalente@MIT.EDU) Add fix for Modula-2 (Norbert Kiesel) Fix bug command too long for fputs. Port to RS6000 (AIX 2.3 rs6000) Add configurable tab widths (Matt Day ) 1.11 March 1995 Misc. updates. 1.12 November 1995 Do not define signal for linux in signals.c (schweikh@ito.uni-stuttgart.de) In global.h define alloca only in certain cases. Test for MAXPATHLEN already defined (in global.h) Update Imakefile for different architectures (Philippe.Defert@cern.ch) Update for NeXT (doug@foxtrot.ccmrc.ucsb.edu) Update for gdb-4.14 : different address format when step/next/up/down. -------------------------- xxgdb-1.12.orig/bitmaps.h100644 1012 1010 21243 5526737012 14300 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: April 9, 1990 * *****************************************************************************/ /* bitmaps.h * * Contain bitmap data for a 48x48 and a 64x64 xdbx icon, and the * stop sign, execution arrow, up-down arrow, and bomb sign used * in the source window. */ /* * iand 94/02/10 remove compiler warnings */ /* bitmap data for 48x48 xdbx icon */ #define xdbx48_width 48 #define xdbx48_height 48 #define xdbx48_bits (char *)xdbx48_bits_u static unsigned char xdbx48_bits_u[] = { 0xff, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0xfe, 0x1f, 0x00, 0x00, 0x00, 0xf0, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0x78, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0x3c, 0xf8, 0x7f, 0x00, 0x02, 0x00, 0x3c, 0xf0, 0xff, 0x00, 0x02, 0x00, 0x1e, 0xe0, 0xff, 0x01, 0x04, 0x00, 0x0f, 0xe0, 0xff, 0x01, 0x04, 0x80, 0x07, 0xc0, 0xff, 0xe3, 0xff, 0xc0, 0x03, 0x80, 0xff, 0x1f, 0x01, 0xc7, 0x03, 0x00, 0xff, 0x27, 0x01, 0xf8, 0x01, 0x00, 0xff, 0xcf, 0x60, 0xf0, 0x10, 0x00, 0xfe, 0x1f, 0x90, 0xf8, 0x10, 0x00, 0xfc, 0x3f, 0x90, 0xbc, 0x08, 0x00, 0xfc, 0x7f, 0x60, 0x3c, 0x07, 0x00, 0xfe, 0xff, 0x03, 0x1e, 0x02, 0x00, 0xfe, 0xff, 0x04, 0x0f, 0x02, 0x00, 0xff, 0xff, 0x85, 0x07, 0x04, 0x80, 0xff, 0xff, 0xc3, 0xc3, 0x04, 0x80, 0xdf, 0xff, 0xe7, 0x23, 0x05, 0x84, 0x9f, 0xff, 0xef, 0x25, 0x09, 0xc8, 0x19, 0xff, 0xf7, 0xc4, 0x08, 0xf0, 0x18, 0xfe, 0x7b, 0x03, 0x08, 0xc0, 0x1f, 0xfc, 0x3d, 0x00, 0x08, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xc0, 0x1f, 0x78, 0x7f, 0x00, 0x08, 0xf0, 0x98, 0xbd, 0xff, 0x00, 0x08, 0xc8, 0x59, 0xde, 0xff, 0x61, 0x08, 0x84, 0x5f, 0xef, 0xff, 0x91, 0x04, 0x80, 0x9f, 0xc7, 0xff, 0x93, 0x04, 0x80, 0x9f, 0x87, 0xff, 0x67, 0x04, 0x00, 0xdf, 0x03, 0xff, 0x0f, 0x02, 0x00, 0xfe, 0x19, 0xfe, 0x1f, 0x02, 0x00, 0xfe, 0x24, 0xfe, 0x1f, 0x07, 0x00, 0x7c, 0x24, 0xfc, 0xff, 0x08, 0x00, 0x78, 0x18, 0xfa, 0x7f, 0x10, 0x00, 0x3c, 0x00, 0xf2, 0xff, 0x10, 0x00, 0xde, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x8f, 0x0f, 0xe0, 0xff, 0x01, 0x80, 0x87, 0xf0, 0xff, 0xff, 0x03, 0x80, 0x87, 0x00, 0x84, 0xff, 0x07, 0xc0, 0x43, 0x00, 0x84, 0xff, 0x07, 0xe0, 0x21, 0x00, 0x02, 0xff, 0x0f, 0xf0, 0x00, 0x00, 0x02, 0xfe, 0x1f, 0x78, 0x00, 0x00, 0x00, 0xfc, 0x3f, 0x78, 0x00, 0x00, 0x00, 0xfc, 0x3f, 0x3c, 0x00, 0x00, 0x00, 0xf8, 0x7f, 0x1e, 0x00, 0x00, 0x00, 0xf0, 0xff}; /* bitmap data for 64x64 xdbx icon */ #define xdbx64_width 64 #define xdbx64_height 64 #define xdbx64_bits (char *)xdbx64_bits_u static unsigned char xdbx64_bits_u[] = { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfc, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xf8, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3e, 0xf8, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x0f, 0xe0, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x80, 0x0f, 0xc0, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xc0, 0x07, 0xc0, 0xff, 0x3f, 0x00, 0x01, 0x00, 0xe0, 0x03, 0x80, 0xff, 0x7f, 0x00, 0x02, 0x00, 0xf0, 0x01, 0x00, 0xff, 0xff, 0x00, 0x04, 0x00, 0xf8, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x04, 0x00, 0xf8, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x04, 0x00, 0x7c, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x01, 0x3e, 0x04, 0x00, 0xf8, 0xff, 0x07, 0x00, 0x1e, 0x1f, 0x04, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xe0, 0x0f, 0x04, 0x00, 0xf0, 0xff, 0x0f, 0x80, 0x81, 0x07, 0x02, 0x00, 0xe0, 0xff, 0x1f, 0x40, 0xc2, 0x07, 0x01, 0x00, 0xc0, 0xff, 0xbf, 0x41, 0xe2, 0x8b, 0x01, 0x00, 0xc0, 0xff, 0x7f, 0x82, 0xf1, 0xd1, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x02, 0xf8, 0x60, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x01, 0x7c, 0x40, 0x00, 0x00, 0xf8, 0xfe, 0xff, 0x01, 0x7c, 0x80, 0x00, 0x00, 0xfc, 0xfc, 0xff, 0x03, 0x3e, 0x80, 0x00, 0x00, 0xfc, 0xfc, 0xff, 0x03, 0x1f, 0x00, 0x01, 0x00, 0xfe, 0xf8, 0xff, 0x87, 0x0f, 0x03, 0x01, 0x00, 0xff, 0xf0, 0xff, 0xcf, 0x87, 0x04, 0x02, 0x08, 0xff, 0xe0, 0xff, 0xcf, 0x87, 0x04, 0x02, 0x10, 0xe7, 0xe0, 0xff, 0xe7, 0x03, 0x03, 0x02, 0xe0, 0xe3, 0xc0, 0xff, 0xf3, 0x01, 0x00, 0x04, 0x80, 0xff, 0x80, 0xff, 0xf9, 0x00, 0x00, 0x04, 0x80, 0xff, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x04, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x80, 0xff, 0x00, 0x7e, 0xfe, 0x01, 0x00, 0x04, 0x80, 0xff, 0x00, 0x3e, 0xff, 0x1b, 0x00, 0x04, 0xe0, 0xe3, 0x00, 0x9f, 0xff, 0x27, 0x00, 0x04, 0x10, 0xe7, 0xb0, 0xcf, 0xff, 0x2f, 0x30, 0x02, 0x08, 0xff, 0xc8, 0xe7, 0xff, 0x1f, 0x48, 0x02, 0x00, 0xff, 0xe8, 0xe7, 0xff, 0x1f, 0x48, 0x02, 0x00, 0xfe, 0xf0, 0xc3, 0xff, 0x3f, 0x30, 0x01, 0x00, 0xfc, 0xf0, 0xc1, 0xff, 0x3f, 0x00, 0x01, 0x00, 0xfc, 0xf8, 0x80, 0xff, 0x7f, 0x80, 0x00, 0x00, 0xf8, 0x7c, 0x00, 0xff, 0xff, 0x80, 0x00, 0x00, 0xf0, 0x7c, 0x18, 0xfe, 0xff, 0xc1, 0x00, 0x00, 0xe0, 0x3e, 0x24, 0xfe, 0xff, 0x61, 0x00, 0x00, 0xc0, 0x1f, 0x24, 0xfc, 0xff, 0xd3, 0x00, 0x00, 0x80, 0x0f, 0x18, 0xf8, 0xff, 0x8f, 0x01, 0x00, 0xc0, 0x07, 0x00, 0xf4, 0xff, 0x0f, 0x01, 0x00, 0xe0, 0x0f, 0x00, 0xe4, 0xff, 0x1f, 0x02, 0x00, 0xf0, 0x39, 0x00, 0xf8, 0xff, 0x1f, 0x04, 0x00, 0xf0, 0xc9, 0x03, 0xc0, 0xff, 0x3f, 0x04, 0x00, 0xf8, 0x08, 0xfc, 0xff, 0xff, 0x7f, 0x04, 0x00, 0x7c, 0x04, 0x00, 0x01, 0xff, 0x7f, 0x00, 0x00, 0x3e, 0x02, 0x00, 0x01, 0xff, 0xff, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0xfe, 0xff, 0x01, 0x00, 0x1f, 0x00, 0x80, 0x00, 0xfc, 0xff, 0x03, 0x80, 0x0f, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0xc0, 0x07, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x07, 0xe0, 0x03, 0x00, 0x00, 0x00, 0xf0, 0xff, 0x0f, 0xe0, 0x03, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x1f, 0xf0, 0x01, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x3f, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff}; /* bitmap data for stop sign */ #define stop_width 16 #define stop_height 16 #define stop_x_hot -1 #define stop_y_hot -1 #define stop_bits (char *)stop_bits_u static unsigned char stop_bits_u[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xd0, 0x01, 0x5c, 0x07, 0x54, 0x05, 0x54, 0x05, 0x14, 0x04, 0x0c, 0x04, 0x08, 0x04, 0x18, 0x06, 0xf0, 0x03, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00}; /* bitmap data for arrow sign */ #define arrow_width 16 #define arrow_height 16 #define arrow_x_hot -1 #define arrow_y_hot -1 #define arrow_bits (char *)arrow_bits_u static unsigned char arrow_bits_u[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x01, 0x80, 0x03, 0xff, 0x07, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x07, 0x80, 0x03, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* bitmap data for up-down (outlined arrow) sign */ #define updown_width 16 #define updown_height 16 #define updown_x_hot -1 #define updown_y_hot -1 #define updown_bits (char *)updown_bits_u static unsigned char updown_bits_u[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x01, 0x80, 0x03, 0xff, 0x06, 0x01, 0x0c, 0x01, 0x0c, 0xff, 0x06, 0x80, 0x03, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* bitmap data for bomb sign */ #define bomb_width 16 #define bomb_height 16 #define bomb_bits (char *)bomb_bits_u static unsigned char bomb_bits_u[] = { 0x00, 0x00, 0x69, 0x00, 0x94, 0x00, 0x8a, 0x00, 0xc0, 0x01, 0xc5, 0x01, 0xf0, 0x07, 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0d, 0xf8, 0x0d, 0xf8, 0x0d, 0xf0, 0x06, 0xf0, 0x07, 0xc0, 0x01, 0x00, 0x00}; xxgdb-1.12.orig/bsd_regex.h100644 1012 1010 11710 5662460665 14611 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * *****************************************************************************/ /* bsd_regex.h * * Regular expression pattern matching for Berkeley dbx. * * The reg_token array indicates the register no. for each token type. * reg_token[0] : message * reg_token[1] : stop number * reg_token[2] : function name * reg_token[3] : line number * reg_token[4] : file name * reg_token[5] : display command output */ #define TK_MESG 0 #define TK_STOP 1 #define TK_FUNC 2 #define TK_LINE 3 #define TK_FILE 4 #define TK_DISP 5 #define O_EXEC_GDB 0 #define O_DONE 1 #define O_STOPAT 2 #define O_STOPIN 3 #define O_UPDOWN 4 #define O_BELL 5 #define O_LIST 6 #define O_FILE 7 #define O_SEARCH 8 #define O_PRINT 9 #define O_DEBUG 10 #define C_ANY -1 #define C_EXEC 0 #define C_STOPAT 1 #define C_STOPIN 2 #define C_UPDOWN 3 #define C_DELETE 4 #define C_FUNC 5 #define C_FILE 6 #define C_USE 7 #define C_LIST 8 #define C_SEARCH 9 #define C_PRINT 10 #define C_STATUS 11 static PatternRec output_pattern[] = { /* exec */ {"\\(.*\n\\)*.*\\(\[[0-9]+\\] \\)?\\(\\(stopped\\|Bus error\\|Segmentation \ fault\\|Interrupt\\) in \\([^ ]+\\) at line \ \\([0-9]+\\)\\( in file \"\\([^ ]+\\)\"\\)?\\)\n", NULL, {3, -1, 5, 6, 8, -1} }, /* done */ {"\\(.*\n\\)*execution completed", NULL, {-1, -1, -1, -1, -1, -1} }, /* stop at */ {"\\[\\([0-9]+\\)\\] stop at \\(\"\\([^ ]+\\)\":\\)?\\([0-9]+\\)\n", NULL, {-1, 1, -1, 4, 3, -1} }, /* stop in */ {"\\[\\([0-9]+\\)\\] stop in \\([^ ]+\\)\n", NULL, {-1, 1, 2, -1, -1, -1} }, /* up, down */ {"\\([^ ]+\\)(.*), line \\([0-9]+\\) in \"\\([^ ]+\\)\"\n", NULL, {-1, -1, 1, 2, 3, -1} }, /* bell */ {"\\(not that many levels\n\\|can't continue execution\n\\)", NULL, {-1, -1, -1, -1, -1, -1} }, /* list */ {"\\([ ]*[0-9]+.*\n\\)*[ ]+\\([0-9]+\\)[ ]+{.*\n", NULL, {-1, -1, -1, 2, -1, -1} }, /* file */ {"\\([^ ]*\\)\n", NULL, {-1, -1, -1, -1, 1, -1} }, /* search */ {"[ ]*\\([0-9]+\\).*\n", NULL, {-1, -1, -1, 1, -1, -1} }, /* print, display */ {"\\(warning: .*\n\\)?\\(\\(.*\\) = .*\n\\(.*\n\\)*\\)", NULL, { 3, -1, -1, -1, -1, 2} }, NULL }; static PatternRec command_pattern[] = { {"[ ]*\\(run\\|r\\|cont\\|c\\|next\\|n\\|step\\|s\\|return\\)", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(stop\\|st\\)[ ]+at[ ]+[0-9]+", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(stop\\|st\\)[ ]+in[ ]+[^ ]+", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(where\\|up\\|down\\)", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(delete\\|d\\)", NULL, {-1, -1, -1, 1, -1, -1}}, {"[ ]*func[ ]*\\([^ ]+\\)[ ]*", NULL, {-1, -1, 1, -1, -1, -1}}, {"[ ]*file[ ]*", NULL, {-1, -1, -1, -1, 1, -1}}, {"[ ]*use[ ]*", NULL, {-1, -1, -1, -1, 1, -1}}, {"[ ]*list[ ]*", NULL, {-1, -1, -1, -1, 1, -1}}, {"[ ]*\\(/\\|\?\\)", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*print[ ]*[^ ]+", NULL, {-1, -1, -1, -1, -1, -1}}, NULL }; xxgdb-1.12.orig/calldbx.c100644 1012 1010 26121 6224427401 14237 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* calldbx.c * * Set up communication between dbx and xdbx using pseudo terminal, and * call dbx. * * open_master(): Open the master side of pty. * open_slave(): Open the slave side of pty. * calldbx(): Invoke dbx. * create_io_window(): create an io window for gdb to use */ #include #include #include #include #include "global.h" #if !(defined(OLDSUNOS) || defined(BSD)) #include #else #include #endif #ifdef CREATE_IO_WINDOW #include #include #endif /* CREATE_IO_WINDOW */ #ifdef SVR4 #define MASTER_CLONE "/dev/ptmx" #include #include #include #include #endif /* SVR4 */ #if (defined(BSD) && (BSD < 44)) || defined(ultrix) #define OLDBSD #endif #if defined(TIOCSCTTY) #define NEWBSD #endif extern char *progname; /* (MJH) */ FILE *dbxfp = NULL; /* file pointer to dbx */ int dbxpid = 0; /* dbx process id */ static XtInputId 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; #ifdef CREATE_IO_WINDOW char iowintty[] = "/dev/ttyp0"; int iowinpid = 0; #endif /* CREATE_IO_WINDOW */ /* * Xdbx talks to dbx through a pseudo terminal which is a pair of master * and slave devices: /dev/pty?? and /dev/tty??, where ?? goes from p0 to * sf (system dependent). The pty is opened for both read and write. */ 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; #ifndef sco for (c='p'; c<'t'; c++) { for (i=0; i<16; i++) { #else c = 'p'; for (i=0; i<8; i++) { #endif pty[8] = c; pty[9] = "0123456789abcdef"[i]; if ((master = open(pty, O_RDWR)) >= 0) return (master); } #ifndef sco } #endif #endif /* SVR4 */ #ifdef GDB fprintf(stderr, "xxgdb: all ptys in use\n"); #else fprintf(stderr, "xdbx: all ptys in use\n"); #endif exit(1); } /*ARGSUSED*/ static int open_slave(master) int master; { int slave; #ifdef SVR4 /* (MJH) */ char *slave_name = "unknown"; 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 */ } #ifdef CREATE_IO_WINDOW /* use a separate io window to talk to gdb, so program output is not confused with gdb output. */ /* creates an io window which is the program xxgdbiowin running behind an * xterm. This function sets two global variables: * iowintty, a character array which is the resulting ptty of the xterm * iowinpid, an int which is the pid of xxgdbiowin */ void create_io_window () { int pid = fork(); if (pid == -1) { printf("unable to fork\n"); } else if (pid) { /* parent */ char ttypid[40]; int sock; struct sockaddr_un name; sock = socket(AF_UNIX, SOCK_DGRAM, 0); name.sun_family = AF_UNIX; strcpy(name.sun_path, "/tmp/iowindowtty"); bind(sock, (struct sockaddr*)&name, sizeof(struct sockaddr_un)); read(sock, ttypid, 40); sscanf(ttypid, "%[a-z/0-9],%d", iowintty, &iowinpid); close(sock); unlink("/tmp/iowindowtty"); } else { /* child */ /* printf("xterm xterm -l -e xxgdbiowin\n");*/ if (execlp("xterm", "xterm", "-e", "xxgdbiowin", 0)) { printf("exec of 'xterm -e xxgdbiowin' fails\n"); unlink("/tmp/iowindowtty"); } } } #endif /* CREATE_IO_WINDOW */ /* ARGSUSED */ void calldbx(argc, argv) int argc; char *argv[]; { /* * (JBL)10MAY91 : use sgttyb if generic BSD */ #if !(defined(OLDSUNOS) || defined(BSD)) struct termio Termio; #else struct sgttyb Termio; #endif int master; /* file descriptor of master pty */ int slave; /* file descriptor of slave pty */ #ifdef OLDBSD int fd; /* file descriptor of controlling tty */ #endif char *debugger; /* name of executable debugger */ char errmsg[LINESIZ]; #ifdef GDB /* for GDB, we use XXGDB_DEBUGGER instead */ debugger = (char *) getenv("XXGDB_DEBUGGER"); /* first looks up env var */ #else debugger = (char *) getenv("DEBUGGER"); /* first looks up env var */ #endif /* CRL mod 4 3/15/91 GWC if no env var then try app res for db_name */ if (debugger == NULL && app_resources.db_name && strcmp(app_resources.db_name, "") != 0) debugger = XtNewString(app_resources.db_name); if (debugger == NULL) debugger = XtNewString(DEBUGGER); /* CRL mod 4 3/15/91 GWC - allow the user to specify a db_prompt */ if (app_resources.db_prompt && strcmp(app_resources.db_prompt, "") != 0) dbxprompt = XtNewString(app_resources.db_prompt); /* construct dbx prompt string based on the name of debugger invoked */ if (dbxprompt == NULL) { dbxprompt = XtMalloc((4+strlen(debugger)) * sizeof(char)); sprintf(dbxprompt, "(%s) ", debugger); } if (debug) fprintf(stderr,"debugger=\"%s\"\nprompt=\"%s\"\n",debugger,dbxprompt); master = open_master(); dbxpid = fork(); if (dbxpid == -1) { sprintf(errmsg, "%s error: Cannot fork %s\n", progname, debugger); /* (MJH) */ perror(errmsg); exit(1); } else if (dbxpid) { /* * Parent : close the slave side of pty * close stdin and stdout * set the dbx file descriptor to nonblocking mode * open file pointer with read/write access to dbx * set line buffered mode * register dbx input with X */ close(0); close(1); #ifdef _POSIX_SOURCE fcntl(master, F_SETFL, O_NONBLOCK); #else fcntl(master, F_SETFL, O_NDELAY); #endif if((dbxfp = fdopen(master, "r+")) == NULL) /* (MJH) */ { perror("Associating stdio stream with pty master"); exit(1); } /* turn off stdio buffering */ setbuf(dbxfp, NULL); dbxInputId = XtAppAddInput(app_context, master, (XtPointer) XtInputReadMask, read_dbx, NULL); } else { /* * Child : close master side of pty * redirect stdin, stdout, stderr of dbx to pty * unbuffer output data from dbx * exec dbx with arguments */ /* lose controlling tty */ #if defined(NEWBSD) || defined(SVR4) || defined(_POSIX_SOURCE) setsid(); #endif #ifdef OLDBSD if ((fd = open("/dev/tty", O_RDWR)) > 0) { ioctl(fd, TIOCNOTTY, 0); close(fd); } #endif slave = open_slave(master); close(master); /* * Modify local and output mode of slave pty */ /* * (JBL)10MAY91 : use sgttyb if OLDSUN or generic BSD */ #if !(defined(OLDSUNOS) || defined(BSD)) ioctl(slave, TCGETA, &Termio); Termio.c_lflag &= ~ECHO; /* No echo */ Termio.c_oflag &= ~ONLCR; /* Do not map NL to CR-NL on output */ ioctl(slave, TCSETA, &Termio); #else ioctl(slave, TIOCGETP, &Termio); Termio.sg_flags &= ~ECHO; /* No echo */ Termio.sg_flags &= ~CRMOD; /* Do not map NL to CR-NL on output */ ioctl(slave, TIOCSETP, &Termio); #endif dup2(slave, 0); dup2(slave, 1); dup2(slave, 2); if (slave > 2) close(slave); fcntl(1, F_SETFL, O_APPEND); setbuf(stdout, NULL); /* gain controlling tty */ #ifdef NEWBSD ioctl(0, TIOCSCTTY, 0); #endif /* flush stdin ! (for RS6000) FIXME */ argv[0] = debugger; if (debug) { int i=0; fprintf (stderr, "Forking \"%s",argv[i++]); while (argv[i]) { fprintf (stderr, " %s", argv[i++]); } fprintf (stderr, "\"\n"); } execvp(debugger, argv); sprintf(errmsg, "%s error: cannot exec %s", progname, debugger); perror(errmsg); exit(1); } } xxgdb-1.12.orig/command.c100644 1012 1010 66510 6224427401 14252 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * * AJK Changes: Apr-May 1991 * 1. Added new buttons for gdb, dbx, * 2. Free strings allocated by 'XFetchBytes', *****************************************************************************/ /* command.c * * Create the command window, the command buttons and their callbacks. * * CreateCommandPanel() : Create a window with command buttons * CreateButtons() : Create command buttons in panel * AddButton() : Add a command button into the command window * ButtonSet() : Action proc for command button translation * * Command callbacks for the command buttons: * * forwardSearch() : forward string search * reverseSearch() : reverse string search * Search() : call either forwardSearch() or reverseSearch() * PopupSearch() : command callback for search button * DoneSearch() : command callback for DONE button in search panel * CreateSearchPopup() : create search panel * * Command queue manipulation routines: * send_command(): send a command to dbx and record in the queue * get_command(): read command off head of queue * insert_command(): insert command at the head of queue * delete_command(): delete command from head of queue */ #include #include #include #include #include #ifdef _POSIX_SOURCE #include #endif #include #include "global.h" #define REVERSE 0 #define FORWARD 1 Widget commandWindow; /* command panel with buttons */ Boolean PopupMode = False; static int Button; static Widget searchPopupShell, searchPopup; static Widget AddButton(); static Widget button[30]; static char SearchString[BUFSIZ] = ""; /* search string buffer */ static char command[LINESIZ]; static CommandRec *commandQueue = NULL; #ifndef GDB #ifdef BSD static char savedCommand[LINESIZ] = ""; #endif #endif /* not GDB */ /* ARGSUSED */ static void ButtonSet(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { Button = atoi(params[0]); } /* ARGSUSED */ /* Execute the dbx command specifed in client_data */ static void DoIt (w, command, call_data) Widget w; XtPointer command; XtPointer call_data; { /* run, cont, next, step, where, up, down, status */ send_command(command); AppendDialogText(command); } #if !defined(GDB) && defined(BSD) /* >>>>>>>>>> NOT USED FOR GDB <<<<<<<<<<<<<<< */ /* ARGSUSED */ static void Return (w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { char *funcname; int nbytes; funcname = XFetchBytes(display, &nbytes); /* from CUT_BUFFER0 */ if (nbytes == 0) strcpy(command, "return\n"); else { sprintf(command, "return %s\n", funcname); XFree (funcname); /* AJK */ } send_command(command); AppendDialogText(command); } #endif /* NOT GDB && BSD */ #ifdef GDB /* >>>>>>>>>>>>>> GDB ONLY <<<<<<<<<<<<<<<< */ /* here client_data is "break" or "tbreak" */ static void Break(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { XawTextPosition pos; int line; char *funcname; int nbytes; char *s; funcname = XFetchBytes(display, &nbytes); /* from CUT_BUFFER0 */ if (nbytes) { s = funcname; while (*s == ' ') s++; /* skip leading spaces (if any) */ if ((*s >= '0') && (*s <= '9')) sprintf(command, "%s *%s\n",client_data,funcname); else sprintf(command, "%s %s\n",client_data,funcname); XFree (funcname); /* AJK */ } else { if (displayedFile != NULL) { pos = XawTextGetInsertionPoint(sourceWindow); line = TextPositionToLine(pos); sprintf(command, "%s %d\n",client_data,line); } else { UpdateMessageWindow(BREAK_HELP, NULL); bell(0); return; } } send_command(command); AppendDialogText(command); } #else /* >>>>>>>>>> NOT USED FOR GDB <<<<<<<<<<<<<<< */ /* ARGSUSED */ static void Stop_at(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { XawTextPosition pos; int line; if (displayedFile == NULL) { UpdateMessageWindow(STOP_AT_HELP, NULL); bell(0); return; } pos = XawTextGetInsertionPoint(sourceWindow); line = TextPositionToLine(pos); sprintf(command, "stop at %d\n", line); send_command(command); AppendDialogText(command); } /* ARGSUSED */ static void Stop_in(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { char *funcname; int nbytes; funcname = XFetchBytes(display, &nbytes); /* from CUT_BUFFER0 */ if (nbytes == 0) { UpdateMessageWindow(STOP_IN_HELP, NULL); bell(0); return; } sprintf(command, "stop in %s\n", funcname); send_command(command); AppendDialogText(command); XFree (funcname); /* AJK */ } #endif /* NOT GDB */ /* Delete removes the stop_no associated with a given line number. * RemoveStop() is called to undisplay the stop sign only when there * are no more stop_no's associated with that line number. */ /* ARGSUSED */ static void Delete(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { XawTextPosition pos; char *string; int stop_no, line, nbytes; string = XFetchBytes(display, &nbytes); if (nbytes > 0 && (stop_no = atoi(string)) > 0) { sprintf(command, "delete %d\n", stop_no); send_command(command); AppendDialogText(command); XFree (string); /* AJK */ return; } else if (displayedFile) { if (string) { /* AJK: string is non-NULL, but not an int */ XFree (string); string = (char *)NULL; } pos = XawTextGetInsertionPoint(sourceWindow); line = TextPositionToLine(pos); if ((stop_no = LineToStop_no(line))) { sprintf(command, "delete %d\n", stop_no); send_command(command); AppendDialogText(command); return; } } if (string) { /* AJK */ XFree (string); } UpdateMessageWindow(DELETE_HELP, NULL); bell(0); } /* ARGSUSED */ static void Print(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { char *string; int nbytes; if (Button == 3) PopupMode = True; string = XFetchBytes(display, &nbytes); if (nbytes == 0) { UpdateMessageWindow(PRINT_HELP, NULL); bell(0); return; } if (client_data == (XtPointer)0) sprintf(command, "print %s\n", string); else if (client_data == (XtPointer)1) sprintf(command, "print *%s\n", string); send_command(command); #ifdef GDB if (!PopupMode) /* for GDB don't display print if everything goes in a window */ #endif AppendDialogText(command); XFree (string); /* AJK */ } #ifndef GDB /* >>>>>>>>>> NOT USED FOR GDB <<<<<<<<<<<<<<< */ /* ARGSUSED */ static void Func(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { char *funcname; int nbytes; funcname = XFetchBytes(display, &nbytes); if (nbytes == 0) strcpy(command, "func\n"); else { sprintf(command, "func %s\n", funcname); XFree (funcname); /* AJK */ } send_command(command); AppendDialogText(command); } #endif /* NOT GDB */ /* CRL mod 2/19/91 GWC - an callback procedure for the "interrupt" button. * As in SigInt in dialog.c the process is * interrupted with killpg(dbxpid, SIGINT). */ /* add interrupt button that send sigint to inferior gdb, need to have gdb receive SIGINT. */ static void Interrupt(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { signal_interrupt_dbx (); } #ifdef EDIT_BUTTON /* allow invocation of favorite editor from within interface. */ static void EdCallback(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { StartEditor(); } #endif /* EDIT_BUTTON */ /* ARGSUSED */ #ifndef NEW_INTERFACE static #endif void Quit(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { #ifdef SYSV int status; #else union wait status; #endif /* SYSV */ write_dbx("quit\n"); XtDestroyApplicationContext(app_context); kill(dbxpid, SIGKILL); #ifdef SYSV #if 1 /* instead of 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 */ exit(0); } /* ARGSUSED */ static void Display_(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { char *string; int nbytes; string = XFetchBytes(display, &nbytes); sprintf(command, "display %s\n", string); send_command(command); AppendDialogText(command); if (string) /* AJK */ XFree (string); } #ifndef GDB /* Handle dbx commands which need a variable name (whatis,whereis,which,trace). * Command name is passed in client_data. */ static void WhCmds (w, client_data, call_data) /* AJK */ Widget w; XtPointer client_data; XtPointer call_data; { char *string; int nbytes; string = XFetchBytes (display, &nbytes); if (nbytes == 0) { UpdateMessageWindow (WHATIS_HELP, NULL); bell (0); return; } sprintf (command, "%s %s\n", client_data, string); send_command (command); AppendDialogText (command); XFree (string); } /* WhCmds */ #endif /* >>>>>>>>>>>>>> DBX ONLY <<<<<<<<<<<<<<<< */ #ifdef GDB /* >>>>>>>>>>>>>> GDB ONLY <<<<<<<<<<<<<<<< */ /* ARGSUSED */ static void Undisplay(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { char *string; int stop_no, nbytes; string = XFetchBytes(display, &nbytes); if (nbytes != 0) { if ((stop_no = atoi(string)) > 0) sprintf(command, "undisplay %d\n", stop_no); else { UpdateMessageWindow(UNDISPLAY_HELP, NULL); bell(0); return; } XFree (string); /* AJK */ } else sprintf(command, "undisplay\n"); send_command(command); AppendDialogText(command); } #else /* >>>>>>>>>> NOT USED FOR GDB <<<<<<<<<<<<<<< */ /* ARGSUSED */ static void Undisplay(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { char *string; int stop_no, nbytes; string = XFetchBytes(display, &nbytes); if (nbytes == 0) { UpdateMessageWindow(UNDISPLAY_HELP, NULL); bell(0); return; } if ((stop_no = atoi(string)) > 0) sprintf(command, "undisplay %d\n", stop_no); else sprintf(command, "undisplay %s\n", string); send_command(command); AppendDialogText(command); XFree (string); /* AJK */ } #endif /* NOT GDB */ #ifndef GDB /* >>>>>>>>>> NOT USED FOR GDB <<<<<<<<<<<<<<< */ /* ARGSUSED */ static void Dump(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { char *funcname; int nbytes; funcname = XFetchBytes(display, &nbytes); if (nbytes == 0) strcpy(command, "dump\n"); else { sprintf(command, "dump %s\n", funcname); XFree (funcname); /* AJK */ } send_command(command); AppendDialogText(command); } #endif /* NOT GDB */ /* Beginning from startpos, this routine searches text forward for * searchstring, and returns 1 if searchstring is found, also returning * the left and right positions of the matched string in left and right; * else 0 is returned. * It also does wrap-around search. */ static int forwardSearch(text, startpos, searchstring, left, right) char *text; int startpos; char *searchstring; XawTextPosition *left, *right; { int searchlength, searchsize, i, n=0; char *s1, *s2; 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; } return 0; } } /* Similar to forwardSearch(), except that it does a reverse search */ static int reverseSearch(text, startpos, searchstring, left, right) char *text; XawTextPosition startpos; char *searchstring; XawTextPosition *left, *right; { int searchlength, i, n=0; char *s1, *s2; searchlength = strlen(searchstring); for (i=startpos; i >= searchlength; i--) { n = searchlength; s1 = &text[i]; s2 = &searchstring[searchlength-1]; while (--n >= 0 && *--s1 == *s2--); if (n < 0) break; } if (n < 0) { *right = i; *left = *right-searchlength; return 1; } else { for (i=strlen(text); i > startpos; i--) { n = searchlength; s1 = &text[i]; s2 = &searchstring[searchlength-1]; while (--n >= 0 && *--s1 == *s2--); if (n < 0) break; } if (n < 0) { *right = i; *left = *right-searchlength; return 1; } return 0; } } /* ARGSUSED */ void PopupSearch(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { Arg args[MAXARGS]; Cardinal n; Dimension popup_width, dialog_width; Position x, y; if (!displayedFile) { UpdateMessageWindow(SEARCH_HELP, NULL); bell(0); } else { XtRealizeWidget(searchPopupShell); n = 0; XtSetArg(args[n], XtNwidth, &popup_width); n++; XtGetValues(searchPopupShell, args, n); n = 0; XtSetArg(args[n], XtNwidth, &dialog_width); n++; XtGetValues(dialogWindow, args, n); XtTranslateCoords(dialogWindow, (Position)(dialog_width - popup_width)/2, 10, &x, &y); n = 0; XtSetArg(args[n], XtNx, x); n++; XtSetArg(args[n], XtNy, y); n++; XtSetValues(searchPopupShell, args, n); XtPopup(searchPopupShell, XtGrabNone); } } /* ARGSUSED */ /* This routine handles both forward and reverse text search. * If no text has been entered, the contents of the cut buffer are used * for searching. */ static void Search(w, direction, call_data) Widget w; XtPointer direction; XtPointer call_data; { XawTextBlock textblock; XawTextPosition pos, left, right; char *searchString; searchString = XawDialogGetValueString(searchPopup); if (strlen(searchString) == 0) { textblock.ptr = XFetchBytes(display, &textblock.length); if (!textblock.ptr) { UpdateMessageWindow("No search string selected", NULL); bell(0); return; } searchString = textblock.ptr; } pos = XawTextGetInsertionPoint(sourceWindow); if ((direction == (XtPointer)FORWARD && forwardSearch(displayedFile->buf, pos, searchString, &left, &right)) || (direction == (XtPointer)REVERSE && reverseSearch(displayedFile->buf, pos, searchString, &left, &right))) { AdjustText(TextPositionToLine(left)); XawTextSetSelection(sourceWindow, left, right); XawTextSetInsertionPoint(sourceWindow, left); } else { if (direction == (XtPointer)FORWARD) UpdateMessageWindow("String not found", NULL); else if (direction == (XtPointer)REVERSE) UpdateMessageWindow("String not found", NULL); else #ifdef GDB UpdateMessageWindow("xxgdb error: illegal search direction", NULL); #else UpdateMessageWindow("xdbx error: illegal search direction", NULL); #endif bell(0); } } /* ARGSUSED */ static void DoneSearch(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { XtPopdown(client_data); } /* ARGSUSED */ static void Activate(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { Search(w, (XtPointer)FORWARD, NULL); DoneSearch(w, (XtPointer)searchPopupShell, NULL); } static void CreateSearchPopup() { Widget dialogValue; Arg args[MAXARGS]; Cardinal n; static XtActionsRec search_actions[] = { {"Activate", Activate}, {NULL, NULL} }; static String translations = "#override\n\ Return: Activate() \n\ "; n = 0; XtSetArg(args[n], XtNinput, True); n++; XtSetArg(args[n], XtNallowShellResize, True); n++; searchPopupShell = XtCreatePopupShell("Search", transientShellWidgetClass, toplevel, args, n); n = 0; XtSetArg(args[n], XtNlabel, "Enter search string :"); n++; XtSetArg(args[n], XtNvalue, SearchString); n++; searchPopup = XtCreateManagedWidget("searchPopup", dialogWidgetClass, searchPopupShell, args, n); AddButton(searchPopup, "<<", Search, (XtPointer) REVERSE); AddButton(searchPopup, ">>", Search, (XtPointer) FORWARD); AddButton(searchPopup, "DONE", DoneSearch, (XtPointer)searchPopupShell); dialogValue = XtNameToWidget(searchPopup, "value"); XtOverrideTranslations(dialogValue, XtParseTranslationTable(translations)); XtAppAddActions(app_context, search_actions, XtNumber(search_actions)); } static Widget AddButton(parent, name, function, client_data) Widget parent; char *name; void (*function) (); XtPointer client_data; /* callback registered data */ { Widget button; Arg args[MAXARGS]; Cardinal n; static XtActionsRec command_actions[] = { {"ButtonSet", (XtActionProc) ButtonSet}, {NULL, NULL} }; static String translations = "\ : highlight() \n\ : reset() \n\ : set()\n\ : ButtonSet(1) notify() unset() \n\ : set()\n\ : ButtonSet(3) notify() unset()\n\ "; n = 0; XtSetArg(args[n], XtNresize, (XtArgVal) False); n++; if (strcmp(name, "print") == 0 || strcmp(name, "print *") == 0) { XtSetArg(args[n], XtNtranslations, XtParseTranslationTable(translations)); n++; } button = XtCreateManagedWidget(name, commandWidgetClass, parent, args, n); XtAddCallback(button, XtNcallback, function, client_data); XtAppAddActions(app_context, command_actions, XtNumber(command_actions)); return (button); } static void CreateButtons (parent) Widget parent; { int i=0; #ifdef GDB /* >>>>>>>>>>>>>> GDB ONLY <<<<<<<<<<<<<<<< */ button[i++] = AddButton (parent, "run", DoIt, "run\n"); button[i++] = AddButton (parent, "cont", DoIt, "cont\n"); button[i++] = AddButton (parent, "next", DoIt, "next\n"); button[i++] = AddButton (parent, "step", DoIt, "step\n"); button[i++] = AddButton (parent, "finish", DoIt, "finish\n"); button[i++] = AddButton (parent, "break", Break, "break"); button[i++] = AddButton (parent, "tbreak", Break, "tbreak"); button[i++] = AddButton (parent, "delete", Delete, NULL); button[i++] = AddButton (parent, "up", DoIt, "up\n"); button[i++] = AddButton (parent, "down", DoIt, "down\n"); button[i++] = AddButton (parent, "print", Print, (XtPointer)0); button[i++] = AddButton (parent, "print *", Print, (XtPointer)1); button[i++] = AddButton (parent, "display", Display_, NULL); button[i++] = AddButton (parent, "undisplay", Undisplay, NULL); button[i++] = AddButton (parent, "show display", DoIt, "info display\n"); /* AJK */ button[i++] = AddButton (parent, "args", DoIt, "info args\n"); button[i++] = AddButton (parent, "locals", DoIt, "info locals\n"); button[i++] = AddButton (parent, "stack", DoIt, "info stack\n"); #ifdef EDIT_BUTTON button[i++] = AddButton (parent, "edit", EdCallback, NULL); #endif button[i++] = AddButton (parent, "search", PopupSearch, NULL); button[i++] = AddButton (parent, "interrupt", Interrupt, NULL); /* DH */ button[i++] = AddButton (parent, "file", File, NULL); button[i++] = AddButton (parent, "show brkpts", DoIt, "info breakpoints\n"); /* AJK */ button[i++] = AddButton (parent, "yes", DoIt, "y\n"); /* AJK */ button[i++] = AddButton (parent, "no", DoIt, "n\n"); /* AJK */ button[i++] = AddButton (parent, "quit", Quit, NULL); #else /* >>>>>>>>>> IF NOT GDB <<<<<<<<<<<<<<< */ button[i++] = AddButton (parent, "run", DoIt, "run\n"); button[i++] = AddButton (parent, "rerun", DoIt, "rerun\n"); /* AJK */ button[i++] = AddButton (parent, "cont", DoIt, "cont\n"); button[i++] = AddButton (parent, "next", DoIt, "next\n"); button[i++] = AddButton (parent, "step", DoIt, "step\n"); button[i++] = AddButton (parent, "nexti", DoIt, "nexti\n"); /* AJK */ button[i++] = AddButton (parent, "stepi", DoIt, "stepi\n"); /* AJK */ #ifdef BSD button[i++] = AddButton (parent, "return", Return, "return\n"); #endif button[i++] = AddButton (parent, "stop at", Stop_at, NULL); button[i++] = AddButton (parent, "stop in", Stop_in, NULL); button[i++] = AddButton (parent, "delete", Delete, NULL); button[i++] = AddButton (parent, "where", DoIt, "where\n"); button[i++] = AddButton (parent, "up", DoIt, "up\n"); button[i++] = AddButton (parent, "down", DoIt, "down\n"); button[i++] = AddButton (parent, "print", Print, (XtPointer)0); button[i++] = AddButton (parent, "print *", Print, (XtPointer)1); button[i++] = AddButton (parent, "func", Func, NULL); button[i++] = AddButton (parent, "file", File, NULL); button[i++] = AddButton (parent, "status", DoIt, "status\n"); #ifndef BSD button[i++] = AddButton (parent, "display", Display_, NULL); button[i++] = AddButton (parent, "undisplay", Undisplay, NULL); #endif button[i++] = AddButton (parent, "dump", Dump, NULL); button[i++] = AddButton (parent, "search", PopupSearch, NULL); button[i++] = AddButton (parent, "trace", WhCmds, "trace"); /* AJK */ button[i++] = AddButton (parent, "whereis", WhCmds, "whereis"); /* AJK */ button[i++] = AddButton (parent, "whatis", WhCmds, "whatis"); /* AJK */ button[i++] = AddButton (parent, "which", WhCmds, "which"); /* AJK */ button[i++] = AddButton (parent, "dbxenv", DoIt, "dbxenv\n"); /* AJK */ button[i++] = AddButton (parent, "make", DoIt, "make\n"); /* AJK */ button[i++] = AddButton (parent, "modules", DoIt, "modules\n"); /* AJK */ button[i++] = AddButton (parent, "pwd", DoIt, "pwd\n"); /* AJK */ button[i++] = AddButton (parent, "quit", Quit, NULL); #endif /* NOT GDB */ button[i++] = NULL; CreateSearchPopup(); } /* Create a command widget, and the buttons. */ void CreateCommandPanel(parent) Widget parent; { Arg args[10]; Cardinal n; n = 0; commandWindow = XtCreateManagedWidget("commandWindow", boxWidgetClass, parent, args, n); CreateButtons(commandWindow); #ifndef GDB /* (PW)12MAR93 : for gdb, use pwd command of gdb */ #ifndef SYSV getwd(cwd); #endif #endif /* not GDB */ } /************************************************************************** * * Command queue functions * **************************************************************************/ /* Append command to end of the command queue and send the command to dbx */ void send_command(command) char *command; { CommandRec *p, *q, *r; #ifndef GDB #ifdef BSD /* Save the command if it is not a blank command; else use the last saved command instead */ if (strcspn(command, " \n")) strcpy(savedCommand, command); else strcpy(command, savedCommand); #endif #endif /* not GDB */ p = (CommandRec *)XtNew(CommandRec); p->command = XtNewString(command); p->next = NULL; if (!commandQueue) commandQueue = p; else { q = commandQueue; while ((r = q->next)) q = r; q->next = p; } #ifdef GDB write_dbx_available(); #else write_dbx(command); #endif /* GDB */ } /* Read command at the head of the command queue */ char *get_command() { if (commandQueue) { return (commandQueue->command); } else return NULL; } /* Delete command from the head of the command queue */ void delete_command() { CommandRec *p; if ((p = commandQueue)) { commandQueue = p->next; XtFree(p->command); XtFree((void*)p); } } /* Insert command into head of queue */ void insert_command(command) char *command; { CommandRec *p; p = (CommandRec *)XtNew(CommandRec); p->command = XtNewString(command); p->next = NULL; if (!commandQueue) commandQueue = p; else { p->next = commandQueue; commandQueue = p; } } xxgdb-1.12.orig/datadpy.c100644 1012 1010 72405 5560233767 14276 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* dataDpy.c: * * Provide graphical display of C pointers and structures. * * BuildLinePos(): Construct an array indexing the character position of * each line. * PositionToLine(): Return the character position of a given line. * SelectPointer(): Action proc for double click on a pointer value, * CreateDataPopup(): Create a popup to display the object pointed to by a * pointer. * UpdateDataPopup(): Update an unused popupshell to display data. * AppendList(): Append a popup to the list. * DeleteList(): Delete a popup from the list. * pop_down(): pop down the popup and free storage. * DestroyDataPopup():event handler for destroying a popup, call DeleteList() * and pop_down() (CRL mod 25) * MovePopup(): Position the popup. * print_handler(): Action handler for displaying pointers and structures. */ /* * 01FEB94: bugs fixed (klamer) * xxgdb does not allow the graphically displaying of members of parents * from a class. * xxgdb does not allow the graphically displaying of data through a * reference. */ #include #include "global.h" #include "regex.h" #include "datadpy.h" #define MAXLEVELS 20 /* max level of indentation */ #ifdef GDB #define INDENT 2 /* # of spaces for each indentation */ #else #define INDENT 8 /* # of spaces for each indentation */ #endif /* GDB */ #define EMPTY 0 #define UNUSED 1 #define USED 2 #define LEFT_MARGIN 10 #define SCROLLBAR_WIDTH 15 static DataDpyRec **dataDpyTable; static int dataDpyTableSize = 0; static DataDpyRec *Parent = NULL; static DataDpyList *TopParentList = NULL; static int font_height, font_width; #ifdef OBSOLETE static void DestroyDataPopup(); #else /* CRL mod 25 4/12/91 GWC - changed label widget to command widget in popups */ static void DestroyDataCallback(); #endif /* * Build an array which gives the starting text position of each line. * Very similar to the routine in source.c. */ static void BuildLinePos(dataDpy) DataDpyRec *dataDpy; { char *p; int line, nlines; int max=0; nlines = MAX(1, dataDpy->buflen/CHARS_PER_LINE); dataDpy->linepos = (XawTextPosition *) XtMalloc ((nlines+2) * sizeof(XawTextPosition)); p = dataDpy->buf; line = 0; dataDpy->linepos[line++] = 0; dataDpy->linepos[line++] = 0; while (*p) { if (*p++ == '\n') { if (line == nlines) { /* buffer full, need more memory */ dataDpy->linepos = (XawTextPosition *)XtRealloc( (void*)dataDpy->linepos, (nlines + ADD_LINES) * sizeof(XawTextPosition)); nlines += ADD_LINES; } dataDpy->linepos[line] = p - dataDpy->buf; AssignMax(max, dataDpy->linepos[line] - dataDpy->linepos[line-1]); line++; } } dataDpy->numlines = line - 2; dataDpy->maxLineLength = max; /* shrink to min size */ dataDpy->linepos = (XawTextPosition *) XtRealloc ((void*)dataDpy->linepos, line * sizeof(XawTextPosition)); } /* * Return the line number for the specified text position. */ static int PositionToLine(dataDpy, pos) DataDpyRec *dataDpy; XawTextPosition pos; { int line; if (dataDpy && pos >= 0) { for (line = 1; pos >= dataDpy->linepos[line]; line++); return (line-1); } else return (0); } /* ARGSUSED */ /* * Called by double click of pointer button. * If the selected text is a valid pointer, this routine parses the data * output to obtain the full qualified name of the pointer, and asks * dbx to print the value of the object the pointer is pointing to. */ static void SelectPointer(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { #ifndef GDB struct re_registers regs; char *field[MAXLEVELS]; int line, n, r, level, newlevel; char name[LINESIZ]; #endif XawTextPosition left, right; char *selection, *p; DataDpyRec *dataDpy; int fromLine; int i, nbytes; char command[LINESIZ]; /* Find out which data display output does the selection belong to */ dataDpy = NULL; for (i=0; dataDpyTable[i]; i++) if ((Widget) w == (Widget) dataDpyTable[i]->dataDpyWindow) { dataDpy = dataDpyTable[i]; Parent = dataDpy; break; } if (!dataDpy) return; /* Get the selection and check if it's a pointer value, 0x???? */ selection = XFetchBytes(display, &nbytes); if (re_match(dataPattern[D_POINTER].buf, selection, strlen(selection), 0, 0) < 0) { Parent = NULL; return; } /* Parse the output to get the fully qualified name of the pointer */ XawTextGetSelectionPos(w, &left, &right); fromLine = PositionToLine(dataDpy, left); 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) { if (strchr(selection, '@')) { char *p = strchr(newcommand, '*'); if (p != 0) *p = ' '; } 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, ®s) >= 0) { r = dataPattern[D_FIELD].reg_token[TK_POINTER]; if (strncmp(selection, p+regs.start[r], regs.end[r]-regs.start[r])) return; r = dataPattern[D_FIELD].reg_token[TK_INDENT]; level = regs.end[r]/INDENT; field[level+1] = NULL; r = dataPattern[D_FIELD].reg_token[TK_FIELD]; n = regs.end[r] - regs.start[r]; field[level] = (char *) XtMalloc ((n+1) * sizeof(char)); strncpy(field[level], p+regs.start[r], n); field[level][n] = '\0'; for (line = fromLine-1; line > 0; line--) { p = dataDpy->buf + dataDpy->linepos[line]; if (re_match(dataPattern[D_STRUCT].buf, p, strlen(p), 0, ®s)>=0){ r = dataPattern[D_STRUCT].reg_token[TK_INDENT]; newlevel = regs.end[r]/INDENT; if (newlevel == level-1) { level--; r = dataPattern[D_STRUCT].reg_token[TK_FIELD]; n = regs.end[r] - regs.start[r]; field[level] = (char *) XtMalloc ((n+1) * sizeof(char)); strncpy(field[level], p+regs.start[r], n); field[level][n] = '\0'; } } } if (*field[0] == '*' && field[1]) sprintf(name, "(%s)", field[0]+1); else strcpy(name, field[0]); for (i=1; field[i]; i++) { strcat(name, "."); strcat(name, field[i]); } sprintf(command, "print *(%s)\n", name); PopupMode = True; #ifdef GDB query_gdb(command, PARSE_ON | ECHO_OFF | FILTER_OFF); #else query_dbx(command); #endif /* GDB */ } #endif /* GDB */ } /* * Create a data display with a label. * The popupshell has a form widget which consists of a label and a text * widget. */ static void CreateDataPopup(dataDpy, label) DataDpyRec *dataDpy; char *label; { Arg args[MAXARGS]; Cardinal n; Dimension dataDpyHeight, dataDpyWidth; XFontStruct *text_font; static XtActionsRec datadpy_actions[] = { {"SelectPointer", (XtActionProc) SelectPointer}, {NULL, NULL} }; static String translations = "#override \n\ : SelectStart() SelectWord() SelectPointer() \n\ : SelectEnd() \n\ "; n = 0; dataDpy->popupshell = XtCreatePopupShell("Data Popup", transientShellWidgetClass, toplevel, args, n); n = 0; XtSetArg(args[n], XtNdefaultDistance, 0); n++; dataDpy->popup = XtCreateManagedWidget("popup", formWidgetClass, dataDpy->popupshell, args, n); /* Create the label */ n = 0; XtSetArg(args[n], XtNtop, (XtArgVal) XawChainTop); n++; XtSetArg(args[n], XtNbottom, (XtArgVal) XawChainTop); n++; XtSetArg(args[n], XtNright, (XtArgVal) XawChainRight); n++; XtSetArg(args[n], XtNleft, (XtArgVal) XawChainLeft); n++; XtSetArg(args[n], XtNlabel, (XtArgVal) label); n++; XtSetArg(args[n], XtNresize, (XtArgVal) False); n++; XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyCenter); n++; #ifdef OBSOLETE dataDpy->label = XtCreateManagedWidget("label", labelWidgetClass, dataDpy->popup, args, n); /* GWC says it is better to use ButtonReleaseMask instead of ButtonPressMask.*/ XtAddEventHandler(dataDpy->label, (EventMask) ButtonPressMask, False, DestroyDataPopup, dataDpy); #else /* CRL mod 25 4/12/91 GWC - changed label widget to command widget in popups */ dataDpy->label = XtCreateManagedWidget("command", commandWidgetClass, dataDpy->popup, args, n); XtAddCallback(dataDpy->label, XtNcallback, DestroyDataCallback, dataDpy); #endif /* Create the text window */ n = 0; XtSetArg(args[n], XtNfromVert, (XtArgVal) dataDpy->label); n++; XtSetArg(args[n], XtNtop, (XtArgVal) XawChainTop); n++; XtSetArg(args[n], XtNbottom, (XtArgVal) XawChainBottom); n++; XtSetArg(args[n], XtNright, (XtArgVal) XawChainRight); n++; XtSetArg(args[n], XtNleft, (XtArgVal) XawChainLeft); n++; XtSetArg(args[n], XtNleftMargin, (XtArgVal) LEFT_MARGIN); n++; XtSetArg(args[n], XtNuseStringInPlace, (XtArgVal) True); n++; XtSetArg(args[n], XtNstring, (XtArgVal) dataDpy->buf); n++; XtSetArg(args[n], XtNlength, (XtArgVal) dataDpy->buflen); n++; XtSetArg(args[n], XtNeditType, (XtArgVal) XawtextRead); n++; XtSetArg(args[n], XtNscrollHorizontal, XawtextScrollWhenNeeded); n++; XtSetArg(args[n], XtNscrollVertical, XawtextScrollWhenNeeded); n++; XtSetArg(args[n], XtNtranslations, XtParseTranslationTable(translations)); n++; dataDpy->dataDpyWindow = XtCreateManagedWidget("dataDpyWindow", asciiTextWidgetClass, dataDpy->popup, args, n); XtAppAddActions(app_context, datadpy_actions, XtNumber(datadpy_actions)); /* Get the text font */ n = 0; XtSetArg(args[n], XtNfont, &text_font); n++; XtGetValues(dataDpy->dataDpyWindow, args, n); /* Estimate the size of the text widget, dataDpyWindow, with the number of lines and the maximum length of a line. Assume fixed font width. */ font_height = text_font->ascent + text_font->descent; font_width = text_font->max_bounds.width; dataDpyHeight = dataDpy->numlines * font_height + 5; dataDpyWidth = dataDpy->maxLineLength * font_width + LEFT_MARGIN; if (dataDpyHeight > app_resources.dataDpyMaxHeight) dataDpyWidth += SCROLLBAR_WIDTH; #if 1 /*(PW)17DEC90 : bug ! */ #define SCROLLBAR_HEIGHT 15 if (dataDpyWidth > app_resources.dataDpyMaxWidth) dataDpyHeight += SCROLLBAR_HEIGHT; #endif AssignMin(dataDpyHeight, app_resources.dataDpyMaxHeight); AssignMin(dataDpyWidth, app_resources.dataDpyMaxWidth); n = 0; XtSetArg(args[n], XtNheight, (XtArgVal) dataDpyHeight); n++; XtSetArg(args[n], XtNwidth, (XtArgVal) dataDpyWidth); n++; XtSetValues(dataDpy->dataDpyWindow, args, n); n = 0; XtSetArg(args[n], XtNwidth, (XtArgVal) dataDpyWidth); n++; XtSetValues(dataDpy->label, args, n); } /* * Instead of creating a new popupshell, this routine uses an already * existing popupshell for data display. * It changes the label, calculates the size of the popupshell, * and sets the source of the text window to that of the new data. */ static void UpdateDataPopup(dataDpy, label) DataDpyRec *dataDpy; char *label; { Arg args[MAXARGS]; Cardinal n; Dimension popupHeight, popupWidth, dataDpyHeight, dataDpyWidth, labelHeight, labelBorderWidth, dataDpyBorderWidth; /* Update the label */ n = 0; XtSetArg(args[n], XtNlabel, (XtArgVal) label); n++; XtSetValues(dataDpy->label, args, n); /* Calculate the size of popupshell */ dataDpyHeight = dataDpy->numlines * font_height + 5; dataDpyWidth = dataDpy->maxLineLength * font_width + 2*10; #if 1 /*(PW)18DEC90 : bug ! */ if (dataDpyHeight > app_resources.dataDpyMaxHeight) dataDpyWidth += SCROLLBAR_WIDTH; if (dataDpyWidth > app_resources.dataDpyMaxWidth) dataDpyHeight += SCROLLBAR_HEIGHT; #endif AssignMin(dataDpyHeight, app_resources.dataDpyMaxHeight); AssignMin(dataDpyWidth, app_resources.dataDpyMaxWidth); n = 0; XtSetArg(args[n], XtNheight, (XtArgVal) &labelHeight); n++; XtSetArg(args[n], XtNborderWidth, (XtArgVal) &labelBorderWidth); n++; XtGetValues(dataDpy->label, args, n); n = 0; XtSetArg(args[n], XtNborderWidth, (XtArgVal) &dataDpyBorderWidth); n++; XtGetValues(dataDpy->dataDpyWindow, args, n); popupHeight = dataDpyHeight + labelHeight + 2*labelBorderWidth + 2*dataDpyBorderWidth; popupWidth = dataDpyWidth; n = 0; XtSetArg(args[n], XtNheight, (XtArgVal) popupHeight); n++; XtSetArg(args[n], XtNwidth, (XtArgVal) popupWidth); n++; XtSetValues(dataDpy->popupshell, args, n); /* Set the text source */ n = 0; XtSetArg(args[n], XtNstring, (XtArgVal) dataDpy->buf); n++; XtSetArg(args[n], XtNlength, (XtArgVal) dataDpy->buflen); n++; XawTextSetSource(dataDpy->dataDpyWindow, XtCreateWidget("textsrc", asciiSrcObjectClass, dataDpy->dataDpyWindow, args, n), 0); } /* * Append dataDpy to a DataDpyList pointed to by head. */ static void AppendList(head, dataDpy) DataDpyList **head; DataDpyRec *dataDpy; { DataDpyList *p, *q, *r; p = (DataDpyList *) XtNew (DataDpyList); p->dataDpy = dataDpy; p->next = NULL; q = *head; if (!q) *head = p; else { while ((r = q->next)) q = r; q->next = p; } } /* * Removes a dataDpy from its parent's list of children. */ static void DeleteList(head, dataDpy) DataDpyList **head; DataDpyRec *dataDpy; { DataDpyList *p, *q; if ((p = *head)) { if (p->dataDpy == dataDpy) *head = p->next; else { for (q = p->next; q && q->dataDpy != dataDpy;) { p = q; q = p->next; } if (q) p->next = q->next; } } } /* * Pop down a dataDpy and all its descendants, freeing storage and * reinitializing fields. */ static void pop_down(dataDpy) DataDpyRec *dataDpy; { DataDpyList *p, *q; XtPopdown(dataDpy->popupshell); XtFree((void*)dataDpy->linepos); XtFree(dataDpy->buf); dataDpy->buf = NULL; dataDpy->buflen = 0; dataDpy->linepos = NULL; dataDpy->state = UNUSED; dataDpy->parent = NULL; for (p = dataDpy->childlist; p;) { pop_down(p->dataDpy); q = p; p = p->next; XtFree((void*)q); } dataDpy->childlist = NULL; } /* * Invoked by a ButtonPress event on the label of a data display to * pop down itself and its descendants. */ /* ARGSUSED */ #ifdef OBSOLETE static void DestroyDataPopup(w, dataDpy, event) Widget w; DataDpyRec *dataDpy; XEvent *event; #else /* CRL mod 25 4/12/91 GWC - changed label widget to command widget */ static void DestroyDataCallback(w, dataDpy, call_data) Widget w; DataDpyRec *dataDpy; caddr_t call_data; #endif { if (!dataDpy->parent) DeleteList(&TopParentList, dataDpy); else DeleteList(&dataDpy->parent->childlist, dataDpy); pop_down(dataDpy); } /* * Position the data display on the screen to reflect the parent-child * relationship. */ static void MovePopup(dataDpy) DataDpyRec *dataDpy; { Arg args[MAXARGS]; Cardinal n; Screen *screen; int popupHeight, popupWidth, screenHeight, screenWidth; Position x, y; Dimension dataDpyWidth, dataDpyHeight, dataDpyBorderWidth, labelHeight, labelBorderWidth, width, height, borderWidth; DataDpyList *p, *q; Parent = NULL; if (!dataDpy->parent) p = TopParentList; else p = dataDpy->parent->childlist; /* Look for its previous sibling */ for (q = p->next; q && q->dataDpy != dataDpy;) { p = q; q = q->next; } /* If a sibling exists, place the new popup right next to it */ if (q) { n = 0; XtSetArg(args[n], XtNwidth, (XtArgVal) &width); n++; XtSetArg(args[n], XtNborderWidth, (XtArgVal) &borderWidth); n++; XtGetValues(p->dataDpy->popupshell, args, n); XtTranslateCoords(p->dataDpy->popupshell, 0, 0, &x, &y); x += width; y -= borderWidth; } else { /* no siblings */ /* this is the very first popup */ if (!dataDpy->parent) { x = 0; y = 0; } /* place it under its parent */ else { n = 0; XtSetArg(args[n], XtNheight, (XtArgVal) &height); n++; XtGetValues(dataDpy->parent->popupshell, args, n); XtTranslateCoords(dataDpy->parent->popupshell, 30, (Position)height, &x, &y); } } /* Make sure the popup does not go outside of the screen */ n = 0; XtSetArg(args[n], XtNwidth, (XtArgVal) &dataDpyWidth); n++; XtSetArg(args[n], XtNheight, (XtArgVal) &dataDpyHeight); n++; XtSetArg(args[n], XtNborderWidth, (XtArgVal) &dataDpyBorderWidth); n++; XtGetValues(dataDpy->dataDpyWindow, args, n); n = 0; XtSetArg(args[n], XtNheight, (XtArgVal) &labelHeight); n++; XtSetArg(args[n], XtNborderWidth, (XtArgVal) &labelBorderWidth); n++; XtGetValues(dataDpy->label, args, n); popupHeight = dataDpyHeight + labelHeight + 2*labelBorderWidth + 2*dataDpyBorderWidth; popupWidth = dataDpyWidth; screen = XtScreen(toplevel); screenHeight = XHeightOfScreen(screen); screenWidth = XWidthOfScreen(screen); if (x + popupWidth > screenWidth && y + popupHeight > screenHeight) { x = screenWidth - popupWidth; y = screenHeight - popupHeight; } else if (x + popupWidth > screenWidth) x = screenWidth - popupWidth; else if (y + popupHeight > screenHeight) y = screenHeight - popupHeight; n = 0; XtSetArg(args[n], XtNx, x); n++; XtSetArg(args[n], XtNy, y); n++; XtSetValues(dataDpy->popupshell, args, n); } /* * Handler procedure called by parse(). * The main function to popup a data display. */ void print_handler(output) char *output; { DataDpyRec *dataDpy; int i, j; if (!output) return; if (!PopupMode) return; PopupMode = False; XDefineCursor(display, XtWindow(toplevel), watch); if (Parent) XDefineCursor(display, XtWindow(Parent->dataDpyWindow), watch); UpdateMessageWindow("Click the label to pop down the data popup",NULL); /* 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; dataDpyTable = (DataDpyRec **) XtRealloc ((void*)dataDpyTable, dataDpyTableSize * sizeof(DataDpyRec *)); for (j=i; jstate = EMPTY; dataDpyTable[i]->parent = NULL; dataDpyTable[i]->childlist = NULL; } dataDpy = dataDpyTable[i]; dataDpy->id = i; /* not needed */ dataDpy->buf = XtNewString(output); dataDpy->buflen = strlen(output); BuildLinePos(dataDpy); if (dataDpy->state == EMPTY) CreateDataPopup(dataDpy, Token.mesg); else if (dataDpy->state == UNUSED) UpdateDataPopup(dataDpy, Token.mesg); dataDpy->state = USED; /* mark it used */ if ((dataDpy->parent = Parent)) AppendList(&Parent->childlist, dataDpy); else AppendList(&TopParentList, dataDpy); MovePopup(dataDpy); XtPopup(dataDpy->popupshell, XtGrabNone); if (dataDpy->parent) XUndefineCursor(display, XtWindow(dataDpy->parent->dataDpyWindow)); XUndefineCursor(display, XtWindow(toplevel)); } #ifdef GDB #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; { if (result_index == 0) /* buffer full */ { *result = 0; return; } if ((c == '.') && (result[result_index] == '.')) return; /* To prevent $1..name for pointers in g++ parents */ 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 NULL; 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 */ xxgdb-1.12.orig/datadpy.h100644 1012 1010 10677 5526766760 14314 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* datadpy.h: * * Regular expression pattern matching for C structures * * The reg_token array indicates the register no. for each token type. * reg_token[0] : level of indentation * reg_token[2] : field name * reg_token[4] : pointer string */ #define TK_INDENT 0 #define TK_FIELD 2 #define TK_POINTER 4 #define D_POINTER 0 #define D_FIELD 1 #define D_STRUCT 2 #ifdef GDB /* >>>>>>>>>>>> GDB ONLY <<<<<<<<<<<<<<<<<< */ /* Note : for GDB the 'set prettyprint on' must be ON. Examples : $3 = (struct toto *) 0x40c0 $2 = { pt = 0x40b4, u = 5, v = 6 } */ PatternRec dataPattern[] = { {"@*0x[0-9a-f]+", NULL, {-1, -1, -1, -1, -1, -1} }, {"\\([ ]*\\)\\(.*[^ ]+\\)[ ]* = \\((.*) \\)?\\(0x[0-9a-f]+\\)[,]?[ ]*\n", NULL, { 1, -1, 2, -1, 4, -1} }, {"\\([ ]*\\)\\(.*[^ ]*\\)[ ]* = {\n", NULL, { 1, -1, 2, -1, -1, -1} }, { NULL, /* last one */ NULL, { -1, -1, -1, -1, -1, -1} } }; #else /* >>>>>>>>>>>> IF NOT GDB <<<<<<<<<<<<<<<<<< */ PatternRec dataPattern[] = { {"0x[0-9a-f]+", NULL, {-1, -1, -1, -1, -1, -1} }, {"\\([ ]*\\)\\(.*[^ ]+\\)[ ]* = \\(0x[0-9a-f]+\\)\n", NULL, { 1, -1, 2, -1, 3, -1} }, {"\\([ ]*\\)\\(.*[^ ]*\\)[ ]* = {\n", NULL, { 1, -1, 2, -1, -1, -1} }, { NULL, /* last one */ NULL, { -1, -1, -1, -1, -1, -1} } }; #endif /* NOT GDB */ xxgdb-1.12.orig/dbx.c100644 1012 1010 17366 5663232301 13415 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* * dbx.c * * Handle dbx command initialization file (.dbxinit) and communication * between dbx and xdbx. * * dbx_init(): Handle .dbxinit * debug_init(): * read_dbx(): Read dbx output, parse and filter it before displaying * onto the dialog window. * write_dbx(): Send a command to dbx. * query_dbx(): Send a command to dbx and process it. */ #include #include #include "global.h" Boolean Prompt; /* True when dbx prompt arrives */ char *concat(); char *dbxprompt; char *xdbxprompt; /* Given a dbx command initialization file, this routine executes each dbx * command in the file. It sends the command to dbx, and calls read_dbx() * directly to process output returned from dbx. */ static void dbx_init(xdbxinit) char *xdbxinit; { #ifndef GDB FILE *fp; char s[LINESIZ]; #endif /* not GDB */ if (strcmp(xdbxinit, "") == 0) return; #ifdef GDB read_source_file(xdbxinit); #else /* not GDB */ if (fp = fopen(xdbxinit, "r")) { while (fgets(s, LINESIZ, fp)) { send_command(s); AppendDialogText(s); Prompt = False; while (!Prompt) read_dbx(); } fclose(fp); } #endif /* not GDB */ } /* * This routine is called after getting the first dbx prompt. * > check the use list to create a list of directories for searching * source files. * > ask dbx for the source file and display it if it exists. * > open the command initialization file and executed the commands; * if Tstartup is true, remove the initialization file. */ void debug_init() { static visited = False; if (!visited) { visited = True; dbx_init(xdbxinit); if (Tstartup) unlink(xdbxinit); strcpy(xdbxinit, ""); } } #ifndef GDB /* * 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; { static char *output = NULL; /* buffer for dbx output */ static char *next_string = NULL; static char *command; char *string = NULL; char s[LINESIZ]; Boolean more; 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)) == 0) { 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(); if (Echo) { filter(string, output, command); if (Prompt) AppendDialogText(xdbxprompt); } if (string) { XtFree(string); string = NULL; } if (next_string) { string = concat(string, next_string); XtFree(next_string); next_string = NULL; } if (Prompt) { parse(output, command); delete_command(); XtFree(output); output = NULL; } } } #endif /* not GDB */ /* Write string s to dbx, and flush the output. * * 18NOV94: it could happen that the string is too big for * the IO system to handle at once. Just wait on try again. * Do not try too soon else an error will be returned by * write(). * */ void write_dbx(s) char *s; { int nbwritten; int strl = strlen(s); if (debug) { fprintf(stderr, ">>%s", s); /* (PW) see what is sent to GDB */ } while (strl) { nbwritten = write (fileno(dbxfp), s, strl); if (nbwritten == -1) { perror("write dbxfp"); exit(-1); } strl -= nbwritten; if (strl == 0) { break; /* nothing more */ } s += nbwritten; if (debug) { fprintf(stderr, ">> sleep in write_dbx()\n"); } sleep(1); /* give gdb time to read his buffer */ } } #ifndef 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; { write_dbx(command); insert_command(command); Echo = False; Prompt = False; while (!Prompt) read_dbx(); Parse = True; /* Always reset Parse and Echo to True */ Echo = True; } #endif xxgdb-1.12.orig/defs.h100644 1012 1010 24745 5667745355 13613 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * * AJK, May 91 * 1. Define help message for new dbx commands (whereis/whatis/which) *****************************************************************************/ /* defs.h * * Contain #includes, #defines and typedefs */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if XtVersion < 11005 /* incompatibility of header file with X11R4 documentation */ #define XawChainTop XtChainTop #define XawChainBottom XtChainBottom #define XawChainLeft XtChainLeft #define XawChainRight XtChainRight #endif #ifndef AssignMax #define AssignMax(x, y) if ((y) > (x)) x = (y) #endif #ifndef AssignMin #define AssignMin(x, y) if ((y) < (x)) x = (y) #endif /* increase input LINESIZ to 4k from .5k (could still be too small) */ #define LINESIZ 4096 /* input line length */ #define MAXNAME 256 /* max identifier length */ #define MAXARGS 20 /* max number of args */ #define ADD_SIZE 16 /* # of files added during Realloc */ #define CHARS_PER_LINE 20 /* estimated number of chars per line */ #define ADD_LINES 50 /* # of lines to be added in realloc */ #define NTOKENS 6 /* number of tokens */ #ifdef GDB #define DEBUGGER "gdb" /* name of executable */ #define XDBXPROMPT "(xxgdb) " /* xdbx prompt string */ #else #define DEBUGGER "dbx" /* name of executable */ #define XDBXPROMPT "(xdbx) " /* xdbx prompt string */ #endif /* GDB */ #define DELIMITERS " !%^&*()+=~|;:{},/# #include "global.h" #define DIALOGSIZE 100000 /* max size of dialogue window buffer */ Widget dialogWindow; /* text window as a dbx terminal */ Boolean FalseSignal = FALSE; /* set to TRUE before self-generated interrupt/quit signals */ static char DialogText[DIALOGSIZE]; /* text buffer for widget */ static XawTextPosition StartPos; /* starting position of input text */ /* This procedure prevents the user from deleting past the prompt, or * any text appended by AppendDialogText() to the dialog window. * It checks the last position of text, if it matches StartPos, set * by AppendDialogText(), it inserts a space so that delete-previous- * character() can only delete the space character. */ /* ARGSUSED */ static void InsertSpace(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { XawTextBlock textblock; XawTextPosition lastPos; if (XawTextGetInsertionPoint(w) <= StartPos) { lastPos = TextGetLastPos(w); if (lastPos == StartPos) { textblock.firstPos = 0; textblock.length = 1; textblock.ptr = " "; XawTextReplace(w, lastPos, lastPos, &textblock); XawTextSetInsertionPoint(w, lastPos+1); } } } /* Erases the preceding word. * Simulates the action of the WERASE character (ctrl-W). */ /* ARGSUSED */ void DeleteWord(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { XawTextBlock textblock; XawTextPosition pos; Cardinal i; textblock.firstPos = 0; textblock.length = 0; textblock.ptr = ""; pos = XawTextGetInsertionPoint(w); if (pos <= StartPos) pos = TextGetLastPos(w); for (i=pos; i > StartPos && DialogText[i-1] == ' '; i--); for (; i > StartPos && DialogText[i-1] != ' '; i--); XawTextReplace(w, i, pos, &textblock); XawTextSetInsertionPoint(w, i); } /* Deletes the entire current input line. * simulates the action of the KILL character (ctrl-U). */ /* ARGSUSED */ void DeleteLine(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { XawTextBlock textblock; XawTextPosition pos, beginPos; Cardinal i; char *s; textblock.firstPos = 0; textblock.length = 0; textblock.ptr = ""; pos = XawTextGetInsertionPoint(w); if (w == dialogWindow) { s = DialogText; beginPos = StartPos; if (pos <= beginPos) pos = TextGetLastPos(w); } else { return; } for (i=pos; i > beginPos && s[i-1] != '\n'; i--); XawTextReplace(w, i, pos, &textblock); XawTextSetInsertionPoint(w, i); } /* Dispatch() is invoked on every . * It collects text from the dialog window and sends it to dbx. * If the string is a command to dbx (Prompt would be TRUE), * it is stored in the global variable, Command. */ /* ARGSUSED */ static void Dispatch(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { #ifdef GDB /* For GDB, '\n' means exec previous command again. default command is space+CR, so that we never send CR to gdb (the repeat is managed here) */ static char gdb_command[LINESIZ] = " \n"; #endif char s[LINESIZ]; strcpy(s, DialogText + StartPos); #if 1 /* (PW)18DEC90 : bug xdbx : without the following line, xdbx sends several times the same lines when Prompt is false */ StartPos = TextGetLastPos(dialogWindow); #endif if (Prompt) { #ifdef GDB /* 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); } #endif /* GDB */ send_command (s); } else /* this string is for the application, not for gdb */ write_dbx(s); } /* Sends an interrupt signal, SIGINT, to dbx. * Simulates the action of the INTR character (ctrl-C). */ void signal_interrupt_dbx() { #ifndef GDB FalseSignal = TRUE; #ifdef SYSV /* (PW)13AUG92: change SVR4 into SYSV */ /* (MJH) */ kill(-(dbxpid), SIGINT); #else killpg(dbxpid, SIGINT); #endif /* SYSV */ #else write_dbx("\003"); /* (PW)18FEB91 : seems to work better */ #endif /* GDB */ } /* Sends an interrupt signal, SIGINT, to dbx. * Simulates the action of the INTR character (ctrl-C). */ /* ARGSUSED */ static void SigInt(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { signal_interrupt_dbx (); } /* Sends an EOF signal to dbx. (ctrl-D) */ /* ARGSUSED */ static void SigEof(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { write_dbx("\04"); } /* Sends a QUIT signal, SIGQUIT, to dbx. * Simulates the action of the QUIT character (ctrl-\) */ /* ARGSUSED */ static void SigQuit(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { FalseSignal = TRUE; #ifdef SYSV /* (PW)13AUG92: change SVR4 into SYSV */ /* (MJH) */ kill(-(dbxpid), SIGQUIT); #else killpg(dbxpid, SIGQUIT); #endif /* SYSV */ } /* * Dialog window has its own set of translations for editing. * Special action procedures for keys Delete/Backspace, Carriage Return, * Ctrl-U, Ctrl-C, Ctrl-D, Ctrl-\, and word selection. */ void CreateDialogWindow(parent) Widget parent; { Arg args[MAXARGS]; Cardinal n; static XtActionsRec dialog_actions[] = { {"SigInt", (XtActionProc) SigInt}, {"SigEof", (XtActionProc) SigEof}, {"SigQuit", (XtActionProc) SigQuit}, {"InsertSpace", (XtActionProc) InsertSpace}, {"Dispatch", (XtActionProc) Dispatch}, {NULL, NULL} }; static String translations = "#override\n\ CtrlC: SigInt()\n\ CtrlD: SigEof()\n\ Ctrl|: SigQuit()\n\ CtrlW: DeleteWord()\n\ CtrlU: DeleteLine()\n\ CtrlH: InsertSpace() delete-previous-character()\n\ Delete: InsertSpace() delete-previous-character()\n\ BackSpace: InsertSpace() delete-previous-character()\n\ Return: newline() Dispatch()\n\ "; n = 0; XtSetArg(args[n], XtNuseStringInPlace, True); n++; XtSetArg(args[n], XtNstring, (XtArgVal) DialogText); n++; XtSetArg(args[n], XtNlength, (XtArgVal) DIALOGSIZE); n++; XtSetArg(args[n], XtNeditType, (XtArgVal) XawtextAppend); n++; XtSetArg(args[n], XtNscrollVertical, XawtextScrollAlways); n++; XtSetArg(args[n], XtNwrap, XawtextWrapWord); n++; dialogWindow = XtCreateManagedWidget("dialogWindow", asciiTextWidgetClass, parent, args, n ); XtOverrideTranslations(dialogWindow, XtParseTranslationTable(translations)); XtAppAddActions(app_context, dialog_actions, XtNumber(dialog_actions)); } #if 0 /* never used */ static void TextSetLastPos(w, lastPos) Widget w; XawTextPosition lastPos; { TextWidget ctx = (TextWidget) w; ctx->text.lastPos = lastPos; } #endif void AppendDialogText(s) char *s; { XawTextPosition i, lastPos; XawTextBlock textblock, nullblock; if (!s || !strcmp(s, "")) return; if (debug) { fprintf(stderr, "AppendDialogText \"%s\"\n", s); } textblock.firstPos = 0; textblock.length = strlen(s); textblock.ptr = s; lastPos = TextGetLastPos(dialogWindow); if (textblock.length > DIALOGSIZE) { bell(0); #ifdef GDB fprintf(stderr, "xxgdb error: cannot display string in dialogue window\n\ string has %d bytes; dialogue window size limit is %d bytes\n", textblock.length, DIALOGSIZE); #else fprintf(stderr, "xdbx error: cannot display string in dialogue window\n\ string has %d bytes; dialogue window size limit is %d bytes\n", textblock.length, DIALOGSIZE); #endif return; } if (lastPos + textblock.length > DIALOGSIZE) { nullblock.firstPos = 0; nullblock.length = 0; nullblock.ptr = ""; i = textblock.length - (DIALOGSIZE - lastPos); if (i < 0.9*DIALOGSIZE) i += 0.1*DIALOGSIZE; while (DialogText[i] != '\n') i++; XawTextReplace(dialogWindow, 0, i+1, &nullblock); lastPos = TextGetLastPos(dialogWindow); } XawTextReplace(dialogWindow, lastPos, lastPos, &textblock); StartPos = TextGetLastPos(dialogWindow); XawTextSetInsertionPoint(dialogWindow, StartPos); #if 0 /* no longer necessary I think */ /* fix annoying bug that dialog mark is sometimes scrolled off bottom (widget bug?) */ XawTextDisplay(dialogWindow); #endif #if defined(OLDSUNOS)||defined(SUNOS4) /* Have experienced bug where dialog window actually writes off bottom (does not scroll to bottom). Seems more prevalent with Openwindows, but since it needs to debug certain programs to get this to show up. Couldn't find the problem, but this works around it: (really icky but only way I found to fix it) */ if (StartPos >= ((TextWidget)dialogWindow)->text.lt.info[((TextWidget)dialogWindow)->text.lt.lines].position) XtCallActionProc(dialogWindow, "redraw-display", 0, 0, 0); #endif /* SUNOS */ } xxgdb-1.12.orig/filemenu.c100644 1012 1010 37203 5630434464 14444 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* filemenu.c * * Construct a file menu (directory browser) which allows a user to go * up and down the directory tree, to select text files to display, and * to select executable files to debug. The file menu is popped up by * the 'file' command button. * Duane Voth (duanev@mcc.com) contributed to the layout of the file menu, * plus some code and ideas. * * changeDir(): Record the current working directory. * InList(): Select files to be displayed in the menu. * ScanDir(): Scan the directory and record selected filenames. * DisplayMenuFile(): Callback for the file menu. * CancelFileMenu(): Pop down the file menu. * SetUpFileMenu(): Create the file menu popupshell. * UpdateFileMenu(): Update entries in the file menu. * File(): Command callback for the 'file' command button. */ #include #include #include #ifdef SYSV #include #include #include #include #ifdef _POSIX_SOURCE #ifndef S_IFDIR #define S_IFDIR 0040000 /* directory */ #endif #ifndef S_IEXEC #define S_IEXEC 00100 /* execute/search permission, owner */ #endif #endif /* _POSIX_SOURCE */ #else /* SYSV */ #ifdef SUNOS4 #include #else #include #endif #endif /* SYSV */ #include "global.h" #define MAXCOLUMNS 8 /* max number of columns in file menu */ #define FILES_PER_COL 10 /* # of files per column in file menu */ static char fileMenuDir[MAXPATHLEN];/* current directory of file menu */ static char **filelist; /* list of file names in fileMenu */ static int nfiles = 0; /* number of files in filelist */ static Widget popupshell, /* parent of popup */ popup, /* vpane widget containing file menu */ fileMenu, /* list widget as file menu */ fileMenuLabel; /* label widget as file menu label */ void File(); static void UpdateFileMenu(); /* Change working directory to 'dir'. * For Berkeley dbx, modify static global variable, cwd, to keep track of * current working directory. * For Sun dbx, change working directory of dbx. */ static void changeDir(dir) char *dir; { char command[LINESIZ]; char store[LINESIZ]; int i,j; if(!strcmp(dir, "./")) return; #if defined(BSD) if (dir[0] == '/' || dir[0] == '~') strcpy(cwd, dir); if (strcmp(dir, "../") == 0) { for (i=strlen(cwd); cwd[i] != '/' && i > 0; i--); cwd[i] = '\0'; if (strcmp(cwd, "") == 0) strcpy(cwd, "/"); } else { sprintf(cwd, "%s/%s", cwd, dir); LASTCH(cwd) = '\0'; } #else /* not BSD */ if(!strcmp(dir,"../")) { for(i=0,j=0; cwd[i]; i++) if(cwd[i]=='/')j++; if( j == 1 ) strcpy(store,"/"); else strcpy(store,".."); } else { if(!strcmp(cwd, "/"))cwd[0]='\0'; sprintf(store,"%s/%s", cwd, dir); LASTCH(store)='\0'; } 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); #endif /* not GDB */ #endif /* BSD */ } /* Determines if a directory entry should appear in the file menu. * The files included in the menu are : * .. (parent directory) * directories * text files * executable files */ #ifndef SYSV static int InList(entry) Directory *entry; { char pathname[LINESIZ]; struct stat statbuf; if (strcmp(entry->d_name, ".") == 0 || /* ignore current directory */ LASTCH(entry->d_name) == '~' || /* ignore Emacs backup files */ (LASTCH(entry->d_name) == 'o' && SECLASTCH(entry->d_name) == '.')) /* ignore object files */ return False; if (entry->d_name[0] == '.' && entry->d_name[1] != '.') return False; /* ignore hidden files */ if (strcmp(cwd, "")) /* give full path name */ sprintf(pathname, "%s/%s", cwd, entry->d_name); else strcpy(pathname, entry->d_name); if (stat(pathname, &statbuf) == -1) return False; if (statbuf.st_mode & S_IFDIR) { /* is directory */ strcat(entry->d_name, "/"); ++(entry->d_namlen); return True; } if (statbuf.st_mode & S_IEXEC) { /* is executable */ strcat(entry->d_name, "*"); ++(entry->d_namlen); return True; } return True; } #endif /* not SYSV */ /* Scans the working directory for files selected by InList(), sorted * alphabetically, and stored in an array of pointers to directory * entries called namelist. * The names of the selected files are stored in filelist. */ static void ScanDir(dir) char *dir; { #ifndef SYSV extern alphasort(); Directory **namelist; #else struct dirent *WorkingDirEntry; DIR *WorkingDir; char store[LINESIZ]; #endif register int i,j; #ifdef SYSV if(!(WorkingDir = opendir(dir))) { UpdateMessageWindow("scandir: cannot open %s", dir); return; } nfiles=0; while(readdir(WorkingDir))nfiles++; rewinddir(WorkingDir); #else nfiles = scandir(dir, &namelist, InList, alphasort); if (nfiles == -1) { UpdateMessageWindow("scandir: cannot open %s", dir); return; } #endif if (filelist) { for (i=0; filelist[i]; i++) XtFree(filelist[i]); XtFree((void*)filelist); } filelist = (char **) XtMalloc((nfiles+1) * sizeof(char *)); i = 0; for (j=0; jd_name, ".")) strcpy(store, "./"); else { if(!strcmp(WorkingDirEntry->d_name, "..")) strcpy(store, "../"); else { struct stat statbuf; sprintf(store,"%s/%s",cwd,WorkingDirEntry->d_name); if(stat(store, &statbuf) == -1) store[0]='\0'; else { if (statbuf.st_mode & S_IFDIR) sprintf(store, "%s/", WorkingDirEntry->d_name); else if (statbuf.st_mode & S_IEXEC) sprintf(store, "%s*", WorkingDirEntry->d_name); else if(LASTCH(WorkingDirEntry->d_name) == '~' || LASTCH(WorkingDirEntry->d_name) == '#' || WorkingDirEntry->d_name[0] == '.' || (LASTCH(WorkingDirEntry->d_name) == 'o' && SECLASTCH(WorkingDirEntry->d_name) == '.')) store[0]='\0'; else strcpy(store, WorkingDirEntry->d_name); } } } if(store[0]) filelist[i++] = XtNewString(store); #else /* not SYSV */ filelist[i++] = XtNewString(namelist[j]->d_name); XtFree((XtPointer) namelist[j]); #endif } filelist[i++] = NULL; #ifdef SYSV closedir(WorkingDir); #else XtFree((XtPointer) namelist); #endif return; } /* Callback for the fileMenu list widget. * > if the selected item is a directory, display contents of that directory. * > (Sun dbx only) if the selected item is an executable file, issue the * debug command. * > if the selected item is a readable file, display the file. */ /* ARGSUSED */ static void DisplayMenuFile(w, popupshell, call_data) Widget w; Widget popupshell; XawListReturnStruct *call_data; { char string[LINESIZ], *filename, command[LINESIZ]; XtPopdown(popupshell); filename = call_data->string; if (filename == NULL) return; if (LASTCH(filename) == '/') { changeDir(filename); XtDestroyWidget(popupshell); UpdateFileMenu(); /* create new menu */ File(); /* pop it up */ } else if (LASTCH(filename) == '*') { 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 strcpy(string, filename); LASTCH(string) = '\0'; sprintf(command, "debug %s\n", string); send_command(command); AppendDialogText(command); #endif #endif /* GDB */ } else { UpdateMessageWindow("",NULL); #ifdef GDB if (strcmp(filename, "core") == 0) sprintf(command, "core-file %s\n", filename); else sprintf(command, "list %s:1\n", filename); send_command(command); AppendDialogText(command); #else /* not GDB */ sprintf(command, "file %s\n", filename); send_command(command); AppendDialogText(command); #endif /* GDB */ } } /* Callback to popdown the file menu */ /* ARGSUSED */ static void CancelFileMenu(w, popupshell, call_data) Widget w; Widget popupshell; caddr_t call_data; { XtPopdown(popupshell); UpdateMessageWindow("",NULL); } /* Creates a popup shell with its child being a vpane widget containing * a file menu label, a file menu containing file names returned from * ScanDir(), and a cancel command button. * When an item in the list is selected, DisplayMenuFile is called. */ static void SetUpFileMenu(dir) char *dir; { Widget cancelButton; Arg args[MAXARGS]; Cardinal n; char menulabel[LINESIZ]; int ncolumns; n = 0; popupshell = XtCreatePopupShell("File Directory", transientShellWidgetClass, toplevel, args, n); n = 0; popup = XtCreateManagedWidget("popup", panedWidgetClass, popupshell, args, n); ScanDir(dir); strcpy(fileMenuDir, dir); n = 0; sprintf(menulabel, " %s ", dir); XtSetArg(args[n], XtNlabel, (XtArgVal) menulabel); n++; XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyCenter); n++; fileMenuLabel = XtCreateManagedWidget("fileMenuLabel", labelWidgetClass, popup, args, n); n = 0; ncolumns = nfiles/FILES_PER_COL + 1; ncolumns = MIN(ncolumns, MAXCOLUMNS); XtSetArg(args[n], XtNlist, filelist); n++; XtSetArg(args[n], XtNverticalList, True); n++; XtSetArg(args[n], XtNdefaultColumns, (XtArgVal) ncolumns); n++; fileMenu = XtCreateManagedWidget("fileMenu", listWidgetClass, popup, args, n); XtAddCallback(fileMenu, XtNcallback, DisplayMenuFile, popupshell); n = 0; XtSetArg(args[n], XtNresize, False); n++; XtSetArg(args[n], XtNlabel, "CANCEL"); n++; cancelButton = XtCreateManagedWidget("cancelButton", commandWidgetClass, popup, args, n); XtAddCallback(cancelButton, XtNcallback, CancelFileMenu, popupshell); DisableWindowResize(fileMenuLabel); DisableWindowResize(cancelButton); } /* This routine is called when there is a a change in current directory. * It destroys the existing popup shell and creates a new file menu based * on the new current directory. A new directory list is created. */ static void UpdateFileMenu() { SetUpFileMenu(cwd); #ifdef GDB query_gdb_directories(); /* defined in gdb_handler.c */ #else query_dbx("use\n"); #endif /* GDB */ } /* File command button callback. */ /* ARGSUSED */ void File(w, client_data, call_data) Widget w; caddr_t client_data; caddr_t call_data; { Arg args[MAXARGS]; Cardinal n; Position x, y, x_offset; Dimension fileMenu_width, fileMenuLabel_width, border_width, width, dialog_width; XDefineCursor(display, XtWindow(toplevel), watch); XDefineCursor(display, XtWindow(sourceWindow), watch); XDefineCursor(display, XtWindow(dialogWindow), watch); XFlush(display); if (strcmp(fileMenuDir, cwd)) UpdateFileMenu(); n = 0; XtSetArg(args[n], XtNwidth, &fileMenu_width); n++; XtSetArg(args[n], XtNborderWidth, &border_width); n++; XtGetValues(fileMenu, args, n); n = 0; XtSetArg(args[n], XtNwidth, &fileMenuLabel_width); n++; XtGetValues(fileMenuLabel, args, n); n = 0; XtSetArg(args[n], XtNwidth, &dialog_width); n++; XtGetValues(dialogWindow, args, n); width = MAX(fileMenu_width, fileMenuLabel_width); x_offset = (Position) (dialog_width - width - border_width); XtTranslateCoords(dialogWindow, x_offset, 0, &x, &y); x = MAX(0, x); y = MAX(0, y); n = 0; XtSetArg(args[n], XtNx, x); n++; XtSetArg(args[n], XtNy, y); n++; XtSetValues(popupshell, args, n); XtPopup(popupshell, XtGrabNonexclusive); UpdateMessageWindow("Select a file or directory",NULL); XUndefineCursor(display, XtWindow(toplevel)); XUndefineCursor(display, XtWindow(sourceWindow)); XUndefineCursor(display, XtWindow(dialogWindow)); } xxgdb-1.12.orig/gdb_handler.c100644 1012 1010 57757 5745237136 15115 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* gdb_handler.c * * WARNING : gdb_handler.c is included by handler.c for GDB. * * Contain action handlers for the parser to invoke upon a dbx command. * * updown_handler(): Update file, line label, updown arrow position. * debug_handler(): Check directory use list, display main source file. * pwd_handler(): Update current working directory. * search_handler(): Adjust source file to display matched line. * display_info_handler(): Update display window. * break_handler(): Place stop sign on line or function or address specified. * info_dir_handler(): Update search directory list. * directory_handler(): Update search directory list. * list_handler(): Adjust source file to display result. * info_line_handler(): Update current file. * delete_handler(): Remove stop sign. * display_handler(): Update display window. * info_break_handler(): Update stop signs. * cd_handler(): Record current working directory. * frame_curr_handler(): Update current function name. * exec_handler(): Update file, line label, arrow position. * done_handler(): Progrm execution completed, clear breakpoints * source_handler(): Exec commands of source file specified. * query_gdb(): Send command to gdb. */ #ifdef SYSV # include #endif /* * Display an outlined arrow to locate the calling routine in a stack * frame. */ void updown_handler() { char *func, *file; int line; line = Token.line; func = XtNewString(Token.func); if (line <= 0) line = 1; LoadCurrentFile(); if (displayedFile) file = displayedFile->pathname; else file = NULL; /* AJK */ if (line <= 0 || func == NULL || file == NULL) { XtFree(func); return; } if (displayedFile && strcmp(file, displayedFile->pathname)) { LoadFile(file); } updown.line = line; strcpy(updown.func, func); if (displayedFile) strcpy(updown.file, displayedFile->pathname); AdjustText(line); XtFree(func); } /* ARGSUSED */ void debug_handler() { /* debug_handler is executed at start-up and with 'symbol-file' command and with 'file' command (gdb 4.0) */ /* say no current compilation directory, no current source */ info_source_handler(NULL,NULL,NULL); query_gdb_directories(); if (new_gdb4()) /* (PW)28AUG91: test for gdb 4.0 */ { /* (SH) for gdb 4.0 */ #ifndef NeXT query_gdb("set height 0\n", PARSE_OFF | ECHO_OFF | FILTER_OFF); query_gdb("set width 0\n", PARSE_OFF | ECHO_OFF | FILTER_OFF); #endif 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); } /* (PW)12MAR93 : the update of cwd[] is done here now. This is done by sending the 'pwd' to gdb. It is important to always use the SAME to get cwd. Sometimes the system get_cwd() and the pwd do not yield the same result. In that case, we would have problems. */ query_gdb("pwd\n", PARSE_ON | 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 (displayedFile && LoadCurrentFile() == 0) /* Only if there is a current displayedFile (pavel 4-Dec-1991) */ { arrow.line = 0; /* clear arrow sign */ updown.line = 0; /* clear updown sign */ bomb.line = 0; /* clear bomb sign */ UpdateArrow(displayedFile); UpdateUpdown(displayedFile); UpdateBomb(displayedFile); ClearStops(); UpdateStops(displayedFile); } UpdateMessageWindow("Ready for execution",NULL); /* clear display window */ query_gdb("display\n", PARSE_ON | ECHO_OFF | FILTER_OFF); } void cd_handler(s) char *s; { strcpy(cwd,s); if (debug) fprintf(stderr,"New cwd[] is \"%s\"\n", s); CleanUpFileTable (); } void pwd_handler(s) char *s; { cd_handler((char *)strtok(s, "\n")); } void search_handler() { AdjustText(Token.line); } /* Show output on the display window. * If output is null but the display window is managed, replace contents of * the display window with the null string. */ void display_info_handler() { Arg args[MAXARGS]; Cardinal n; #ifndef NEW_INTERFACE #ifdef UNDISPWIN /* this code removes the display window when there is nothing to display (GWC) */ if (!Token.display || strcmp(Token.display, "") == 0) { XtUnmanageChild(separator); XtUnmanageChild(displayWindow); return; } #endif /* UNDISPWIN */ #endif /* NEW_INTERFACE */ if (!Token.display || strcmp(Token.display, "") == 0) { #ifndef NEW_INTERFACE if (!XtIsManaged(displayWindow)) return; else { #endif XtFree(Token.display); Token.display = XtNewString(""); #ifndef NEW_INTERFACE } #endif } #ifndef NEW_INTERFACE if (!XtIsManaged(displayWindow)) { XtManageChild(separator); XtManageChild(displayWindow); } #endif n = 0; XtSetArg(args[n], XtNstring, (XtArgVal) Token.display); n++; XtSetValues(displayWindow, args, n); XtFree(Token.display); Token.display = 0; /*(PW)14JAN91 */ } /* Place a stop sign next to the line specified on the source file window * if it is to be viewable. */ void break_handler() { char * file; int line; int stop; if (Token.stop == 0 || Token.line == 0 || Token.file == 0) return; line = Token.line; stop = Token.stop; if (Token.stop >= 256) /* see MAXSTOPS in signs.c */ { fprintf(stderr,"Too many breakpoints\n"); return; } /* load & display file if none is displayed */ file = GetSourcePathname(Token.file); if (file == NULL) return; /* (PW)11JAN91 */ if (displayedFile == NULL) { LoadFile(file); AdjustText(line); } stops[stop].file = file; stops[stop].line = line; stops[stop].tag = 0; nstops = stop; /* display breakpoint sign if file is displayed */ if (displayedFile) { if (!strcmp(file, displayedFile->pathname)) DisplayStop(displayedFile, line); } } /* info directories */ void info_dir_handler() { if (Token.file) { MakeDirList(Token.file); CleanUpFileTable (); } } /* ARGSUSED */ void directory_handler() { /* Note : for GDB, the 'directory' command with no parameter will reset search directories to current directory only. GDB requires confirmation */ query_gdb_directories(); } void list_handler() { int line; line = Token.line; 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. */ LoadCurrentFile(); AdjustText(line); } else { AppendDialogText("Error list command\n"); bell(0); } } /* ARGSUSED */ void info_line_handler() /* Command was 'info line' */ { /* Note that CurrentFile is not run through simplify_path(). This is ok because LoadFile() will do it. */ if (Token.file) strcpy(CurrentFile, Token.file); else strcpy(CurrentFile, ""); } /* * Delete handler remove the stop specified and undisplayed the stopsign * if it's visible. * It calls the dbx status command to find out what stops are left, and * then update the array of stops accordingly. */ /* ARGSUSED */ void delete_handler() { /* update breakpoints */ query_gdb("info break\n", PARSE_ON | ECHO_OFF | FILTER_OFF); } void display_handler() /* display or undisplay */ { /* update display */ query_gdb("display\n", PARSE_ON | ECHO_OFF | FILTER_ON); } /* (gdb) info break Breakpoints: Num Enb Address Where #1 y 0x000022f4 in main (pw.c line 34) #2 y 0x000022a0 in foo (pw.c line 5) (gdb) info break No breakpoints. New for gdb 4.5 : Num Type Disp Enb Address What 1 breakpoint keep y 0x000022a4 in main at mem.c:9 */ void info_break_handler(output_string) char *output_string; { int i; int line; char c; char type[20],disp[20],enb[20]; if (!output_string) return; if (strncmp(output_string,"Num Type",8)) { /* Pre 4.5 */ while(*output_string) { if (*(output_string++) == '#') { if (sscanf(output_string, "%d %c", &i,&c) == 2) if (i > 0 && i <= nstops && stops[i].line > 0 && c == 'y') stops[i].tag = 1; } } } else { /* for 4.5 Display (Ken Mandelberg, km@mathcs.emory.edu) */ while(*output_string) { if (*(output_string++) == '\n') { if (sscanf(output_string, "%d%s%s%s", &i,type,disp,enb) == 4) if (i > 0 && i <= nstops && stops[i].line > 0 && !strcmp(type,"breakpoint") && !strcmp(enb,"y")) stops[i].tag = 1; } } } for (i=1; i<=nstops; i++) if (stops[i].line > 0) { if (stops[i].tag) stops[i].tag = 0; else { line = stops[i].line; stops[i].line = 0; stops[i].file = NULL; if (LineToStop_no(line) == 0) RemoveStop(line); } } } /* this handler justs update the function name. Because the function name is not always displayed after next,step ... */ static char* funcname = 0; void frame_curr_handler() { if (Token.func == NULL) return; if (funcname) { XtFree(funcname); funcname = 0; } funcname = XtNewString(Token.func); } /* Handle dbx output of run, cont, next, step, return commands. * Result of output parsing is returned in a set of tokens. * * If message is not 0, this is an important message and should * be displayed instead of Token.mesg. * This message will hold the Bus error and segmentation violation errors. * signal is the signal number received (if any). */ void exec_handler(message,signal) char *message; int signal; { int line, status; char *func; /* Print "stopped in ..." line in message window * Adjust text displayed */ if (Token.line == 0) return; if (message) UpdateMessageWindow(message,NULL); else UpdateMessageWindow(Token.mesg,NULL); line = Token.line; func = (Token.func) ? XtNewString(Token.func) : 0; if (Token.file) status = LoadFile(Token.file); else status = -1; /* AJK */ display_info_handler(); /* uses Token.display ! */ /* 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) return; funcname = 0; /* tell frame_curr_handler WE are going to XtFree it */ } arrow.line = line; /* update arrow sign position */ strcpy(arrow.func, func); updown.line = 0; /* remove updown, if any */ if (displayedFile) { strcpy(arrow.file, displayedFile->pathname); } /* Display bomb sign if segmentation fault occurs in source code */ if (status != -1 && message && signal == SIGSEGV) { arrow.line = 0; bomb.line = line; if (func) strcpy(bomb.func, func); if (displayedFile) strcpy(bomb.file, displayedFile->pathname); } else bomb.line = 0; AdjustText(line); XtFree(func); } /* Remove all the arrow and updown signs, print message, then * change the file variable to the file name displayed. */ /* ARGSUSED */ void done_handler(message,signal) char *message; int signal; { arrow.line = 0; updown.line = 0; UpdateArrow(displayedFile); UpdateUpdown(displayedFile); UpdateMessageWindow("Ready for execution",NULL); } /*--------------------------------------------------------------------------+ | | | Function to read the .gdbinit file or any source file. | | | | input : file name. | | | | output : none. | | | +--------------------------------------------------------------------------*/ void read_source_file(file) char *file; { char s[LINESIZ]; FILE *fp; if ((fp = fopen(file, "r"))) { while (fgets(s, LINESIZ, fp)) { /* Check for comment line, DO NOT SEND '\n', Take care of source command, Take care of define or document commands. */ if ((*s != '#') && strcmp(s,"\n")) { if (!(gdb_source_command (s,TRUE) || gdb_define_command (s,fp) || xxgdb_command (s,TRUE))) /* send to gdb only if it is not source, define or an xxgdb command. */ query_gdb(s, PARSE_ON | ECHO_ON | FILTER_ON); } } fclose(fp); } } /* WARNING : source_handler() is NOT called by the parser. It is called by gdb_source_command() in gdb_parser.c. This is because 'source' command is NEVER sent to gdb, instead xxgdb sends the commands in the specified file one by one. */ void source_handler() { char *file; if (!Token.file || strcmp(Token.file, "") == 0) { XtFree(Token.file); Token.file = XtNewString(gdbinit); /* default is .gdbinit */ } file = GetPathname(Token.file); if (file == NULL) { /* error message already displayed by GetPathname() */ return; /* (PW)11JAN91 */ } read_source_file(file); } /* core-file * gdb does not display current line, file, func ..., so we send * 'frame 0' command to have them. */ void core_file_handler() { char *message; int line; int signal; message = XtNewString(Token.mesg); 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; /* Display bomb sign if segmentation fault occurred in source code */ if (line != 0 && signal == SIGSEGV) { arrow.line = 0; bomb.line = line; strcpy(bomb.func, updown.func); strcpy(bomb.file, updown.file); } else { bomb.line = 0; arrow.line = line; strcpy(arrow.func, updown.func); strcpy(arrow.file, updown.file); } UpdateMessageWindow(message,NULL); XtFree(message); 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). | | | | (PW)(DS)19FEB92 NeXT : | | gdb 3.1 for the NeXT OS 2.1 does not answer 'undefined command' when | | trying to execute 'show'. That is why the test for gdb-4.x vs | | gdb 3.x does not work in case of NeXT. Using gdb 3.x as default | | will make xxgdb skip this test. | | The gdb answer is "Ambiguous command "show": shownops, showps.". | | | +--------------------------------------------------------------------------*/ #if defined(NeXT) && defined(NEXTOS_2) static int new_gdb = False; /* special case for NeXT */ #else static int new_gdb = True; /* default : we are running gdb 4.0 */ #endif 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, | | current source full path, | | current source path. | | (returned from 'info source' gdb command). | | | | output : none. | | | +--------------------------------------------------------------------------*/ char cdir[MAXPATHLEN]; /* The compilation directory */ char source_fullpath[MAXPATHLEN]; /* The current source file full path */ char source_path[MAXPATHLEN]; /* The current source file name */ void info_source_handler(compile_dir,current_source_path, current_source) char * compile_dir; char * current_source_path; char * current_source; { cdir[0] = 0; if (compile_dir != NULL) { simplify_path (compile_dir); /* be sure to get only significant path */ if (strlen (compile_dir) < MAXPATHLEN) /* check length */ strcpy (cdir, compile_dir); else UpdateMessageWindow("Path too long \"%s\"", compile_dir); if (LASTCH(cdir) == '/') /* remove last '/' */ LASTCH(cdir) = '\0'; } source_fullpath[0] = 0; if (current_source_path != NULL) { simplify_path (current_source_path); /* be sure to get only significant path */ if (strlen (current_source_path) < MAXPATHLEN) /* check length */ strcpy (source_fullpath, current_source_path); else UpdateMessageWindow("Path too long \"%s\"", current_source_path); } source_path[0] = 0; if (current_source != NULL) { simplify_path (current_source); /* be sure to get only significant path */ if (strlen (current_source) < MAXPATHLEN) /* check length */ strcpy (source_path, current_source); else UpdateMessageWindow("Path too long \"%s\"", current_source); } if (debug) fprintf(stderr,"cdir = \"%s\"\nsource = \"%s\"\nsource full path = \"%s\"\n", cdir, source_path, source_fullpath); } /*--------------------------------------------------------------------------+ | | | Function to simplify a pathname : | | | | /. => / | | /./xxx => /xxx | | /foo/.. => / | | /foo/../xxx => /xxx | | foo/.. => . | | foo/../ => . | | foo/../xxx => xxx | | xxx/ => xxx | | | +--------------------------------------------------------------------------*/ void simplify_path(path) char *path; { char *p; int len; for (p = path; *p;) { if (!strncmp (p, "/./", 2) && (p[2] == 0 || p[2] == '/')) { if (p[2] == 0 && p == path) /* '/.' => '/' */ *(p+1) = 0; /* keep first '/' */ else strcpy (p, p + 2); /* '/./xxx' => '/xxx' */ } else if (!strncmp (p, "/..", 3) && (p[3] == 0 || p[3] == '/') && p != path) { char *q = p; /* search previous '/' */ while (q != path && q[-1] != '/') q--; if (q != path) /* previous '/' was found */ { if (p[3] == 0 && (q-1) == path) /* '/foo/..'=> '/' */ *q = 0; /* keep first '/' */ else strcpy (q-1, p+3); /* '/foo/../xxx' => '/xxx' */ p = q-1; } else /* previous '/' was not found */ { /* 'foo/..' => '.' */ if (p[3] == 0 || p[4] == 0) /* 'foo/../' => '.' */ strcpy (path, "."); else /* 'foo/../xxx'=> xxx */ strcpy (path, p+4); } } else p++; } /* remove last '/' if not in first position */ len = strlen(path); if ((len > 1) && (path[len-1] == '/')) path[len-1] = 0; } xxgdb-1.12.orig/gdb_regex.h100644 1012 1010 52705 5745756553 14614 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* * gdb_regex.h: * * Regular expression pattern matching for GNU gdb. * * The reg_token array indicates the register no. for each token type. * reg_token[0] : message * reg_token[1] : stop number * reg_token[2] : function name * reg_token[3] : line number * reg_token[4] : file name * reg_token[5] : display command output */ #define TK_MESG 0 #define TK_STOP 1 #define TK_FUNC 2 #define TK_LINE 3 #define TK_FILE 4 #define TK_DISP 5 #define O_EXEC_MESS_AFTER 0 #define O_EXEC_MESS_BEFORE 1 #define O_EXEC_GDB 2 #define O_DONE 3 #define O_BREAK 4 /* Instead of O_STOPAT & O_STOPIN */ #define O_INFO_DIR 5 /* NEW for GDB */ #define O_FRAME_CURR 6 /* O_FRAME_CURR = O_UPDOWN */ #define O_UPDOWN 6 #define O_BELL 7 #define O_SEARCH 8 #define O_INFO_LINE 9 /* Instead of O_FILE */ #define O_PRINT 10 #define O_DEBUG 11 #define O_DIRECTORY 12 #define O_LIST 13 /* for dbx, O_LIST = O_SEARCH */ #define O_DISPLAY 14 #define O_DISPLAY_INFO 15 #define O_PWD 16 #define O_CD 16 /* O_PWD = O_CD */ #define O_RECEIVED_SIGNAL 17 /* test program received signal */ #define O_EXEC_DISPLAY 18 /* special for filter_display_info */ #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) */ #define O_UPDOWN_NOSOURCE 23 /* up/down in no source file */ #define C_ANY -1 #define C_EXEC 0 #define C_BREAK 1 /* Instead of C_STOPAT & C_STOPIN */ #define C_INFO_DIR 2 /* NEW for GDB */ #define C_FRAME_CURR 3 #define C_UPDOWN 4 #define C_DELETE 5 #define C_FINISH 6 /* Instead of C_FUNC */ #define C_INFO_LINE 7 /* Instead of C_FILE */ #define C_SYMBOL_FILE 8 #define C_CD 9 #define C_DIRECTORY 10 /* Instead of C_USE */ #define C_PWD 11 #define C_LIST 12 #define C_SEARCH 13 #define C_DISPLAY_INFO 14 /* must be BEFORE C_DISPLAY ! */ #define C_DISPLAY 15 #define C_UNDISPLAY 16 #define C_PRINT 17 #define C_INFO_BREAK 18 #define C_SOURCE 19 #define C_EXEC_FILE 20 #define C_CORE_FILE 21 #define C_DEFINE 22 #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 */ /*--------------------------------------------------------------------------+ | | | DBX | | | | Reading symbolic information... | | Read 46 symbols | | (dbx) | | (dbx) | | stopped in main at line 5 in file "pw.c" | | 5 for (i=0; i<100; i++) | | (dbx) use | | /usr1/gnu_sun4/xdbx/ | | (dbx) file | | pw.c | | (dbx) file | | No current source file | | | +--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------+ | | | GDB | | | | Reading symbol data from /usr1/gnu_sun4/xdbx/pw...done. | | Type "help" for a list of commands. | | (gdb) | | (gdb) | | Bpt 1, main () (pw.c line 5) | | 5 for (i=0; i<100; i++) | | (gdb) info directories | | Source directories searched: /usr1/gnu_sun4/xdbx:/usr1/toto | | (gdb) info line | | Line 10 of "pw.c" starts at pc 0x22dc and ends at 0x22e4. | | (gdb) info line | | No source file specified. | | | +--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------+ | | | GDB -fullname | | | | | | We use option -fullname (see dbxoptions() in xdbx.c). | | | | GDB prints (see source.c of gdb): | | | | "\032\032%s:%d:%d:%s:0x%x\n", s->fullname, | | line, s->line_charpos[line - 1], | | mid_statement ? "middle" : "beg", | | get_frame_pc (get_current_frame())); | | | | (gdb) break main | | Reading in symbols for pw.c...done. | | Breakpoint 1 at 0x229c: file pw.c, line 5. | | (gdb) run | | Starting program: /usr1/gnu_sun4/xdbx/pw | | | | Bpt 1, main () (pw.c line 5) | | /usr1/gnu_sun4/xdbx/pw.c:5:17:beg:0x229c | | (gdb) step | | /usr1/gnu_sun4/xdbx/pw.c:6:40:beg:0x22b0 | | (gdb) | | | | (gdb) info directories | | Source directories searched: /usr1/gnu_sun4/xdbx | | (gdb) info line | | Line 10 of "pw.c" starts at pc 0x22dc and ends at 0x22e4. | | (gdb) info line | | No source file specified. | | (gdb) info line | | Line number 34 is out of range for "bug1.c". | | | | (gdb) display i | | 3: i = 0 | | (gdb) display | | 4: i + 1 = 1 | | 3: i = 0 | | (gdb) undisplay 2 | | (gdb) display | | (gdb) | | | | (gdb) up | | #2 0x2314 in main () (pw.c line 35) | | /usr1/gnu_sun4/xdbx/pw.c:35:158:beg:0x2360 | | (gdb) up | | Initial frame selected; you cannot go up. | | (gdb) | | | | (gdb) down | | #0 glop (number=1) (pw2.c line 5) | | /usr1/gnu_sun4/xdbx/pw2.c:5:33:beg:0x2360 | | (gdb) down | | Bottom (i.e., innermost) frame selected; you cannot go down. | | (gdb) | | | | (gdb) pwd | | Working directory /usr1/gnu_sun4/xdbx. | | (gdb) cd .. | | Working directory /usr1/gnu_sun4. | | (gdb) cd xdbx | | Working directory /usr1/gnu_sun4/xdbx. | | (gdb) cd toto | | toto: No such file or directory. | | (gdb) | | | | Program exited with code 01. | | (gdb) | | | +--------------------------------------------------------------------------*/ /* . --> any character but '\n' * --> any character 0 to n times + --> any character 1 to n times ? --> any character 0 or 1 time ^ --> begin of line or NOT following character $ --> end of line or '$' \\w --> character '0..9a..zA...Z' \\W --> character NOT '0..9a..zA...Z' \\< --> word begin (word is composed of 0..9a..zA...Z) \\> --> word end (word is composed of 0..9a..zA...Z) \\b --> word bound \\B --> not word bound \\| --> means OR \\` --> begin buffer \\\' --> end buffer >> WARNING : be carefull with \\| (OR) : the re_match() function >> will NOT correctly update the string for a pattern which is >> optional ! >> --> The number SHOULD NOT point to a patterm which is optional ! */ /* (PW)5DEC90: I have a problem if we say \\(Bpt.*\n\\)? in exec pattern. That is why I have two cases : with or without Bpt... Note that 'exec without Message' includes 'exec with Message'. We display 'Bpt...' in the message window. */ /* (PW)14JAN91 (v1.01) : use \\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\) instead of \\(\\([0-9]+:.*\n\\)*\\) for display pattern. (PW)21APR95 :For gdb 4.14 (Sun) : \032\032/net/tcela/sky/aoutwrap/sun/../aoutwrap.c:714:21758:beg:125f0 ^^^^^ So change :0.+\n into :.+\n for exec patterns and up/down pattern. It is now possible that those new patterns works also for NeXT, but I cannot test so I will leave the ifdef NexT. */ static PatternRec output_pattern[] = { #ifndef NeXT /* if standard GDB */ /* 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} }, /* 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} }, /* 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} }, #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} }, /* 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} }, /* 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} }, #endif /* NeXT */ /* done */ {"\\(.*\n\\)*\n\\(Program terminated with signal \\|Program exited with code 0\\|Program exited normally\\).*\n\\(.*\n\\)*", NULL, {-1, -1, -1, -1, -1, -1} }, #if defined (NeXT) && !defined(NEXTOS_2) #if defined(NEXTOS_3_0) /* NeXT 3.0 gdb is special case : uses "file:#" intead of "file, line #" */ /* break */ {"\\(.*\n\\)*Breakpoint \\([0-9]+\\) at [^ \n]+: file \\([^ \n]+\\):\\([0-9]+\\).\n", NULL, {-1, 2, -1, 4, 3, -1} }, #else /* NeXT 3.X gdb is special case : leaves out "file" label altogether */ /* break */ {"\\(.*\n\\)*Breakpoint \\([0-9]+\\) at [^ \n]+: \\([^ \n]+\\):\\([0-9]+\\).\n", NULL, {-1, 2, -1, 4, 3, -1} }, #endif #else /* if standard GDB */ /* break */ {"\\(.*\n\\)*Breakpoint \\([0-9]+\\) at [^ \n]+: file \\([^ \n]+\\), line \\([0-9]+\\).\n", NULL, {-1, 2, -1, 4, 3, -1} }, #endif /* NeXT */ /* info directories */ {"Source directories searched:[ ]*\\([^ \n]+\\)[ ]*\n", NULL, { -1, -1, -1, -1, 1, -1} }, #ifndef NeXT /* if standard GDB */ /* up, down */ {"\\(.*\n\\)*\\(#[0-9]+[ ]+\\(0[^ \n]+[ ]+in[ ]+\\)?\\([^ \n]+\\)[^\032]*\\)\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\):.+\n", NULL, {2, -1, 4, 6, 5, -1} }, #else /* NeXT is a special case : same as standard except that ":0x.+" are removed. */ /* up, down */ {"\\(.*\n\\)*\\(#[0-9]+[ ]+\\(0[^ \n]+[ ]+in[ ]+\\)?\\([^ \n]+\\)[^\032]*\\)\032\032\\([^ \n]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ \n]+\\)\n", NULL, {2, -1, 4, 6, 5, -1} }, #endif /* NeXT */ /* bell */ {"\\(Undefined command: .*\n\\|Already at the \\(top\\|bottom\\) call level\n\\|\ No active stack frames\n\\|no program to run\n\\|no process to run\n\\|\ program is not active\n\\|can't continue execution\n\\|\ .*\ncan't write to process.*\n\\|\ \\(Top\\|End\\)-of-file; did not find search string:.*\n\\)", NULL, {-1, -1, -1, -1, -1, -1} }, /* search */ {"\\([0-9]+\\).*\n", NULL, {-1, -1, -1, 1, -1, -1} }, /* info line */ {"\\(\\(Line \\(number \\)?[0-9]+ \\(of\\|is out of range for\\) \"\\([^ \n]+\\)\".*\\)\\|\\(No symbol table is loaded.*\\)\\|\\(No source file specified.*\\)\\|\\(No line number.*\\)\\)\n", NULL, {-1, -1, -1, -1, 5, -1} }, /* print */ {"\\(warning: .*\n\\)?\\(\\(.*\\) = .*\n\\(.*\n\\)*\\)", NULL, { 3, -1, -1, -1, -1, 2} }, /* start gdb (debug) */ {"\\(.*\n\\)*Type \"help\" for a list of commands.\n", NULL, { -1, -1, -1, -1, -1, -1} }, /* directory */ {"\\([^ \n]+ is already in the source path.[ ]*\n\\)*Source directories searched:[ ]*\\([^ \n]+\\)[ ]*\n", NULL, { -1, -1, -1, -1, 1, -1} }, /* list : 22MAY91 put message in Token.mesg (edit again 30MAY91) */ {"\\(\\([^0-9\n]+.*\n\\)*\\)\\(.*\n\\)*\\(\\([0-9]+\\).*\n\\)", NULL, { 1, -1, -1, 5, -1, -1} }, /* {"\\(\\(.*\n\\)*\\)\\(\\([0-9]+\\).*\n\\)", NULL, { 1, -1, -1, 4, -1, -1} }, */ /* display */ {"\\([0-9]+:.*\n\\)", NULL, { -1, -1, -1, -1, -1, 1} }, /* info display */ {"\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*[ }]*}\n\\)?\\)*\\)\\(\\(.*\n\\)*\\)", NULL, { 5, -1, -1, -1, -1, 1} }, /* {"\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)", NULL, { -1, -1, -1, -1, -1, 1} }, */ /* pwd or cd */ /* 11JUN92: Fix by Michael L. Graham : pb with symbolic link directories */ /* {"Working directory[ ]+\\([^ \n]+\\).[ ]*\n\\([ ]*(canonically[ ]+\\([^ \n]+\\)).\n\\)?", */ /* (PW)23NOV92 : the patch did not work when directory name includes '.' */ /* {"Working directory[ ]+\\([^ \n.]+\\)\\.?[ ]*\n\\([ ]*(canonically[ ]+\\([^ \n]+\\)).\n\\)?",*/ {"Working directory[ ]+\\([^ \n]+\\)[ ]*\\(\n[ ]*(canonically[ ]+\\([^ \n]+\\))\\)?.\n", NULL, { 1, -1, -1, -1, -1, 3} }, /* program received signal */ {"\\(.*\n\\)*\n\\(Program received signal \\([-]?[0-9]+\\), [^ \n]+.*\n\\)\\(.*\n\\)*", NULL, { 2, 3, -1, -1, -1, -1} }, /* special for test in filter_display_info() */ {"\\([^0-9\n].*\n\\)*\\([0-9]+:.*\n\\)\\(.*\n\\)*", NULL, { -1, -1, -1, -1, -1, 2} }, /* special for test in filter_reading_symbols() */ {"\\(.*\n\\)*\\(Reading in symbols for .*done.\n\\)\\(.*\n\\)*", NULL, { 2, -1, -1, -1, -1, -1} }, /* core-file */ {"\\(.*\n\\)*\\(Program terminated with signal \\([-]?[0-9]+\\), [^ \n]+.*\n\\)\\(.*\n\\)*", NULL, { 2, 3, -1, -1, -1, -1} }, /* Undefined show command (for test gdb 4.0) */ {"\\(Undefined command: \"show\".\n\\)", NULL, {-1, -1, -1, -1, -1, -1} }, /* info source (for gdb 4.0) */ {"\\(.*\n\\)*Current source file is \\([^ ]+\\)\nCompilation directory is \\([^ ]+\\)\nLocated in \\([^ ]+\\)\n\\(.*\n\\)*", NULL, { 3, -1, 2, -1, 4, -1} }, /* up, down with no source file */ {"\\(.*\n\\)*\\(#[0-9]+[ ]+\\(0[^ \n]+[ ]+in[ ]+\\)?\\([^ \n]+\\).*\\)\n", NULL, {2, -1, 4, -1, -1, -1} }, { NULL, /* last one */ NULL, {-1, -1, -1, -1, -1, -1} } }; /* To simplify the patterns, I used for example : "f[rame]*" instead of "frame\\|fram\\|fra||fr". This will cause 'frmeame' to be accepted. But this is no problem because 'Undefined command' output is parsed before parsing the command line (see parse() in parser.c). */ static PatternRec command_pattern[] = { /* run -r - cont - c - next - n - step - s - nexti - ni - stepi - si - return 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 */ {"[ ]*\\(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 current frame. Else 'frame n' is like up or down. */ /* CRL mod 23 4/5/91 GWC - changed fr[ame] to f[rame] */ {"[ ]*f[rame]*[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(up\\|down\\|dow\\|do\\|f[rame]*\\)\\( .*\\)?\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* delete - d - clear - enable - disable - dis - disa */ /* gdb commands 'delete display' 'enable display' and 'delete environment' are also found here. This is superfluous, but no problem */ {"[ ]*\\(del[ete]*\\|d\\|cl[ear]*\\|en[able]*\\|disab[le]*\\|dis\\|disa\\)\\( .*\\)?\n", 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}}, /* symbol-file */ {"[ ]*sy.*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*cd[ ]*[^ \n]+[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* directory */ {"[ ]*dir.*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*pwd[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* list */ {"[ ]*\\(l\\|li\\|lis\\|list\\)\\( .*\\)?\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* forward-search or reverse-search or search */ {"[ ]*\\(fo[rward-search]*\\|rev[erse-search]*\\|sea[rch]*\\)[ ]*", NULL, {-1, -1, -1, -1, -1, -1}}, /* 'display' is a special case of 'display exp' since it does not add any expression to be displayed */ {"[ ]*disp[lay]*[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*disp[lay]\\(/[^ \n]+\\)?*[ ]*[^ \n]+[ ]*.*\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* undisplay */ {"[ ]*und.*\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* Note that Token.mesg (if any) is updated with print command (see 1) */ {"[ ]*print[ ]*\\([^ \n]?\\([ ]+[^ \n]+\\)*\\)[ ]*\n", NULL, { 1, -1, -1, -1, -1, -1}}, {"[ ]*info[ ]+break[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* source (note that Token.TK_FILE is updated here) */ {"[ ]*so[urce]*[ ]*\\(.*\\)\n", NULL, {-1, -1, -1, -1, 1, -1}}, /* exec-file (just used internally) */ {"[ ]*ex[ec-file]*.*\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* core-file */ {"[ ]*cor[e-file]*.*\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* define */ {"[ ]*def[ine]*[ ]+[^ \n]+\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* document */ {"[ ]*doc[ument]*[ ]+[^ \n]+\n", NULL, {-1, -1, -1, -1, -1, -1}}, /* 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, /* last one */ NULL, {-1, -1, -1, -1, -1, -1}} }; xxgdb-1.12.orig/global.h100644 1012 1010 24621 6100220307 14063 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* global.h: * * Contain extern declarations of variables and functions. */ #include "defs.h" #if defined(__GNUC__) && !defined(alloca) #define alloca __builtin_alloca #endif #ifndef __alpha #ifndef MAXPATHLEN #define MAXPATHLEN 1024 #endif #endif #if defined(SYSV) && !defined(MAX) #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)>(b)?(b):(a)) #ifdef sco #include #endif #endif /* calldbx.c */ extern void calldbx(); /* fork child, exec dbx */ /* command.c */ extern void CreateCommandPanel(); extern void send_command(); extern char *get_command(); extern void insert_command(); extern void delete_command(); #ifdef NEW_INTERFACE extern void Quit(); #endif /* datadpy.c */ extern void print_handler(); /* printing variables */ /* dbx.c */ extern void debug_init(); /* initial source display */ extern void read_dbx(); /* get data from dbx */ extern void write_dbx(); /* send data to dbx */ extern void query_dbx(); /* ask dbx for info */ /* dialog.c */ extern void DeleteLine(); /* delete line action proc */ extern void DeleteWord(); /* delete word action proc */ extern void CreateDialogWindow(); extern void AppendDialogText(); /* append text to buffer */ /* filemenu.c */ extern void File(); /* file button callback */ /* handler.c */ extern void TextSetTopPosition(); /* sets topDisplayPosition */ extern void AdjustText(); /* adjust display position */ extern void exec_handler(); /* run, cont, next, step */ extern void done_handler(); /* run, cont, next, step */ extern void stop_at_handler(); /* stop at line */ extern void stop_in_handler(); /* stop in function */ extern void updown_handler(); /* move up/down the stack */ extern void delete_handler(); /* delete stop signs */ extern void func_handler(); /* display function */ extern void file_handler(); /* display file */ extern void debug_handler(); /* debug program */ extern void cd_handler(); /* change directory */ extern void pwd_handler(); /* print working directory */ extern void use_handler(); /* update use directory list */ extern void search_handler(); /* display searched string */ extern void list_handler(); /* list source code */ extern void display_handler(); /* show display variables */ /* parser.c */ extern void parser_init(); /* initialization */ extern void parse(); /* parse dbx output */ extern void filter(); /* modify dbx output */ /* signals.c */ extern void trap_signals(); /* signal handling for xdbx */ /* signs.c */ extern void signs_init(); /* initilalize routine */ extern void DisplayStop(); /* show stop sign */ extern void UpdateStops(); /* update position of stops */ extern void ClearStops(); /* mark all stops invalid */ extern void RemoveStop(); /* undisplay stop sign */ extern void UpdateArrow(); /* update position of arrow */ extern void UpdateUpdown(); /* update position of updown */ extern void UpdateBomb(); /* update position of bomb */ /* source.c */ extern void SelectStart(); /* modified select-start */ extern void SelectEnd(); /* modified select-end */ extern void SelectWord(); /* my select word */ extern void PrintSelection(); /* select variable and print */ extern void Update(); /* update line label */ extern void source_init(); /* init routine */ extern void CreateSourceWindow(); extern int LoadFile(); /* display source file */ extern int LoadCurrentFile(); /* display source file */ extern char *GetPathname(); /* get full path name of file */ extern void MakeDirList(); /* maintain list of dirs */ /* utils.c */ extern XawTextPosition TextGetLastPos(); /* get last pos of text */ extern int TextPositionToLine(); /* convert line # to text pos */ extern int LineToStop_no(); /* convert line # to stop # */ extern void DisableWindowResize(); /* do not allow window resize */ extern void bell(); /* sound bell */ extern char *concat(); /* substring search */ /* windows.c */ extern void CreateSubWindows(); /* all subwindows of xdbx */ extern void UpdateFileLabel(); /* update current file name */ extern void UpdateLineLabel(); /* update current line num */ extern void UpdateMessageWindow(); /* update xdbx message */ /* extern variables */ extern Display *display; extern XtAppContext app_context; extern Widget toplevel, fileWindow, sourceForm, sourceWindow, messageWindow, commandWindow, dialogWindow, searchWindow, #ifndef NEW_INTERFACE separator, #endif displayWindow; #ifdef NEW_INTERFACE extern Widget pcWindow; extern Widget sourceShell; extern Widget sourceToggle; extern Widget commandShell; extern Widget commandToggle; extern Widget displayShell; extern Widget displayToggle; extern Atom wm_delete_window; #endif extern Cursor watch; /* XC_watch cursor */ extern XdbxResources app_resources; /* application resources */ extern char xdbxinit[]; /* initialization filename */ extern char *dbxprompt; /* dbx prompt string */ extern char *xdbxprompt; /* xdbx prompt string */ extern Boolean Tstartup; extern Boolean debug; extern FileRec *displayedFile; /* pointer to current file info */ extern Tokens Token; /* token structure */ 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 */ extern int dbxpid; /* dbx process id */ extern FILE *dbxfp; /* file pointer to dbx process */ #ifdef CREATE_IO_WINDOW extern int iowinpid; /* process id of io window */ extern char iowintty[]; /* the tty of the io window */ #endif /* CREATE_IO_WINDOW */ extern char CurrentFile[]; /* string for dbx output */ extern char cwd[]; /* current working directory of dbx */ extern Arrow arrow; /* arrow widget and mapped info */ extern Updown updown; /* updown widget and mapped info */ extern Stops stops[]; /* stop widget and mapped info */ extern Bomb bomb; /* bomb widget and mapped info */ extern Cardinal nstops; /* number of stops */ #ifdef GDB extern void display_info_handler(); extern void break_handler(); extern void info_dir_handler(); extern void directory_handler(); 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(); extern void StartEditor(); extern void signal_interrupt_dbx(); extern int new_gdb4(); extern char * GetSourcePathname(); extern int gdb_define_command(); extern int gdb_source_command(); extern int xxgdb_command(); extern void CleanUpFileTable(); extern void core_file_handler(); extern void frame_curr_handler(); extern void source_handler(); #endif #ifdef GDB /* (PW)11SEP91 : for gdb 4.0 */ extern char cdir[]; /* compilation directory */ extern char source_fullpath[]; /* source full path output by 'info_source' */ extern char source_path[]; /* source file name */ void simplify_path(); extern char gdbinit[]; /* default gdb startup file (.gdbinit usually) */ #endif xxgdb-1.12.orig/regex.c100644 1012 1010 135657 6224427401 13777 0ustar geyerAlgebra/* Extended regular expression matching and search. Copyright (C) 1985 Free Software Foundation, Inc. NO WARRANTY BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. GENERAL PUBLIC LICENSE TO COPY 1. You may copy and distribute verbatim copies of this source file as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy a valid copyright notice "Copyright (C) 1985 Free Software Foundation, Inc."; and include following the copyright notice a verbatim copy of the above disclaimer of warranty and of this License. You may charge a distribution fee for the physical act of transferring a copy. 2. You may modify your copy or copies of this source file or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains or is a derivative of this program or any part thereof, to be licensed at no charge to all third parties on terms identical to those contained in this License Agreement (except that you may choose to grant more extensive warranty protection to some or all third parties, at your option). c) You may charge a distribution fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another unrelated program with this program (or its derivative) on a volume of a storage or distribution medium does not bring the other program under the scope of these terms. 3. You may copy and distribute this program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal shipping charge) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs. 4. You may not copy, sublicense, distribute or transfer this program except as expressly provided under this License Agreement. Any attempt otherwise to copy, sublicense, distribute or transfer this program is void and your rights to use the program under this License agreement shall be automatically terminated. However, parties who have received computer software programs from you with this License Agreement will not have their licenses terminated so long as such parties remain in full compliance. 5. If you wish to incorporate parts of this program into other free programs whose distribution conditions are different, write to the Free Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet worked out a simple rule that can be stated here, but we will often permit this. We will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software. In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! */ /* To test, compile with -Dtest. This Dtestable feature turns this into a self-contained program which reads a pattern, describes how it compiles, then reads a string and searches for it. */ /* * Modification: alloca.h included for sparc machines * By : Po Cheung, po@cerc.utexas.edu * Date : July 27, 1990 */ #ifndef NeXT #include #endif #include #include #include #include #ifdef sparc #include #else #pragma alloca #endif #define FAILURE_STACK 20000 /* max failure stack size */ #ifdef __GNUC__ #ifdef alloca #undef alloca #endif #define alloca __builtin_alloca #endif #ifdef __STDC__ static int bcmp_translate (unsigned char *, unsigned char *s2, int len, unsigned char *translate); /* (MJH) */ #endif /* __STDC__ */ /* bcopy, bzero and bcmp are needed if we are on Solaris */ #ifdef SYSV #ifdef SUNOS4 void bcopy(s1, s2, len) register char *s1, *s2; int len; { for (; len; len--) *(s2++) = *(s1++); } int bcmp(s1, s2, len) register char *s1, *s2; int len; { for (; len; len--) if (*(s1++) != *(s2++)) return 1; return 0; } void bzero(sp, len) register char *sp; int len; { for (; len; len--) *(sp++) = 0; } #endif /* SUNOS4 */ #endif /* SYSV */ #ifdef emacs /* The `emacs' switch turns on certain special matching commands that make sense only in emacs. */ #include "config.h" #include "lisp.h" #include "buffer.h" #include "syntax.h" #else /* not emacs */ /* * Define the syntax stuff, so we can do the \<...\> things. */ #ifndef Sword /* must be non-zero in some of the tests below... */ #define Sword 1 #endif #define SYNTAX(c) re_syntax_table[c] #ifdef SYNTAX_TABLE char *re_syntax_table; #else static char re_syntax_table[256]; static void init_syntax_once () { register int c; static int done = 0; if (done) return; bzero (re_syntax_table, sizeof re_syntax_table); for (c = 'a'; c <= 'z'; c++) re_syntax_table[c] = Sword; for (c = 'A'; c <= 'Z'; c++) re_syntax_table[c] = Sword; for (c = '0'; c <= '9'; c++) re_syntax_table[c] = Sword; done = 1; } #endif /* SYNTAX_TABLE */ #endif /* not emacs */ #include "regex.h" /* Number of failure points to allocate space for initially, when matching. If this number is exceeded, more space is allocated, so it is not a hard limit. */ #ifndef NFAILURES #define NFAILURES 80 #endif /* NFAILURES */ /* width of a byte in bits */ #define BYTEWIDTH 8 #ifndef SIGN_EXTEND_CHAR #define SIGN_EXTEND_CHAR(x) ((signed char)(x)) #endif /* compile_pattern takes a regular-expression descriptor string in the user's format and converts it into a buffer full of byte commands for matching. pattern is the address of the pattern string size is the length of it. bufp is a struct re_pattern_buffer * which points to the info on where to store the byte commands. This structure contains a char * which points to the actual space, which should have been obtained with malloc. compile_pattern may use realloc to grow the buffer space. The number of bytes of commands can be found out by looking in the struct re_pattern_buffer that bufp pointed to, after compile_pattern returns. */ #define PATPUSH(ch) (*b++ = (char) (ch)) #define PATFETCH(c) \ {if (p == pend) goto end_of_pattern; \ c = * (unsigned char *) p++; \ if (translate) c = translate[c]; } #define PATFETCH_RAW(c) \ {if (p == pend) goto end_of_pattern; \ c = * (unsigned char *) p++; } #define PATUNFETCH p-- /* This version of EXTEND_BUFFER will now work Alpha Machines, and non Alpha Machines. It isn't quite clean but it is cleaner than the previous version that really only worked at all with 32bit pointers. Dean Michaels, TRLabs. dean@trlabs.ca */ #define EXTEND_BUFFER \ { char *old_buffer = bufp->buffer; \ if (bufp->allocated == (1<<16)) goto too_big; \ bufp->allocated *= 2; \ if (bufp->allocated > (1<<16)) bufp->allocated = (1<<16); \ if (!(bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated))) \ goto memory_exhausted; \ c = bufp->buffer - old_buffer; \ b -= (-(int)c); \ if (fixup_jump) \ fixup_jump -= (-(int)c); \ if (laststart) \ laststart -= (-(int)c); \ begalt -= (-(int)c); \ if (pending_exact) \ pending_exact -= (-(int)c); \ } static int store_jump (), insert_jump (); char * re_compile_pattern (pattern, size, bufp) char *pattern; int size; struct re_pattern_buffer *bufp; { register char *b = bufp->buffer; register char *p = pattern; char *pend = pattern + size; register unsigned c, c1; char *p1; unsigned char *translate = (unsigned char *) bufp->translate; /* address of the count-byte of the most recently inserted "exactn" command. This makes it possible to tell whether a new exact-match character can be added to that command or requires a new "exactn" command. */ char *pending_exact = 0; /* address of the place where a forward-jump should go to the end of the containing expression. Each alternative of an "or", except the last, ends with a forward-jump of this sort. */ char *fixup_jump = 0; /* address of start of the most recently finished expression. This tells postfix * where to find the start of its operand. */ char *laststart = 0; /* In processing a repeat, 1 means zero matches is allowed */ char zero_times_ok; /* In processing a repeat, 1 means many matches is allowed */ char many_times_ok; /* address of beginning of regexp, or inside of last \( */ char *begalt = b; /* Stack of information saved by \( and restored by \). Four stack elements are pushed by each \(: First, the value of b. Second, the value of fixup_jump. Third, the value of regnum. Fourth, the value of begalt. */ int stackb[40]; int *stackp = stackb; int *stacke = stackb + 40; int *stackt; /* Counts \('s as they are encountered. Remembered for the matching \), where it becomes the "register number" to put in the stop_memory command */ int regnum = 1; bufp->fastmap_accurate = 0; #ifndef emacs #ifndef SYNTAX_TABLE /* * Initialize the syntax table. */ init_syntax_once(); #endif #endif if (bufp->allocated == 0) { bufp->allocated = 28; if (bufp->buffer) /* EXTEND_BUFFER loses when bufp->allocated is 0 */ bufp->buffer = (char *) realloc (bufp->buffer, 28); else /* Caller did not allocate a buffer. Do it for him */ bufp->buffer = (char *) malloc (28); if (!bufp->buffer) goto memory_exhausted; begalt = b = bufp->buffer; } while (p != pend) { if (b - bufp->buffer > bufp->allocated - 10) /* Note that EXTEND_BUFFER clobbers c */ EXTEND_BUFFER; PATFETCH (c); switch (c) { case '$': /* $ means succeed if at end of line, but only in special contexts. If randonly in the middle of a pattern, it is a normal character. */ if (p == pend || (*p == '\\' && (p[1] == ')' || p[1] == '|'))) { PATPUSH (endline); break; } goto normal_char; case '^': /* ^ means succeed if at beg of line, but only if no preceding pattern. */ if (laststart) goto normal_char; PATPUSH (begline); break; case '*': case '+': case '?': /* If there is no previous pattern, char not special. */ if (!laststart) goto normal_char; /* If there is a sequence of repetition chars, collapse it down to equivalent to just one. */ zero_times_ok = 0; many_times_ok = 0; while (1) { zero_times_ok |= c != '+'; many_times_ok |= c != '?'; if (p == pend) break; PATFETCH (c); if (!(c == '*' || c == '+' || c == '?')) { PATUNFETCH; break; } } /* Now we know whether 0 matches is allowed, and whether 2 or more matches is allowed. */ if (many_times_ok) { /* If more than one repetition is allowed, put in a backward jump at the end. */ store_jump (b, maybe_finalize_jump, laststart - 3); b += 3; } insert_jump (on_failure_jump, laststart, b + 3, b); pending_exact = 0; b += 3; if (!zero_times_ok) { /* At least one repetition required: insert before the loop a skip over the initial on-failure-jump instruction */ insert_jump (dummy_failure_jump, laststart, laststart + 6, b); b += 3; } break; case '.': laststart = b; PATPUSH (anychar); break; case '[': if (b - bufp->buffer > bufp->allocated - 3 - (1 << BYTEWIDTH) / BYTEWIDTH) /* Note that EXTEND_BUFFER clobbers c */ EXTEND_BUFFER; laststart = b; if (*p == '^') PATPUSH (charset_not), p++; else PATPUSH (charset); p1 = p; PATPUSH ((1 << BYTEWIDTH) / BYTEWIDTH); /* Clear the whole map */ bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); /* Read in characters and ranges, setting map bits */ while (1) { PATFETCH (c); if (c == ']' && p != p1 + 1) break; if (*p == '-') { PATFETCH (c1); PATFETCH (c1); while (c <= c1) b[c / BYTEWIDTH] |= 1 << (c % BYTEWIDTH), c++; } else { b[c / BYTEWIDTH] |= 1 << (c % BYTEWIDTH); } } /* Discard any bitmap bytes that are all 0 at the end of the map. Decrement the map-length byte too. */ while (b[-1] > 0 && b[b[-1] - 1] == 0) b[-1]--; b += b[-1]; break; case '\\': if (p == pend) goto invalid_pattern; PATFETCH_RAW (c); switch (c) { case '(': if (stackp == stacke) goto nesting_too_deep; if (regnum < RE_NREGS) { PATPUSH (start_memory); PATPUSH (regnum); } *stackp++ = b - bufp->buffer; *stackp++ = fixup_jump ? fixup_jump - bufp->buffer + 1 : 0; *stackp++ = regnum++; *stackp++ = begalt - bufp->buffer; fixup_jump = 0; laststart = 0; begalt = b; break; case ')': if (stackp == stackb) goto unmatched_close; begalt = *--stackp + bufp->buffer; if (fixup_jump) store_jump (fixup_jump, jump, b); if (stackp[-1] < RE_NREGS) { PATPUSH (stop_memory); PATPUSH (stackp[-1]); } stackp -= 2; fixup_jump = 0; if (*stackp) fixup_jump = *stackp + bufp->buffer - 1; laststart = *--stackp + bufp->buffer; break; case '|': insert_jump (on_failure_jump, begalt, b + 6, b); pending_exact = 0; b += 3; if (fixup_jump) store_jump (fixup_jump, jump, b); fixup_jump = b; b += 3; laststart = 0; begalt = b; break; #ifdef emacs case '=': PATPUSH (at_dot); break; case 's': laststart = b; PATPUSH (syntaxspec); PATFETCH (c); PATPUSH (syntax_spec_code[c]); break; case 'S': laststart = b; PATPUSH (notsyntaxspec); PATFETCH (c); PATPUSH (syntax_spec_code[c]); break; #endif /* emacs */ case 'w': laststart = b; PATPUSH (wordchar); break; case 'W': laststart = b; PATPUSH (notwordchar); break; case '<': PATPUSH (wordbeg); break; case '>': PATPUSH (wordend); break; case 'b': PATPUSH (wordbound); break; case 'B': PATPUSH (notwordbound); break; case '`': PATPUSH (begbuf); break; case '\'': PATPUSH (endbuf); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': c1 = c - '0'; if (c1 >= regnum) goto normal_char; for (stackt = stackp - 2; stackt > stackb; stackt -= 4) if (*stackt == c1) goto normal_char; laststart = b; PATPUSH (duplicate); PATPUSH (c1); break; default: /* You might think it wuld be useful for \ to mean not to translate; but if we don't translate it it will never match anything. */ if (translate) c = translate[c]; goto normal_char; } break; default: normal_char: if (!pending_exact || pending_exact + *pending_exact + 1 != b || *pending_exact == 0177 || *p == '*' || *p == '^' || *p == '+' || *p == '?') { laststart = b; PATPUSH (exactn); pending_exact = b; PATPUSH (0); } PATPUSH (c); (*pending_exact)++; } } if (fixup_jump) store_jump (fixup_jump, jump, b); if (stackp != stackb) goto unmatched_open; bufp->used = b - bufp->buffer; return 0; invalid_pattern: return "Invalid regular expression"; unmatched_open: return "Unmatched \\("; unmatched_close: return "Unmatched \\)"; end_of_pattern: return "Premature end of regular expression"; nesting_too_deep: return "Nesting too deep"; too_big: return "Regular expression too big"; memory_exhausted: return "Memory exhausted"; } /* Store where `from' points a jump operation to jump to where `to' points. `opcode' is the opcode to store. */ static int store_jump (from, opcode, to) char *from, *to; char opcode; { from[0] = opcode; from[1] = (to - (from + 3)) & 0377; from[2] = (to - (from + 3)) >> 8; } /* Open up space at char FROM, and insert there a jump to TO. CURRENT_END gives te end of the storage no in use, so we know how much data to copy up. OP is the opcode of the jump to insert. If you call this function, you must zero out pending_exact. */ static int insert_jump (op, from, to, current_end) char op; char *from, *to, *current_end; { register char *pto = current_end + 3; register char *pfrom = current_end; while (pfrom != from) *--pto = *--pfrom; store_jump (from, op, to); } /* Given a pattern, compute a fastmap from it. The fastmap records which of the (1 << BYTEWIDTH) possible characters can start a string that matches the pattern. This fastmap is used by re_search to skip quickly over totally implausible text. The caller must supply the address of a (1 << BYTEWIDTH)-byte data area as bufp->fastmap. The other components of bufp describe the pattern to be used. */ void re_compile_fastmap (bufp) struct re_pattern_buffer *bufp; { unsigned char *pattern = (unsigned char *) bufp->buffer; int size = bufp->used; register char *fastmap = bufp->fastmap; register unsigned char *p = pattern; register unsigned char *pend = pattern + size; register int j, k; unsigned char *translate = (unsigned char *) bufp->translate; unsigned char *stackb[NFAILURES]; unsigned char **stackp = stackb; bzero (fastmap, (1 << BYTEWIDTH)); bufp->fastmap_accurate = 1; bufp->can_be_null = 0; while (p) { if (p == pend) { bufp->can_be_null = 1; break; } #ifdef SWITCH_ENUM_BUG switch ((int) ((enum regexpcode) *p++)) #else switch ((enum regexpcode) *p++) #endif { case exactn: if (translate) fastmap[translate[p[1]]] = 1; else fastmap[p[1]] = 1; break; case begline: case before_dot: case at_dot: case after_dot: case begbuf: case endbuf: case wordbound: case notwordbound: case wordbeg: case wordend: continue; case endline: if (translate) fastmap[translate['\n']] = 1; else fastmap['\n'] = 1; if (bufp->can_be_null != 1) bufp->can_be_null = 2; break; case finalize_jump: case maybe_finalize_jump: case jump: case dummy_failure_jump: bufp->can_be_null = 1; j = *p++ & 0377; j += SIGN_EXTEND_CHAR (*(char *)p) << 8; p += j + 1; /* The 1 compensates for missing ++ above */ if (j > 0) continue; /* Jump backward reached implies we just went through the body of a loop and matched nothing. Opcode jumped to should be an on_failure_jump. Just treat it like an ordinary jump. For a * loop, it has pushed its failure point already; if so, discard that as redundant. */ if ((enum regexpcode) *p != on_failure_jump) continue; p++; j = *p++ & 0377; j += SIGN_EXTEND_CHAR (*(char *)p) << 8; p += j + 1; /* The 1 compensates for missing ++ above */ if (stackp != stackb && *stackp == p) stackp--; continue; case on_failure_jump: j = *p++ & 0377; j += SIGN_EXTEND_CHAR (*(char *)p) << 8; p++; *++stackp = p + j; continue; case start_memory: case stop_memory: p++; continue; case duplicate: bufp->can_be_null = 1; fastmap['\n'] = 1; case anychar: for (j = 0; j < (1 << BYTEWIDTH); j++) if (j != '\n') fastmap[j] = 1; if (bufp->can_be_null) return; /* Don't return; check the alternative paths so we can set can_be_null if appropriate. */ break; case wordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) == Sword) fastmap[j] = 1; break; case notwordchar: for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) != Sword) fastmap[j] = 1; break; #ifdef emacs case syntaxspec: k = *p++; for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) == (enum syntaxcode) k) fastmap[j] = 1; break; case notsyntaxspec: k = *p++; for (j = 0; j < (1 << BYTEWIDTH); j++) if (SYNTAX (j) != (enum syntaxcode) k) fastmap[j] = 1; break; #endif /* emacs */ case charset: for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) { if (translate) fastmap[translate[j]] = 1; else fastmap[j] = 1; } break; case charset_not: /* Chars beyond end of map must be allowed */ for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) if (translate) fastmap[translate[j]] = 1; else fastmap[j] = 1; for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) { if (translate) fastmap[translate[j]] = 1; else fastmap[j] = 1; } break; } /* Get here means we have successfully found the possible starting characters of one path of the pattern. We need not follow this path any farther. Instead, look at the next alternative remembered in the stack. */ if (stackp != stackb) p = *stackp--; else break; } } /* Like re_search_2, below, but only one string is specified. */ int re_search (pbufp, string, size, startpos, range, regs) struct re_pattern_buffer *pbufp; char *string; int size, startpos, range; struct re_registers *regs; { return re_search_2 (pbufp, 0, 0, string, size, startpos, range, regs, size); } /* Like re_match_2 but tries first a match starting at index STARTPOS, then at STARTPOS + 1, and so on. RANGE is the number of places to try before giving up. If RANGE is negative, the starting positions tried are STARTPOS, STARTPOS - 1, etc. It is up to the caller to make sure that range is not so large as to take the starting position outside of the input strings. The value returned is the position at which the match was found, or -1 if no match was found, or -2 if error (such as failure stack overflow). */ int re_search_2 (pbufp, string1, size1, string2, size2, startpos, range, regs, mstop) struct re_pattern_buffer *pbufp; char *string1, *string2; int size1, size2; int startpos; register int range; struct re_registers *regs; int mstop; { register char *fastmap = pbufp->fastmap; register unsigned char *translate = (unsigned char *) pbufp->translate; int total = size1 + size2; int val; /* Update the fastmap now if not correct already */ if (fastmap && !pbufp->fastmap_accurate) re_compile_fastmap (pbufp); /* Don't waste time in a long search for a pattern that says it is anchored. */ if (pbufp->used > 0 && (enum regexpcode) pbufp->buffer[0] == begbuf && range > 0) { if (startpos > 0) return -1; else range = 1; } while (1) { /* If a fastmap is supplied, skip quickly over characters that cannot possibly be the start of a match. Note, however, that if the pattern can possibly match the null string, we must test it at each starting point so that we take the first null string we get. */ if (fastmap && startpos < total && pbufp->can_be_null != 1) { if (range > 0) { register int lim = 0; register unsigned char *p; int irange = range; if (startpos < size1 && startpos + range >= size1) lim = range - (size1 - startpos); p = ((unsigned char *) &(startpos >= size1 ? string2 - size1 : string1)[startpos]); if (translate) { while (range > lim && !fastmap[translate[*p++]]) range--; } else { while (range > lim && !fastmap[*p++]) range--; } startpos += irange - range; } else { register unsigned char c; if (startpos >= size1) c = string2[startpos - size1]; else c = string1[startpos]; c &= 0xff; if (translate ? !fastmap[translate[c]] : !fastmap[c]) goto advance; } } if (range >= 0 && startpos == total && fastmap && pbufp->can_be_null == 0) return -1; val = re_match_2 (pbufp, string1, size1, string2, size2, startpos, regs, mstop); if (0 <= val) { if (val == -2) return -2; return startpos; } #ifdef C_ALLOCA alloca (0); #endif /* C_ALLOCA */ advance: if (!range) break; if (range > 0) range--, startpos++; else range++, startpos--; } return -1; } #ifndef emacs /* emacs never uses this */ int re_match (pbufp, string, size, pos, regs) struct re_pattern_buffer *pbufp; char *string; int size, pos; struct re_registers *regs; { return re_match_2 (pbufp, 0, 0, string, size, pos, regs, size); } #endif /* emacs */ /* Maximum size of failure stack. Beyond this, overflow is an error. */ /* * Modification: failure stack size increased from 2000 to FAILURE_STACK * By : Po Cheung, po@cerc.utexas.edu * Date : April 15, 1990 */ int re_max_failures = FAILURE_STACK; /* Match the pattern described by PBUFP against data which is the virtual concatenation of STRING1 and STRING2. SIZE1 and SIZE2 are the sizes of the two data strings. Start the match at position POS. Do not consider matching past the position MSTOP. If pbufp->fastmap is nonzero, then it had better be up to date. The reason that the data to match are specified as two components which are to be regarded as concatenated is so this function can be used directly on the contents of an Emacs buffer. -1 is returned if there is no match. -2 is returned if there is an error (such as match stack overflow). Otherwise the value is the length of the substring which was matched. */ #define ALLOCA_CHECK(pt) {if ((pt) == NULL || (pt) == (char**) 0xdeadbeef) { fprintf(stderr,"alloca failed\n"); exit(1);}} int re_match_2 (pbufp, string1, size1, string2, size2, pos, regs, mstop) struct re_pattern_buffer *pbufp; char *string1, *string2; int size1, size2; int pos; struct re_registers *regs; int mstop; { register char *p = pbufp->buffer; register char *pend = p + pbufp->used; /* End of first string */ char *end1; /* End of second string */ char *end2; /* Pointer just past last char to consider matching */ char *end_match_1, *end_match_2; register char *d, *dend; register int mcnt; unsigned char *translate = (unsigned char *) pbufp->translate; /* Failure point stack. Each place that can handle a failure further down the line pushes a failure point on this stack. It consists of two char *'s. The first one pushed is where to resume scanning the pattern; the second pushed is where to resume scanning the strings. If the latter is zero, the failure point is a "dummy". If a failure happens and the innermost failure point is dormant, it discards that failure point and tries the next one. */ char **stackb = (char **) alloca (2 * NFAILURES * sizeof (char *)); char **stackp = stackb, **stacke = &stackb[2 * NFAILURES]; /* Information on the "contents" of registers. These are pointers into the input strings; they record just what was matched (on this attempt) by some part of the pattern. The start_memory command stores the start of a register's contents and the stop_memory command stores the end. At that point, regstart[regnum] points to the first character in the register, regend[regnum] points to the first character beyond the end of the register, regstart_seg1[regnum] is true iff regstart[regnum] points into string1, and regend_seg1[regnum] is true iff regend[regnum] points into string1. */ char *regstart[RE_NREGS]; char *regend[RE_NREGS]; char regstart_seg1[RE_NREGS], regend_seg1[RE_NREGS]; ALLOCA_CHECK(stackb); /* Set up pointers to ends of strings. Don't allow the second string to be empty unless both are empty. */ if (!size2) { string2 = string1; size2 = size1; string1 = 0; size1 = 0; } end1 = string1 + size1; end2 = string2 + size2; /* Compute where to stop matching, within the two strings */ if (mstop <= size1) { end_match_1 = string1 + mstop; end_match_2 = string2; } else { end_match_1 = end1; end_match_2 = string2 + mstop - size1; } /* Initialize \( and \) text positions to -1 to mark ones that no \( or \) has been seen for. */ for (mcnt = 0; mcnt < sizeof (regstart) / sizeof (*regstart); mcnt++) regstart[mcnt] = (char *) -1; assert(regstart[0] == (char *) -1); /* `p' scans through the pattern as `d' scans through the data. `dend' is the end of the input string that `d' points within. `d' is advanced into the following input string whenever necessary, but this happens before fetching; therefore, at the beginning of the loop, `d' can be pointing at the end of a string, but it cannot equal string2. */ if (pos <= size1) d = string1 + pos, dend = end_match_1; else d = string2 + pos - size1, dend = end_match_2; /* Write PREFETCH; just before fetching a character with *d. */ #define PREFETCH \ while (d == dend) \ { if (dend == end_match_2) goto fail; /* end of string2 => failure */ \ d = string2; /* end of string1 => advance to string2. */ \ dend = end_match_2; } /* This loop loops over pattern commands. It exits by returning from the function if match is complete, or it drops through if match fails at this starting point in the input data. */ while (1) { if (p == pend) /* End of pattern means we have succeeded! */ { /* If caller wants register contents data back, convert it to indices */ if (regs) { regs->start[0] = pos; if (dend == end_match_1) regs->end[0] = d - string1; else regs->end[0] = d - string2 + size1; for (mcnt = 1; mcnt < RE_NREGS; mcnt++) { if (regstart[mcnt] == (char *) -1) { regs->start[mcnt] = -1; regs->end[mcnt] = -1; continue; } if (regstart_seg1[mcnt]) regs->start[mcnt] = regstart[mcnt] - string1; else regs->start[mcnt] = regstart[mcnt] - string2 + size1; if (regend_seg1[mcnt]) regs->end[mcnt] = regend[mcnt] - string1; else regs->end[mcnt] = regend[mcnt] - string2 + size1; } } if (dend == end_match_1) return (d - string1 - pos); else return d - string2 + size1 - pos; } /* Otherwise match next pattern command */ #ifdef SWITCH_ENUM_BUG switch ((int) ((enum regexpcode) *p++)) #else switch ((enum regexpcode) *p++) #endif { /* \( is represented by a start_memory, \) by a stop_memory. Both of those commands contain a "register number" argument. The text matched within the \( and \) is recorded under that number. Then, \ turns into a `duplicate' command which is followed by the numeric value of as the register number. */ case start_memory: regstart[*p] = d; regstart_seg1[*p++] = (dend == end_match_1); break; case stop_memory: regend[*p] = d; regend_seg1[*p++] = (dend == end_match_1); break; case duplicate: { int regno = *p++; /* Get which register to match against */ register char *d2, *dend2; d2 = regstart[regno]; dend2 = (regstart_seg1[regno] == regend_seg1[regno]) ? regend[regno] : end_match_1; while (1) { /* Advance to next segment in register contents, if necessary */ while (d2 == dend2) { if (dend2 == end_match_2) break; if (dend2 == regend[regno]) break; /* end of string1 => advance to string2. */ d2 = string2, dend2 = regend[regno]; } /* At end of register contents => success */ if (d2 == dend2) break; /* Advance to next segment in data being matched, if necessary */ PREFETCH; /* mcnt gets # consecutive chars to compare */ mcnt = dend - d; if (mcnt > dend2 - d2) 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; } } break; case anychar: /* fetch a data character */ PREFETCH; /* Match anything but a newline. */ if ((translate ? translate[*(unsigned char *)d++] : *d++) == '\n') goto fail; break; case charset: case charset_not: { /* Nonzero for charset_not */ int not = 0; register int c; if (*(p - 1) == (char) charset_not) not = 1; /* fetch a data character */ PREFETCH; if (translate) c = translate [*(unsigned char *)d]; else c = *(unsigned char *)d; if (c < *p * BYTEWIDTH && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; p += 1 + *p; if (!not) goto fail; d++; break; } case begline: if (d == string1 || d[-1] == '\n') break; goto fail; case endline: if (d == end2 || (d == end1 ? (size2 == 0 || *string2 == '\n') : *d == '\n')) break; goto fail; /* "or" constructs ("|") are handled by starting each alternative with an on_failure_jump that points to the start of the next alternative. Each alternative except the last ends with a jump to the joining point. (Actually, each jump except for the last one really jumps to the following jump, because tensioning the jumps is a hassle.) */ /* The start of a stupid repeat has an on_failure_jump that points past the end of the repeat text. This makes a failure point so that, on failure to match a repetition, matching restarts past as many repetitions have been found with no way to fail and look for another one. */ /* A smart repeat is similar but loops back to the on_failure_jump so that each repetition makes another failure point. */ case on_failure_jump: if (stackp == stacke) { char **stackx; if (stacke - stackb > re_max_failures) return -2; stackx = (char **) alloca (2 * (stacke - stackb) * sizeof (char *)); ALLOCA_CHECK(stackx); bcopy (stackb, stackx, (stacke - stackb) * sizeof (char *)); stackp += stackx - stackb; stacke = stackx + 2 * (stacke - stackb); stackb = stackx; } mcnt = *p++ & 0377; mcnt += SIGN_EXTEND_CHAR (*p) << 8; p++; *stackp++ = mcnt + p; *stackp++ = d; break; /* The end of a smart repeat has an maybe_finalize_jump back. Change it either to a finalize_jump or an ordinary jump. */ case maybe_finalize_jump: mcnt = *p++ & 0377; mcnt += SIGN_EXTEND_CHAR (*p) << 8; p++; /* Compare what follows with the begining of the repeat. If we can establish that there is nothing that they would both match, we can change to finalize_jump */ if (p == pend) p[-3] = (char) finalize_jump; else if (*p == (char) exactn || *p == (char) endline) { register int c = *p == (char) endline ? '\n' : p[2]; register char *p1 = p + mcnt; /* p1[0] ... p1[2] are an on_failure_jump. Examine what follows that */ if (p1[3] == (char) exactn && p1[5] != c) p[-3] = (char) finalize_jump; else if (p1[3] == (char) charset || p1[3] == (char) charset_not) { int not = p1[3] == (char) charset_not; if (c < p1[4] * BYTEWIDTH && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) not = !not; /* not is 1 if c would match */ /* That means it is not safe to finalize */ if (!not) p[-3] = (char) finalize_jump; } } p -= 2; if (p[-1] != (char) finalize_jump) { p[-1] = (char) jump; goto nofinalize; } /* The end of a stupid repeat has a finalize-jump back to the start, where another failure point will be made which will point after all the repetitions found so far. */ case finalize_jump: stackp -= 2; case jump: nofinalize: mcnt = *p++ & 0377; mcnt += SIGN_EXTEND_CHAR (*p) << 8; p += mcnt + 1; /* The 1 compensates for missing ++ above */ break; case dummy_failure_jump: if (stackp == stacke) { char **stackx = (char **) alloca (2 * (stacke - stackb) * sizeof (char *)); ALLOCA_CHECK(stackx); bcopy (stackb, stackx, (stacke - stackb) * sizeof (char *)); stackp += stackx - stackb; stacke = stackx + 2 * (stacke - stackb); stackb = stackx; } *stackp++ = 0; *stackp++ = 0; goto nofinalize; case wordbound: if (d == string1 /* Points to first char */ || d == end2 /* Points to end */ || (d == end1 && size2 == 0)) /* Points to end */ break; if ((SYNTAX (((unsigned char *)d)[-1]) == Sword) != (SYNTAX (d == end1 ? *(unsigned char *)string2 : *(unsigned char *)d) == Sword)) break; goto fail; case notwordbound: if (d == string1 /* Points to first char */ || d == end2 /* Points to end */ || (d == end1 && size2 == 0)) /* Points to end */ goto fail; if ((SYNTAX (((unsigned char *)d)[-1]) == Sword) != (SYNTAX (d == end1 ? *(unsigned char *)string2 : *(unsigned char *)d) == Sword)) goto fail; break; case wordbeg: if (d == end2 /* Points to end */ || (d == end1 && size2 == 0) /* Points to end */ || SYNTAX (*(unsigned char *) (d == end1 ? string2 : d)) != Sword) /* Next char not a letter */ goto fail; /* prev char not letter */ if (d == string1 /* Points to first char */ || SYNTAX (((unsigned char *)d)[-1]) != Sword) break; goto fail; case wordend: if (d == string1 /* Points to first char */ || SYNTAX (((unsigned char *)d)[-1]) != Sword) /* prev char not letter */ goto fail; if (d == end2 /* Points to end */ || (d == end1 && size2 == 0) /* Points to end */ || SYNTAX (d == end1 ? *(unsigned char *)string2 : *(unsigned char *)d) != Sword) /* Next char not a letter */ break; goto fail; #ifdef emacs case before_dot: if (((d - string2 <= (unsigned) size2) ? d - (char *) bf_p2 : d - (char *) bf_p1) <= point) goto fail; break; case at_dot: if (((d - string2 <= (unsigned) size2) ? d - (char *) bf_p2 : d - (char *) bf_p1) == point) goto fail; break; case after_dot: if (((d - string2 <= (unsigned) size2) ? d - (char *) bf_p2 : d - (char *) bf_p1) >= point) goto fail; break; case wordchar: mcnt = (int) Sword; goto matchsyntax; case syntaxspec: mcnt = *p++; matchsyntax: PREFETCH; if (SYNTAX (*(unsigned char *)d++) != (enum syntaxcode) mcnt) goto fail; break; case notwordchar: mcnt = (int) Sword; goto matchnotsyntax; case notsyntaxspec: mcnt = *p++; matchnotsyntax: PREFETCH; if (SYNTAX (*(unsigned char *)d++) == (enum syntaxcode) mcnt) goto fail; break; #else case wordchar: PREFETCH; if (SYNTAX (*(unsigned char *)d++) == 0) goto fail; break; case notwordchar: PREFETCH; if (SYNTAX (*(unsigned char *)d++) != 0) goto fail; break; #endif /* not emacs */ case begbuf: if (d == string1) /* Note, d cannot equal string2 */ break; /* unless string1 == string2. */ goto fail; case endbuf: if (d == end2 || (d == end1 && size2 == 0)) break; goto fail; case exactn: /* Match the next few pattern characters exactly. mcnt is how many characters to match. */ mcnt = *p++; if (translate) { do { PREFETCH; if (translate[*(unsigned char *)d++] != *p++) goto fail; } while (--mcnt); } else { do { PREFETCH; if (*d++ != *p++) goto fail; } while (--mcnt); } break; } continue; /* Successfully matched one pattern command; keep matching */ /* Jump here if any matching operation fails. */ fail: if (stackp != stackb) /* A restart point is known. Restart there and pop it. */ { if (!stackp[-2]) { /* If innermost failure point is dormant, flush it and keep looking */ stackp -= 2; goto fail; } d = *--stackp; p = *--stackp; if (d >= string1 && d <= end1) dend = end_match_1; } else break; /* Matching at this starting point really fails! */ } return -1; /* Failure to match */ } static int bcmp_translate (s1, s2, len, translate) unsigned char *s1, *s2; register int len; unsigned char *translate; { register unsigned char *p1 = s1, *p2 = s2; while (len) { if (translate [*p1++] != translate [*p2++]) return 1; len--; } return 0; } /* Entry points compatible with bsd4.2 regex library */ #ifndef emacs static struct re_pattern_buffer re_comp_buf; char * re_comp (s) char *s; { if (!s) { if (!re_comp_buf.buffer) return "No previous regular expression"; return 0; } if (!re_comp_buf.buffer) { if (!(re_comp_buf.buffer = (char *) malloc (200))) return "Memory exhausted"; re_comp_buf.allocated = 200; if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH))) return "Memory exhausted"; } return re_compile_pattern (s, strlen (s), &re_comp_buf); } int re_exec (s) char *s; { int len = strlen (s); return 0 <= re_search (&re_comp_buf, s, len, 0, len, 0); } #endif /* emacs */ #ifdef test #include /* Indexed by a character, gives the upper case equivalent of the character */ static char upcase[0400] = { 000, 001, 002, 003, 004, 005, 006, 007, 010, 011, 012, 013, 014, 015, 016, 017, 020, 021, 022, 023, 024, 025, 026, 027, 030, 031, 032, 033, 034, 035, 036, 037, 040, 041, 042, 043, 044, 045, 046, 047, 050, 051, 052, 053, 054, 055, 056, 057, 060, 061, 062, 063, 064, 065, 066, 067, 070, 071, 072, 073, 074, 075, 076, 077, 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377 }; main () { char pat[80]; struct re_pattern_buffer buf; int i; char c; char fastmap[(1 << BYTEWIDTH)]; buf.allocated = 40; buf.buffer = (char *) malloc (buf.allocated); buf.fastmap = fastmap; buf.translate = upcase; while (1) { gets (pat); if (*pat) { re_compile_pattern (pat, strlen(pat), &buf); for (i = 0; i < buf.used; i++) printchar (buf.buffer[i]); putchar ('\n'); printf ("%d allocated, %d used.\n", buf.allocated, buf.used); re_compile_fastmap (&buf); printf ("Allowed by fastmap: "); for (i = 0; i < (1 << BYTEWIDTH); i++) if (fastmap[i]) printchar (i); putchar ('\n'); } gets (pat); /* Now read the string to match against */ i = re_match (&buf, pat, strlen (pat), 0, 0); printf ("Match value %d.\n", i); } } #ifdef NOTDEF print_buf (bufp) struct re_pattern_buffer *bufp; { int i; printf ("buf is :\n----------------\n"); for (i = 0; i < bufp->used; i++) printchar (bufp->buffer[i]); printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used); printf ("Allowed by fastmap: "); for (i = 0; i < (1 << BYTEWIDTH); i++) if (bufp->fastmap[i]) printchar (i); printf ("\nAllowed by translate: "); if (bufp->translate) for (i = 0; i < (1 << BYTEWIDTH); i++) if (bufp->translate[i]) printchar (i); printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't"); printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not"); } #endif printchar (c) char c; { if (c < 041 || c >= 0177) { putchar ('\\'); putchar (((c >> 6) & 3) + '0'); putchar (((c >> 3) & 7) + '0'); putchar ((c & 7) + '0'); } else putchar (c); } error (string) char *string; { puts (string); #ifdef CREATE_IO_WINDOW if (iowinpid) kill(iowinpid, SIGKILL); iowinpid = 0; #endif /* CREATE_IO_WINDOW */ exit (1); } #endif /* test */ xxgdb-1.12.orig/handler.c100644 1012 1010 34646 5630434463 14264 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* handler.c * * Contain action handlers for the parser to invoke upon a dbx command. * * TextSetTopPosition(): Set the top character position of text displayed * AdjustText(): Adjust the portion of text displayed. * exec_handler(): Update file, line label, arrow position. * done_handler(): Progrm execution completed, clear breakpoints * stop_at_handler(): Place stop sign on line specified. * stop_in_handler(): Place stop sign on function specified. * updown_handler(): Update file, line label, updown arrow position. * delete_handler(): Remove stop sign. * func_handler(): Display function, if specified. * file_handler(): Display file, if specified. * debug_handler(): Check directory use list, display source file. * cd_handler(): Record current working directory. * use_handler(): Record directory paths. * search_handler(): Adjust source file to display matched line. * list_handler(); Adjust source file to display result. * display_handler(): Display results in display window. */ #include #include "global.h" #ifdef BSD #define BRACKET "[%d]" #else #define BRACKET "(%d)" #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 */ void TextSetTopPosition(w, pos) Widget w; XawTextPosition pos; { Arg args[MAXARGS]; Cardinal n; n = 0; XtSetArg(args[n], XtNdisplayPosition, (XtArgVal) pos); n++; XtSetValues(w, args, n); } /* * Adjust text so that 'line' will fall into the viewable part of the * source window. * Arrows, stop signs, and line label are updated accordingly. */ void AdjustText(line) int line; { FileRec *file; int nlines = 0; int i; XawTextPosition pos; if ((file = displayedFile) == NULL || line <= 0) return; file->currentline = line; if (line < file->topline || line > file->bottomline ) { /* Position line about 30% from the top */ nlines = file->lines*0.3; if (line < nlines) /* near top */ file->topline = 1; else if (line > file->lastline - nlines) /* near bottom */ file->topline = MAX(file->lastline - file->lines + 1, 1); else file->topline = line - nlines; file->bottomline = MIN(file->topline + file->lines - 1, file->lastline); TextSetTopPosition(sourceWindow, file->linepos[file->topline]); file->topPosition = file->linepos[file->topline]; } XawTextSetInsertionPoint(sourceWindow, file->linepos[line]); /* Text window might have scrolled, check topline & bottomline */ pos = XawTextTopPosition(sourceWindow); for (i=1; pos >= file->linepos[i]; i++); if (file->topline != i-1) { file->topline = i-1; file->bottomline = MIN (file->topline + file->lines - 1, file->lastline); } UpdateLineLabel(line); UpdateStops(file); UpdateArrow(file); UpdateUpdown(file); UpdateBomb(file); } #ifdef GDB #include "gdb_handler.c" #else /*>>>>>>>>>> ALL THE FOLLOWING IS NOT COMPILED FOR GDB <<<<<<<<<<<<<<<<<<<*/ /* Handle dbx output of run, cont, next, step, return commands. * Result of output parsing is returned in a set of tokens. */ void exec_handler() { int line, status; char *func, *mesg; char *segv = "signal SEGV"; char *segfault = "Segmentation fault"; /* Print "stopped in ..." line in message window * Adjust text displayed */ if (Token.func == NULL || Token.line == 0) return; UpdateMessageWindow(Token.mesg,NULL); line = Token.line; func = XtNewString(Token.func); mesg = XtNewString(Token.mesg); #ifdef MIPS status = LoadCurrentFile(); #else if (Token.file) status = LoadFile(Token.file); #endif arrow.line = line; /* update arrow sign position */ strcpy(arrow.func, func); updown.line = 0; /* remove updown, if any */ if (displayedFile) { strcpy(arrow.file, displayedFile->pathname); } /* Display bomb sign if segmentation fault occurs in source code */ if (status != -1 && (strncmp(mesg, segv, strlen(segv)) == 0 || strncmp(mesg, segfault, strlen(segfault)) == 0)) { arrow.line = 0; bomb.line = line; strcpy(bomb.func, func); if (displayedFile) strcpy(bomb.file, displayedFile->pathname); } else bomb.line = 0; AdjustText(line); #ifndef BSD display_handler(); #endif XtFree(func); XtFree(mesg); } /* Remove all the arrow and updown signs, print message, then * change the file variable to the file name displayed. */ void done_handler() { char command[LINESIZ]; arrow.line = 0; updown.line = 0; UpdateArrow(displayedFile); UpdateUpdown(displayedFile); UpdateMessageWindow("Ready for execution",NULL); if (displayedFile == NULL) return; #ifdef MIPS sprintf(command, "file %s\n", displayedFile->filename); #else sprintf(command, "file %s\n", displayedFile->pathname); #endif Parse = False; query_dbx(command); } /* Place a stop sign next to the line specified on the source file window * if it is to be viewable. */ void stop_at_handler() { if (Token.stop == 0 || Token.line == 0 || displayedFile == NULL) return; if (Token.file == NULL) stops[Token.stop].file = displayedFile->pathname; else stops[Token.stop].file = GetPathname(Token.file); DisplayStop(displayedFile, Token.line); stops[Token.stop].line = Token.line; stops[Token.stop].tag = 0; nstops = Token.stop; } /* * Place a stop sign next to the function routine, getting the line number * by "list ", (or "func " on a MIPS), and resetting the file * variable properly. */ void stop_in_handler() { char command[LINESIZ], *file; int stop; int line; if (Token.stop == 0 || Token.func == NULL || displayedFile == NULL) return; stop = Token.stop; #ifdef MIPS /* For mips dbx, need to use func command to locate the function */ Skip_func_handler = True; sprintf(command, "func %s\n", Token.func); query_dbx(command); #else #ifdef BSD sprintf(command, "list %s\n", Token.func); query_dbx(command); #else sprintf(command, "list %s\n", Token.func); query_dbx(command); if (Token.line <= 0) return; else Token.line += 5; #endif #endif stops[stop].line = Token.line; nstops = stop; line = Token.line; /* Check the name of the file containing Token.func */ query_dbx("file\n"); if ((file = GetPathname(CurrentFile)) && strcmp(file, displayedFile->pathname)) { /* new file, record stop */ stops[nstops].file = file; #ifdef MIPS sprintf(command, "file %s\n", displayedFile->filename); #else sprintf(command, "file %s\n", displayedFile->pathname); #endif Parse = False; query_dbx(command); } else { /* same file, display stop */ stops[nstops].file = displayedFile->pathname; DisplayStop(displayedFile, line); } } /* * Display an outlined arrow to locate the calling routine in a stack * frame. BSD and SUN dbx have slightly different output semantics here. * The appropriate file with the calling routine is displayed and the * file variable is set accordingly. */ void updown_handler() { char command[LINESIZ], *func, *file; int line; line = Token.line; func = XtNewString(Token.func); #ifdef MIPS LoadCurrentFile(); #endif #ifdef BSD file = GetPathname(Token.file); #else if (line <= 0) line = 1; LoadCurrentFile(); if (displayedFile) file = displayedFile->pathname; #endif if (line <= 0 || func == NULL || file == NULL) return; if (displayedFile && strcmp(file, displayedFile->pathname)) { LoadFile(file); /* set dbx file variable to file */ #ifdef MIPS sprintf(command, "file %s\n", displayedFile->filename); #else sprintf(command, "file %s\n", displayedFile->pathname); #endif Parse = False; query_dbx(command); } updown.line = line; strcpy(updown.func, func); if (displayedFile) strcpy(updown.file, displayedFile->pathname); AdjustText(line); XtFree(func); } /* * Delete handler remove the stop specified and undisplayed the stopsign * if it's visible. * It calls the dbx status command to find out what stops are left, and * then update the array of stops accordingly. */ /* ARGSUSED */ void delete_handler() { char s[LINESIZ]; int i; int line; write_dbx("status\n"); while (fgets(s, LINESIZ, dbxfp) == NULL); do { if (strcmp(s, dbxprompt) || strcmp(s, "")) { sscanf(s, BRACKET, &i); if (i > 0 && i <= nstops && stops[i].line > 0) stops[i].tag = 1; } } while (fgets(s, LINESIZ, dbxfp)); for (i=1; i<=nstops; i++) if (stops[i].line > 0) { if (stops[i].tag) stops[i].tag = 0; else { line = stops[i].line; stops[i].line = 0; stops[i].file = NULL; if (LineToStop_no(line) == 0) RemoveStop(line); } } } /* * This handler displays the function routine on the source window. * It locates the function by sending the dbx command "list ", * and loads the appropriate file accordingly. */ void func_handler() { int line; char command[LINESIZ]; if (Token.func && !Skip_func_handler) { #ifdef MIPS line = Token.line; #else sprintf(command, "list %s\n", Token.func); query_dbx(command); line = Token.line + 5; #endif LoadCurrentFile(); AdjustText(line); } Skip_func_handler = False; } /* File handler first queries the current file set by the user command, * and then loads the file. */ /* ARGSUSED */ void file_handler() /* Command was 'file' */ { if (Token.file) strcpy(CurrentFile, Token.file); else strcpy(CurrentFile, ""); } /* ARGSUSED */ void debug_handler() { query_dbx("use\n"); displayedFile = NULL; /* force reloading of source file */ if (LoadCurrentFile() == 0) { arrow.line = 0; /* clear arrow sign */ updown.line = 0; /* clear updown sign */ bomb.line = 0; /* clear bomb sign */ UpdateArrow(displayedFile); UpdateUpdown(displayedFile); UpdateBomb(displayedFile); ClearStops(); UpdateStops(displayedFile); UpdateMessageWindow("Ready for execution",NULL); query_dbx("func main\n"); #ifndef BSD query_dbx("display\n"); /* clear display window */ #endif } } /* ARGSUSED */ void cd_handler() { query_dbx("pwd\n"); } /* ARGSUSED */ void pwd_handler(s) char *s; { strcpy(cwd, (char *)strtok(s, "\n")); } /* ARGSUSED */ void use_handler(output) char *output; { if (strcmp(output, "") == 0) query_dbx("use\n"); else MakeDirList(output); } /* ARGSUSED */ void search_handler() { AdjustText(Token.line); } /* ARGSUSED */ void list_handler() { int line; if (Echo) { line = Token.line; LoadCurrentFile(); AdjustText(line); } } /* ARGSUSED */ /* Show output on the display window. * If output is null but the display window is managed, replace contents of * the display window with the null string. */ void display_handler() { Arg args[MAXARGS]; Cardinal n; if (!Token.display || strcmp(Token.display, "") == 0) { #ifndef NEW_INTERFACE if (!XtIsManaged(displayWindow)) return; else { #endif XtFree(Token.display); Token.display = XtNewString(""); #ifndef NEW_INTERFACE } #endif } #ifndef NEW_INTERFACE if (!XtIsManaged(displayWindow)) { XtManageChild(separator); XtManageChild(displayWindow); } #endif n = 0; XtSetArg(args[n], XtNstring, (XtArgVal) Token.display); n++; XtSetValues(displayWindow, args, n); XtFree(Token.display); } #endif /* NOT GDB */ xxgdb-1.12.orig/mips_regex.h100644 1012 1010 12502 5662460713 15003 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: November 24, 1989 * *****************************************************************************/ /* mips_regex.h: * * Regular expression pattern matching for dbx on DECStation. * * The reg_token array indicates the register no. for each token type. * reg_token[0] : message * reg_token[1] : stop number * reg_token[2] : function name * reg_token[3] : line number * reg_token[4] : file name * reg_token[5] : display command output */ #define TK_MESG 0 #define TK_STOP 1 #define TK_FUNC 2 #define TK_LINE 3 #define TK_FILE 4 #define TK_DISP 5 #define O_EXEC_GDB 0 #define O_DONE 1 #define O_STOPAT 2 #define O_STOPIN 3 #define O_UPDOWN 4 #define O_FUNC 4 #define O_BELL 5 #define O_LIST 6 #define O_FILE 7 #define O_SEARCH 8 #define O_PRINT 9 #define O_DEBUG 10 #define C_ANY -1 #define C_EXEC 0 #define C_STOPAT 1 #define C_STOPIN 2 #define C_UPDOWN 3 #define C_DELETE 4 #define C_FUNC 5 #define C_FILE 6 #define C_USE 7 #define C_LIST 8 #define C_SEARCH 9 #define C_PRINT 10 #define C_STATUS 11 static PatternRec output_pattern[] = { /* exec */ {"\\(.*\n\\)*\\(\\(\\(\\(\[[0-9]+\\] \\)?\\(stopped at \\)?\\)\\|Bus error \ \\|Segmentation fault \\|Interrupt \\)?\\[\\([^ ]+\\):\\([0-9]+\\).*\\]\\).*\n", NULL, {2, -1, 7, 8, -1, -1} }, /* done */ {"\\(.*\n\\)*Program terminated normally\n", NULL, {-1, -1, -1, -1, -1, -1} }, /* stop at */ {"\\[\\([0-9]+\\)\\] stop at \\(\"\\([^ ]+\\)\":\\)?\\([0-9]+\\)\n", NULL, {-1, 1, -1, 4, 3, -1} }, /* stop in */ {"\\(\\[.*\\]\n\\)*\\[\\([0-9]+\\)\\] stop in \\([^ ]+\\)\n", NULL, {-1, 2, 3, -1, -1, -1} }, /* up, down, func */ {"\\(.*\n\\)*\\([^ ]+\\):[ ]*\\([0-9]+\\).*\n", NULL, {2, -1, 2, 3, -1, -1} }, /* bell */ {"\n\\(not that many levels\\|program not active\\|program is not active\\|\ cannot read register unless program is active\\|cannot dump unless program is \ active\\)\n", NULL, {-1, -1, -1, -1, -1, -1} }, /* list */ {"[ ]*\\([0-9]+\\).*\n", NULL, {-1, -1, -1, 1, -1, -1} }, /* file */ {"\\([^ ]+\\)\n", NULL, {-1, -1, -1, -1, 1, -1} }, /* search */ {"[ ]*\\([0-9]+\\).*\n", NULL, {-1, -1, -1, 1, -1, -1} }, /* print */ {"\\(.+\n\\(.*\n\\)*\\)", NULL, { 1, -1, -1, -1, -1, -1} }, /* dbx init */ {"\\(.*\n\\)*.*\\(dbx version .*\nType 'help' for help.\nreading symbolic \ information ...\n\\)\\(\nwarning: .*\n\\)?\\([^ ]+\\):[ ]*\\([0-9]+\\).*\n", NULL, {-1, -1, 4, 5, -1, -1} }, NULL }; static PatternRec command_pattern[] = { {"[ ]*\\(run\\|r\\|cont\\|c\\|next\\|n\\|step\\|s\\|return\\)\\( \\|\n\\)", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(stop\\|st\\)[ ]+at[ ]+[0-9]+", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(stop\\|st\\)[ ]+in[ ]+[^ ]+", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(up\\|down\\)", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(delete\\|d\\)", NULL, {-1, -1, -1, 1, -1, -1}}, {"[ ]*func[ ]*\\([^ ]+\\)[ ]*", NULL, {-1, -1, 1, -1, -1, -1}}, {"[ ]*file[ ]*", NULL, {-1, -1, -1, -1, 1, -1}}, {"[ ]*use[ ]*", NULL, {-1, -1, -1, -1, 1, -1}}, {"[ ]*list[ ]*", NULL, {-1, -1, -1, -1, 1, -1}}, {"[ ]*\\(/\\|\?\\)", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(print\\|p\\)[ ]*[^ ]+", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*status[ ]*", NULL, {-1, -1, -1, -1, 1, -1}}, NULL }; xxgdb-1.12.orig/parser.c100644 1012 1010 31164 5662460451 14134 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* parser.c: * * Parse output messages from dbx using regular expression pattern matching, * and take appropriate action. * * compile(): Compile the regular expressions in a table. * match(): Try to best match a given string with the regular * expressions found in the table and return an index. * parser_init(): Initialization. * parse(): Parse the dbx output and invoke the appropriate action * handler. * filter(): Modify the dbx output before it gets displayed on the * dialog window. * query_dbx(): Send a query command to dbx and process it. */ #include #include "global.h" #include "regex.h" #ifdef GDB #include "gdb_regex.h" #else #ifdef BSD #ifdef MIPS #include "mips_regex.h" #else #include "bsd_regex.h" #endif #else #include "sun_regex.h" #endif #endif /* GDB */ #define BYTEWIDTH 8 #define RE_BUFFER 100 Tokens Token; /* gloabl token structure */ #ifndef GDB Boolean Parse = True; /* Parse flag for parse routine */ #endif /* * Compile all the regular expression patterns in a pattern table. * A pattern table is an array of pattern records. * Each pattern record consists of a regular * expression, a buffer for the to-be-compiled regular expression, * and an array to associate a given token with a matched register number. */ static void compile(patternTable) PatternRec *patternTable; { PatternRec *p; char fastmap[(1 << BYTEWIDTH)]; int i; for (i=0; patternTable[i].pat; i++) { p = &patternTable[i]; p->buf = (struct re_pattern_buffer *) XtMalloc (sizeof (struct re_pattern_buffer)); p->buf->allocated = RE_BUFFER; p->buf->buffer = (char *) XtMalloc (p->buf->allocated); p->buf->fastmap = fastmap; p->buf->translate = NULL; re_compile_pattern(p->pat, strlen(p->pat), p->buf); re_compile_fastmap(p->buf); } } /* * This routine tries to match a given string with each regular * expression in a given pattern table. The best match is found, and * the function returns an index to the pattern table. */ #ifndef GDB /* for GDB, match is called from gdb_parser.c */ static #endif int match(patternTable, string, type) PatternRec *patternTable; char *string; int type; { struct re_registers regs; int m, bestmatch = -1, index = -1, i, j, r, start, n; char *s; if (strcmp(string, "") == 0) return -1; for (i=0; patternTable[i].pat; i++) { if (type != C_ANY && type != i) continue; m = re_match(patternTable[i].buf, string, strlen(string), 0, ®s); if (m == -2 ) { /* match error - failure stack overflow */ #ifdef GDB fprintf(stderr, "xxgdb error: regular expression matching failed \ (failure stack overflow)\n"); #else fprintf(stderr, "xdbx error: regular expression matching failed \ (failure stack overflow)\n"); #endif return (-1); } if (m > bestmatch) { bestmatch = m; index = i; #ifdef GDB /* for GDB, free memory (if not done earlier) */ XtFree(Token.mesg); XtFree(Token.file); XtFree(Token.func); XtFree(Token.display); #endif /* GDB */ Token.mesg = Token.file = Token.func = Token.display = NULL; Token.line = Token.stop = 0; for (j=0; j= 0) { start = regs.start[r]; if ((n = regs.end[r] - start) > 0) { #ifdef GDB /* The following error could happen if the pattern table is not correct, better test it here.. */ if ( n > strlen(string)) /* Something is wrong here ! */ { fprintf(stderr,"Error match() : n = %d is too big\n",n); n = 0; } #endif /* GDB */ s = (char *) XtMalloc ((n+1) * sizeof(char)); strncpy(s, string+start, n); s[n] = '\0'; switch (j) { case TK_MESG: Token.mesg = s; break; case TK_STOP: Token.stop = atoi(s); XtFree(s); break; case TK_FUNC: Token.func = s; break; case TK_LINE: Token.line = atoi(s); XtFree(s); break; case TK_FILE: Token.file = s; break; case TK_DISP: Token.display = s; break; } } } } } } return index; } /* Compile the regular expressions in the output and command pattern tables. */ void parser_init() { compile(output_pattern); compile(command_pattern); compile(dataPattern); } #ifdef GDB #include "gdb_parser.c" #else /*>>>>>>>>>> ALL THE FOLLOWING IS NOT COMPILED FOR GDB <<<<<<<<<<<<<<<<<<<*/ /* This routine first parses the command string. * If the command is one of run, cont, next, step, stop at, stop in, * where, up, or down, it parses the dbx output to decide what action * to take and dispatch it to one of the handlers. * For other commands, the appropriate handler is called. * * !!! This routine has to be re-entrant. */ void parse(output, command) char *output; char *command; { int command_type; char *output_string; if (debug) { fprintf(stderr, "parse(output = %s, command = %s)\n", output, command); } /* Make a local copy of `output' and use that instead */ output_string = XtNewString(output); if (output) strcpy(output, ""); if (!command) { if (match(output_pattern, output_string, O_DEBUG) != -1) debug_handler(); debug_init(); return; } if (!Parse) return; command_type = match(command_pattern, command, C_ANY); switch (command_type) { case C_EXEC: if (match(output_pattern, output_string, O_EXEC_GDB) != -1) exec_handler(); else if (match(output_pattern, output_string, O_DONE) != -1) done_handler(); else bell(0); break; case C_STOPAT: if (match(output_pattern, output_string, O_STOPAT) != -1) stop_at_handler(); else bell(0); break; case C_STOPIN: if (match(output_pattern, output_string, O_STOPIN) != -1) stop_in_handler(); else bell(0); break; case C_UPDOWN: if (match(output_pattern, output_string, O_UPDOWN) != -1) updown_handler(); else bell(0); break; case C_SEARCH: if (match(output_pattern, output_string, O_SEARCH) != -1) search_handler(); else bell(0); break; case C_DELETE: delete_handler(); break; case C_FILE: if (match(output_pattern, output_string, O_FILE) != -1) file_handler(); /* command was 'file' */ else LoadCurrentFile(); /* command was 'file ...' */ break; case C_LIST: if (match(output_pattern, output_string, O_LIST) != -1) list_handler(); else bell(0); break; case C_FUNC: #ifdef MIPS if (match(output_pattern, output_string, O_FUNC) != -1) #else if (strcmp(output_string, "") == 0) #endif func_handler(); else bell(0); break; case C_USE: use_handler(output_string); break; #ifndef BSD case C_PRINT: if (match(output_pattern, output_string, O_PRINT) != -1) print_handler(output_string); else bell(0); break; case C_DEBUG: if (match(output_pattern, output_string, O_DEBUG) != -1) debug_handler(); else bell(0); break; case C_CD: if (strcmp(output_string, "") == 0) cd_handler(); else bell(0); break; case C_PWD: pwd_handler(output_string); break; case C_DISPLAY: if (strcmp(output_string, "") == 0 || match(output_pattern, output_string, O_PRINT) != -1) display_handler(); else bell(0); break; #endif #ifdef BSD case C_STATUS: break; #endif default: break; } XtFree(output_string); } /* This function edits the dbx output so that unnecessary information is * not displayed on the dialog window. * It filters away the some output returned by the execution commands; * output from the search commands, and the display command. * On Sun dbx, it also filters away part of the output returned by the * up and down commands. */ void filter(string, output, command) char *string, *output, *command; { struct re_registers regs; char *p; int r; static Boolean deleteRest = False; int command_type = -1; if (output == NULL || strcmp(output, "") == 0) return; #ifdef BSD if (!command) { AppendDialogText(string); return; } #endif if (command) command_type = match(command_pattern, command, C_ANY); if (command_type == C_EXEC) { if (re_match(output_pattern[O_EXEC_GDB].buf, string, strlen(string), 0, ®s) > 0) { r = output_pattern[O_EXEC_GDB].reg_token[TK_MESG]; for (p=string+regs.start[r]; p!=string && *(p-1) != '\n'; p--); strcpy(p, ""); if (!Prompt) deleteRest = True; } else if (deleteRest) { strcpy(string, ""); if (Prompt) deleteRest = False; } AppendDialogText(string); return; } if (Prompt) { char *s; s = XtNewString(output); switch (command_type) { #ifndef BSD case C_UPDOWN: if (match(output_pattern, s, O_UPDOWN) != -1) strcpy(s, Token.mesg); break; case C_DISPLAY: if (match(output_pattern, s, O_PRINT) != -1) strcpy(s, ""); break; #endif #ifdef MIPS case C_UPDOWN: if (match(output_pattern, s, O_UPDOWN) != -1) strcpy(s, Token.mesg); strcat(s, "\n"); break; case C_FUNC: if (match(output_pattern, s, O_FUNC) != -1) strcpy(s, ""); break; #endif case C_SEARCH: if (match(output_pattern, s, O_SEARCH) != -1) strcpy(s, ""); break; case C_LIST: if (match(output_pattern, s, O_LIST) != -1) strcpy(s, ""); break; default: s = XtNewString(string); /* append 'string' only */ break; } AppendDialogText(s); XtFree(s); } else { switch (command_type) { #ifndef BSD case C_UPDOWN: case C_DISPLAY: #endif #ifdef MIPS case C_UPDOWN: case C_FUNC: #endif case C_SEARCH: case C_LIST: break; default: AppendDialogText(string); break; } } } #endif /* NOT GDB */ xxgdb-1.12.orig/patchlevel.h100644 1012 1010 25 5472754344 14712 0ustar geyerAlgebra#define PATCHLEVEL 0 xxgdb-1.12.orig/regex.h100644 1012 1010 25120 5343270170 13743 0ustar geyerAlgebra/* Definitions for data structures callers pass the regex library. Copyright (C) 1985 Free Software Foundation, Inc. NO WARRANTY BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. GENERAL PUBLIC LICENSE TO COPY 1. You may copy and distribute verbatim copies of this source file as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy a valid copyright notice "Copyright (C) 1985 Free Software Foundation, Inc."; and include following the copyright notice a verbatim copy of the above disclaimer of warranty and of this License. You may charge a distribution fee for the physical act of transferring a copy. 2. You may modify your copy or copies of this source file or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains or is a derivative of this program or any part thereof, to be licensed at no charge to all third parties on terms identical to those contained in this License Agreement (except that you may choose to grant more extensive warranty protection to some or all third parties, at your option). c) You may charge a distribution fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another unrelated program with this program (or its derivative) on a volume of a storage or distribution medium does not bring the other program under the scope of these terms. 3. You may copy and distribute this program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal shipping charge) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs. 4. You may not copy, sublicense, distribute or transfer this program except as expressly provided under this License Agreement. Any attempt otherwise to copy, sublicense, distribute or transfer this program is void and your rights to use the program under this License agreement shall be automatically terminated. However, parties who have received computer software programs from you with this License Agreement will not have their licenses terminated so long as such parties remain in full compliance. 5. If you wish to incorporate parts of this program into other free programs whose distribution conditions are different, write to the Free Software Foundation at 675 Mass Ave, Cambridge, MA 02139. We have not yet worked out a simple rule that can be stated here, but we will often permit this. We will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software. In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! */ #ifndef RE_NREGS #define RE_NREGS 10 #endif /* This data structure is used to represent a compiled pattern. */ struct re_pattern_buffer { char *buffer; /* Space holding the compiled pattern commands. */ int allocated; /* Size of space that buffer points to */ int used; /* Length of portion of buffer actually occupied */ char *fastmap; /* Pointer to fastmap, if any, or zero if none. */ /* re_search uses the fastmap, if there is one, to skip quickly over totally implausible characters */ char *translate; /* Translate table to apply to all characters before comparing. Or zero for no translation. The translation is applied to a pattern when it is compiled and to data when it is matched. */ char fastmap_accurate; /* Set to zero when a new pattern is stored, set to one when the fastmap is updated from it. */ char can_be_null; /* Set to one by compiling fastmap if this pattern might match the null string. It does not necessarily match the null string in that case, but if this is zero, it cannot. 2 as value means can match null string but at end of range or before a character listed in the fastmap. */ }; /* Structure to store "register" contents data in. Pass the address of such a structure as an argument to re_match, etc., if you want this information back. start[i] and end[i] record the string matched by \( ... \) grouping i, for i from 1 to RE_NREGS - 1. start[0] and end[0] record the entire string matched. */ struct re_registers { int start[RE_NREGS]; int end[RE_NREGS]; }; /* These are the command codes that appear in compiled regular expressions, one per byte. Some command codes are followed by argument bytes. A command code can specify any interpretation whatever for its arguments. Zero-bytes may appear in the compiled regular expression. */ enum regexpcode { unused, exactn, /* followed by one byte giving n, and then by n literal bytes */ begline, /* fails unless at beginning of line */ endline, /* fails unless at end of line */ jump, /* followed by two bytes giving relative address to jump to */ on_failure_jump, /* followed by two bytes giving relative address of place to resume at in case of failure. */ finalize_jump, /* Throw away latest failure point and then jump to address. */ maybe_finalize_jump, /* Like jump but finalize if safe to do so. This is used to jump back to the beginning of a repeat. If the command that follows this jump is clearly incompatible with the one at the beginning of the repeat, such that we can be sure that there is no use backtracking out of repetitions already completed, then we finalize. */ dummy_failure_jump, /* jump, and push a dummy failure point. This failure point will be thrown away if an attempt is made to use it for a failure. A + construct makes this before the first repeat. */ anychar, /* matches any one character */ charset, /* matches any one char belonging to specified set. First following byte is # bitmap bytes. Then come bytes for a bit-map saying which chars are in. Bits in each byte are ordered low-bit-first. A character is in the set if its bit is 1. A character too large to have a bit in the map is automatically not in the set */ charset_not, /* similar but match any character that is NOT one of those specified */ start_memory, /* starts remembering the text that is matched and stores it in a memory register. followed by one byte containing the register number. Register numbers must be in the range 0 through NREGS. */ stop_memory, /* stops remembering the text that is matched and stores it in a memory register. followed by one byte containing the register number. Register numbers must be in the range 0 through NREGS. */ duplicate, /* match a duplicate of something remembered. Followed by one byte containing the index of the memory register. */ before_dot, /* Succeeds if before dot */ at_dot, /* Succeeds if at dot */ after_dot, /* Succeeds if after dot */ begbuf, /* Succeeds if at beginning of buffer */ endbuf, /* Succeeds if at end of buffer */ wordchar, /* Matches any word-constituent character */ notwordchar, /* Matches any char that is not a word-constituent */ wordbeg, /* Succeeds if at word beginning */ wordend, /* Succeeds if at word end */ wordbound, /* Succeeds if at a word boundary */ notwordbound, /* Succeeds if not at a word boundary */ syntaxspec, /* Matches any character whose syntax is specified. followed by a byte which contains a syntax code, Sword or such like */ notsyntaxspec /* Matches any character whose syntax differs from the specified. */ }; extern char *re_compile_pattern (); /* Is this really advertised? */ extern void re_compile_fastmap (); extern int re_search (), re_search_2 (); extern int re_match (), re_match_2 (); /* 4.2 bsd compatibility (yuck) */ extern char *re_comp (); extern int re_exec (); #ifdef SYNTAX_TABLE extern char *re_syntax_table; #endif xxgdb-1.12.orig/signals.c100644 1012 1010 11743 6224427401 14272 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * *****************************************************************************/ /* signals.c * * Signal handling for xdbx and dbx. * * kill_hanlder(): For SIGINT, SIGQUIT, SIGILL, SIGBUS, SIGTERM * print error message and exit with signal status. * quit_handler(): SIGCHLD, wait for dbx to die and exit gracefully. * stop_handler(): SIGTSTP, stop dbx process, then stop own process. * cont_handler(): SIGCONT, continue dbx process. * trap_signals(): Install signal handlers. */ /* * iand 94/02/10 eliminate signal handler prototype warnings on SVR4 and similar systems * iand 94/02/10 use reliable signals on SYSV * */ #include #include #ifdef _POSIX_SOURCE #include #endif #include #include "global.h" #if ( defined(SYSV) || defined(SVR4) ) && !defined(HPUX) && !defined(linux) #define signal sigset #endif /* Kill the dbx child process and then exits. */ /* ARGSUSED */ static void kill_handler(sig) int sig; { if (FalseSignal) { FalseSignal = FALSE; return; } kill(dbxpid, SIGKILL); switch (sig) { case SIGINT : fprintf(stderr, "Interrupt\n"); break; case SIGQUIT : fprintf(stderr, "Quit\n"); break; case SIGILL : fprintf(stderr, "Illegal instruction\n"); break; case SIGBUS : fprintf(stderr, "Bus error\n"); break; case SIGSEGV : fprintf(stderr, "Segmentation violation\n"); break; case SIGTERM : fprintf(stderr, "Soft kill\n"); break; } #ifdef CREATE_IO_WINDOW if (iowinpid) kill(iowinpid, SIGKILL); iowinpid = 0; sleep(10); #endif /* CREATE_IO_WINDOW */ if (debug) fprintf(stderr,"kill_handler signal %d\n", sig); exit(sig); } static void quit_handler(int sig) { int pid; #ifdef SYSV int status; #else union wait status; #endif /* SYSV */ /* wait for the child to report its status; if the child has died, * exit gracefully. */ #ifdef SYSV #if 1 /* instead of ifdef SVR4 */ pid = waitpid((pid_t)0, &status, WNOHANG|WUNTRACED); /* (MJH) */ #else pid = waitpid(&status, NULL , WNOHANG|WUNTRACED); #endif /* SVR4 */ #else pid = wait3(&status, WNOHANG|WUNTRACED, NULL); #endif /* SYSV */ #ifdef EDIT_BUTTON /* dont die if sub edit process dies */ if (pid == dbxpid && (WIFEXITED(status) || WIFSIGNALED(status)) && !WIFSTOPPED(status)) #else if ((WIFEXITED(status) || WIFSIGNALED(status)) && !WIFSTOPPED(status)) #endif /* EDIT_BUTTON */ { #ifdef CREATE_IO_WINDOW if (iowinpid) kill(iowinpid, SIGKILL); iowinpid = 0; #endif /* CREATE_IO_WINDOW */ if (debug) { fprintf(stderr,"quit_handler (child must have died ?)\n"); } exit(1); } } static void stop_handler(int sig) { if (dbxpid) kill(dbxpid, SIGSTOP); /* stop dbx process */ kill(0, SIGSTOP); /* stop own process */ } static void cont_handler(int sig) { if (dbxpid) { sleep(1); /* we need this */ kill(dbxpid, SIGCONT); /* continue dbx after stop */ } } /* * Trap signals to xdbx so that the child process can be handled properly. */ void trap_signals() { signal(SIGINT, kill_handler); signal(SIGQUIT, kill_handler); signal(SIGILL, kill_handler); signal(SIGBUS, kill_handler); signal(SIGSEGV, kill_handler); signal(SIGTERM, kill_handler); signal(SIGTSTP, stop_handler); /* stop signal from keyboard */ signal(SIGCONT, cont_handler); /* continue after stop */ signal(SIGCHLD, quit_handler); /* child status has changed */ } xxgdb-1.12.orig/signs.c100644 1012 1010 26464 5473006176 13772 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * *****************************************************************************/ /* signs.c * * This file contains all the routines for the creation and manipulation of * symbols used in xdbx. There are 3 different signs: * arrow - a solid right arrow to indicate the current execution point. * updown - an outlined right arrow to indicate position in stack trace. * stop - a stop hand symbol to indicate a breakpoint is set. * bomb - a bomb symbol to indicate the point of segmentation fault. * * To display a sign on a given line in the source window, it is first * created and mapped. To undisplay it, the sign is unmapped. It can * be mapped again when the sign is needed. Note that the sign is never * moved, so that there can be as many signs created (but not mapped) as * the number of lines in the source window. * For arrow and updown, there can be at most one of each mapped at a time. * For stop, there can be more than one mapped at the same time. */ #include "global.h" #include "bitmaps.h" #define MAXSTOPS 256 /* max number of stops */ #define MAXSIGNS 256 /* max number of signs */ #define OFFSET 2 /* offset for displaying signs */ typedef struct { Widget w; Boolean mapped; } ArrowSign; typedef struct { Widget w; Boolean mapped; } UpdownSign; typedef struct { Widget w; Boolean mapped; } StopSign; typedef struct { Widget w; Boolean mapped; } BombSign; static ArrowSign arrowsign[MAXSIGNS]; static UpdownSign updownsign[MAXSIGNS]; static StopSign stopsign[MAXSIGNS]; static BombSign bombsign[MAXSIGNS]; Arrow arrow; Updown updown; Stops stops[MAXSTOPS]; /* array of stops */ Bomb bomb; Cardinal nstops; /* number of stops */ /* Initialize data structures */ void signs_init() { int i; for (i=0; ilines; vertDistance = OFFSET + (i * height_per_line); screen = DefaultScreen(display); if (sign && !strcmp(sign, "arrow")) { bits = arrow_bits; width = arrow_width; height = arrow_height; horizDistance = 0; fg = app_resources.arrow_color; } else if (sign && !strcmp(sign, "updown")) { bits = updown_bits; width = updown_width; height = updown_height; horizDistance = 0; fg = app_resources.updown_color; } else if (sign && !strcmp(sign, "stop")) { bits = stop_bits; width = stop_width; height = stop_height; horizDistance = arrow_width; fg = app_resources.stop_color; } else if (sign && !strcmp(sign, "bomb")) { bits = bomb_bits; width = bomb_width; height = bomb_height; horizDistance = 0; fg = app_resources.bomb_color; } else { return NULL; } if( ctx->text.vbar != NULL ) { n = 0; XtSetArg(args[n], XtNwidth, &vbar_width); n++; XtSetArg(args[n], XtNborderWidth, &border_width); n++; XtGetValues(ctx->text.vbar, args, n); vbar_width += (border_width * 2); } n = 0; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNwidth, (XtArgVal) width); n++; XtSetArg(args[n], XtNheight, (XtArgVal) height); n++; XtSetArg(args[n], XtNresize, (XtArgVal) False); n++; XtSetArg(args[n], XtNmappedWhenManaged, (XtArgVal) False); n++; XtSetArg(args[n], XtNbitmap, XCreatePixmapFromBitmapData ( display, DefaultRootWindow(display), bits, width, height, fg, bg, DefaultDepth(display, screen))); n++; XtSetArg(args[n], XtNfromVert, (XtArgVal) NULL); n++; XtSetArg(args[n], XtNfromHoriz, (XtArgVal) NULL); n++; XtSetArg(args[n], XtNhorizDistance, (XtArgVal) horizDistance+vbar_width); n++; XtSetArg(args[n], XtNvertDistance, (XtArgVal) vertDistance); n++; XtSetArg(args[n], XtNtop, (XtArgVal) XawChainTop); n++; XtSetArg(args[n], XtNleft, (XtArgVal) XawChainLeft); n++; XtSetArg(args[n], XtNbottom, (XtArgVal) XawChainTop); n++; XtSetArg(args[n], XtNright, (XtArgVal) XawChainLeft); n++; return XtCreateManagedWidget(sign, labelWidgetClass, parent, args, n); } /* * Given a line number, displays a stop sign if that line is viewable. * If the stop widget for that line does not exist, create one and map it. * If the stop widget exists but not mapped, map it. */ void DisplayStop(file, line) FileRec *file; int line; { Cardinal i; if (line >= file->topline && line <= file->bottomline) { i = line - file->topline; if (stopsign[i].w == NULL) { /* widget does not exist */ stopsign[i].w = CreateSign(sourceForm, "stop", i); XtMapWidget(stopsign[i].w); stopsign[i].mapped = 1; } else if (!stopsign[i].mapped) { /* widget not mapped */ XtMapWidget(stopsign[i].w); stopsign[i].mapped = 1; } } } /* * Unmap all stop signs and then display only those stops that are viewable. */ void UpdateStops(file) FileRec *file; { Cardinal i; int line; if (file == NULL) return; for (i=0; ilines; i++) if (stopsign[i].w && stopsign[i].mapped) { XtUnmapWidget(stopsign[i].w); stopsign[i].mapped = 0; } for (i=1; i<=nstops; i++) if (stops[i].file && !strcmp(stops[i].file, file->pathname) && (line=stops[i].line) && line >= file->topline && line <= file->bottomline) { DisplayStop(file, line); } } /* * Given a line number, unmap the stop sign associated with that line. */ void RemoveStop(line) int line; { Cardinal i; if (displayedFile && line >= displayedFile->topline && line <= displayedFile->bottomline) { i = line - displayedFile->topline; if (stopsign[i].w && stopsign[i].mapped) { XtUnmapWidget(stopsign[i].w); stopsign[i].mapped = 0; } } } void ClearStops() { int i; for (i=1; i<=nstops; i++) { stops[i].file = NULL; stops[i].line = 0; } } /* Unmap the current arrow sign. * Display a new arrow sign if it is viewable. */ void UpdateArrow(file) FileRec *file; { Cardinal i; int line; if (file == NULL) return; i = arrow.i; if (i>=0 && ilines) if (arrowsign[i].w && arrowsign[i].mapped) { XtUnmapWidget(arrowsign[i].w); arrowsign[i].mapped = 0; } line = arrow.line; if (arrow.file && !strcmp(arrow.file, file->pathname) && line >= file->topline && line <= file->bottomline) { i = line - file->topline; arrow.i = i; if (arrowsign[i].w == NULL) { arrowsign[i].w = CreateSign(sourceForm, "arrow", i); XtMapWidget(arrowsign[i].w); arrowsign[i].mapped = TRUE; } else if (!arrowsign[i].mapped) { XtMapWidget(arrowsign[i].w); arrowsign[i].mapped = TRUE; } } } /* If the new updown is on the same line as the arrow, remove the updown. * Unmap current updown sign. * Display the updown if it is viewable. */ void UpdateUpdown(file) FileRec *file; { Cardinal i; int line; if (file == NULL) return; /* (PW)9JULY91 : add test line else it prevents up/down when a function calls itself */ if (updown.file && !strcmp(updown.file, arrow.file) && !strcmp(updown.func, arrow.func) && (updown.line == arrow.line)) { updown.line = 0; strcpy(updown.file, ""); } i = updown.i; if (i>=0 && ilines) if (updownsign[i].w && updownsign[i].mapped) { XtUnmapWidget(updownsign[i].w); updownsign[i].mapped = 0; } line = updown.line; if (updown.file && !strcmp(updown.file, file->pathname) && line >= file->topline && line <= file->bottomline) { i = line - file->topline; updown.i = i; if (updownsign[i].w == NULL) { updownsign[i].w = CreateSign(sourceForm, "updown", i); XtMapWidget(updownsign[i].w); updownsign[i].mapped = TRUE; } else if (!updownsign[i].mapped) { XtMapWidget(updownsign[i].w); updownsign[i].mapped = TRUE; } } } /* Unmap the current bomb sign, if any. * Display a new bomb sign. */ void UpdateBomb(file) FileRec *file; { Cardinal i; int line; if (file == NULL) return; i = bomb.i; if (i>=0 && ilines) if (bombsign[i].w && bombsign[i].mapped) { XtUnmapWidget(bombsign[i].w); bombsign[i].mapped = 0; } line = bomb.line; if (bomb.file && !strcmp(bomb.file, file->pathname) && line >= file->topline && line <= file->bottomline) { i = line - file->topline; bomb.i = i; if (bombsign[i].w == NULL) { bombsign[i].w = CreateSign(sourceForm, "bomb", i); XtMapWidget(bombsign[i].w); bombsign[i].mapped = TRUE; } else if (!bombsign[i].mapped) { XtMapWidget(bombsign[i].w); bombsign[i].mapped = TRUE; } } } xxgdb-1.12.orig/source.c100644 1012 1010 103165 5745755102 14163 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* source.c * * Create the source window and handle display of file. * * source_init(): Initialization routine. * Update(): Action proc to update source window on scrollbar action. * NotifyResize(): Action proc to update source window on resize. * CreateSourceWindow(): Create the source window. * BuildLinePos(): Build an array of starting text position of each line. * LookUpFileTable():Check out source file info from a file table. * SaveDisplayedFileInfo(): records displayed file info into file table. * DisplayFile(): Display a file on the source window * StartEditor(): Start a child process editor on the displayed file. * LoadFile(): Search for a file and open it for display. */ #ifndef NeXT #include #endif #include #include #include #include #include "global.h" #ifdef SYSV #ifdef sco # include #endif #endif /* SYSV */ #ifdef GDB #include #endif #define MAXDIRS 256 /* max number of dirs in dirList */ char CurrentFile[MAXNAME]; /* current contents of file variable */ Widget sourceForm, /* parent of sourceWindow */ sourceWindow; /* text window for source file */ FileRec *displayedFile; /* pointer to table entry of currently displayed file */ static FileRec **fileTable; /* table of file records */ static int fileTableSize; /* size of file table */ static char *dirList[MAXDIRS]; /* list of dirs for searching files */ void source_init() { dirList[0] = NULL; } /* * Update topline, bottomline, arrow sign, updown sign, stop signs, and * line label. */ /* ARGSUSED */ void Update(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { XawTextPosition pos; int topline; FileRec *file; if (displayedFile) { file = displayedFile; pos = XawTextTopPosition(sourceWindow); file->topPosition = pos; topline = TextPositionToLine(pos); /* Update the symbols only if the text scrolls */ if (file->topline != topline) { file->topline = topline; file->bottomline = MIN (file->topline + file->lines - 1, file->lastline); /* 03/26/91 mod 7 GWC Fixed a bug where the special margin symbols (arrows, stop signs, etc.) did not scroll when one moved the text with keyboard commands such as Ctrln. To do this the Update action procedure should be called after text widget actions such as next-line. Unfortunately Update needed to be enhanced a bit not to always warp the cursor to the top of the window. You can now call Update with a parameter "warp" to warp the cursor to the top of the screen; the default is not to warp. */ if (*num_params == 1 && strcmp(params[0], "warp") == 0) { XawTextSetInsertionPoint(sourceWindow, file->linepos[file->topline]); } UpdateLineLabel(file->topline); UpdateStops(file); UpdateArrow(file); UpdateUpdown(file); UpdateBomb(file); } else {/* Update caret position only */ pos = XawTextGetInsertionPoint(sourceWindow); UpdateLineLabel(TextPositionToLine(pos)); } } } /* * Update bottomline, arrow sign, updown sign and stop signs on resize. * Invoked by ConfigureNotify event. */ /* ARGSUSED */ static void NotifyResize(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { XawTextPosition pos; TextWidget ctx = (TextWidget) sourceWindow; FileRec *file; if ((file = displayedFile)) { file->lines = ctx->text.lt.lines; pos = XawTextTopPosition(sourceWindow); file->topline = TextPositionToLine(pos); file->bottomline = MIN (file->topline + file->lines - 1, file->lastline); UpdateStops(file); UpdateArrow(file); UpdateUpdown(file); UpdateBomb(file); } } /* Update the position of the caret */ /* ARGSUSED */ #ifdef notdef void UpdateLine(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { XawTextPosition pos; int line; pos = XawTextGetInsertionPoint(w); line = TextPositionToLine(pos); UpdateLineLabel(line); } #endif /* My select-start routine that cancels the effect of automatic scrolling * near the bottom of an Athena text widget window. */ /* ARGSUSED */ void SelectStart(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { XawTextPosition topPosition; /* remember the top display position before automatic scrolling */ /* displayedFile->topPosition = XawTextTopPosition(w); */ topPosition = XawTextTopPosition(w); XtCallActionProc(w, "select-start", event, params, *num_params); /* reset to remembered position if top position changed */ /* if (XawTextTopPosition(w) != displayedFile->topPosition) TextSetTopPosition(w, displayedFile->topPosition); */ if (XawTextTopPosition(w) != topPosition) TextSetTopPosition(w, topPosition); } /* My select-end routine to store the text selection into both the PRIMARY * selection and cut buffer 0. */ /* ARGSUSED */ void SelectEnd(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { XawTextPosition begin, end, start; Widget textsrc; XawTextBlock buffer; char s_storage[LINESIZ]; /* fix bug where if selection is past 10k, xxgdb crashes */ char* s = &s_storage[0]; int nchars; XawTextGetSelectionPos(w, &begin, &end); XawTextSetSelection(w, begin, end); if (begin == end) return; if (end - begin > LINESIZ) s = (char*)malloc(end - begin + LINESIZ); textsrc = XawTextGetSource(w); strcpy(s, ""); for (start=begin, nchars=end-begin; nchars > 0; start=begin+buffer.length, nchars-=buffer.length) { XawTextSourceRead(textsrc, start, &buffer, nchars); strncat(s, buffer.ptr, buffer.length); } XStoreBytes(display, s, strlen(s)); if (end - begin > LINESIZ) free(s); } /* This is my own select word routine to replace the standard action * procedure provided by the Text widget. * It selects a word delimited by DELIMITERS, not whitespace. */ /* ARGSUSED */ void SelectWord(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { XawTextPosition pos, left, right, start; XawTextBlock buffer; Widget textsrc; char s[LINESIZ]; char *p, *ls, *rs; int nchars; pos = XawTextGetInsertionPoint(w); textsrc = XawTextGetSource(w); XawTextSourceRead(textsrc, pos, &buffer, 1); if (buffer.length == 0 || (buffer.length == 1 && strchr(app_resources.delimiters, (int)*(buffer.ptr)) != NULL)) { XStoreBytes(display, NULL, 0); return; } left = XawTextSourceScan(textsrc, pos+1, XawstWhiteSpace, XawsdLeft, 1, FALSE); right = XawTextSourceScan(textsrc, left, XawstWhiteSpace, XawsdRight, 1, FALSE); strcpy(s, ""); for (start=left, nchars=right-left; nchars > 0; start=left+buffer.length, nchars-=buffer.length) { XawTextSourceRead(textsrc, start, &buffer, nchars); strncat(s, buffer.ptr, buffer.length); } if (!strcmp(s, "")) return; p = s+pos-left; ls = (char *) strtok(s, app_resources.delimiters); rs = (char *) strtok(NULL, app_resources.delimiters); if (!ls) return; while (rs<=p && rs!=NULL) { ls = rs; rs = (char *) strtok(NULL, app_resources.delimiters); } left = left + ls - s; right = left + strlen(ls) - 1; XawTextUnsetSelection(w); XStoreBytes(display, ls, strlen(ls)); XawTextSetSelection(w, left, right+1); } /* Print the value of the expression in cut buffer 0. */ /* ARGSUSED */ void PrintSelection(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { char command[LINESIZ]; char *string; int nbytes; string = XFetchBytes(display, &nbytes); if (nbytes == 0) { UpdateMessageWindow(PRINT_HELP, NULL); bell(0); return; } sprintf(command, "print %s\n", string); send_command(command); AppendDialogText(command); } #ifdef EDIT_BUTTON /* allow invocation of favorite editor from within interface */ extern void StartEditor(); void EdAction(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { StartEditor(); } #endif /* EDIT_BUTTON */ /* fixes keybindings in source window */ extern PopupSearch(); void Search(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { PopupSearch(w, NULL, NULL); } /* * On top of a form widget, we have a text widget with scrollbar, label * widgets for the stop sign, arrow sign, and updown signs. */ /* add popupsearch which is triggered by ^S in file window also add -editor switch which can be set to vi or emacs (default is emacs) and have operative keys in the editor window for moving around (move stop signs and such around too) */ void CreateSourceWindow(parent) Widget parent; { TextWidget ctx; Arg args[MAXARGS]; Cardinal n; static XtActionsRec sbar_actions[] = { {"NotifyResize", NotifyResize}, {"Update", Update}, {NULL, NULL} }; /* fixes keybindings in source window */ static XtActionsRec text_actions[] = { {"Update", Update}, #ifdef EDIT_BUTTON {"Editor", EdAction}, #endif {"Search", Search}, {NULL, NULL} }; #ifdef EDIT_BUTTON static String eTextTranslations = "#override \n\ CtrlV: next-page() Update(warp) \n\ MetaV: previous-page() Update(warp) \n\ CtrlN: next-line() Update() \n\ CtrlP: previous-line() Update() \n\ CtrlZ: scroll-one-line-up() Update(warp) \n\ MetaZ: scroll-one-line-down() Update(warp) \n\ Meta]: forward-paragraph() Update(warp) \n\ Meta[: backward-paragraph() Update(warp) \n\ MetaF: forward-word() Update() \n\ MetaB: backward-word() Update() \n\ CtrlF: forward-character() Update() \n\ CtrlB: backward-character() Update() \n\ MetaE: Editor() \n\ Meta<: beginning-of-file() Update(warp) \n\ Meta>: end-of-file() Update(warp) \n\ L: redraw-display() Update() \n\ S: Search() Update() \n\ R: Search() Update() \n\ : SelectStart() SelectWord() \n\ Shift: Update() SelectEnd() PrintSelection() \n\ : Update() SelectEnd() \n\ "; static String vTextTranslations = "#override \n\ CtrlF: next-page() Update(warp) \n\ CtrlB: previous-page() Update(warp) \n\ CtrlD: next-page() Update() \n\ CtrlU: previous-page() Update() \n\ Return: next-line() Update() \n\ -: previous-line() Update() \n\ j: next-line() Update() \n\ k: previous-line() Update() \n\ space: forward-character() Update() \n\ BackSpace: backward-character() Update() \n\ 1: beginning-of-file() Update(warp) \n\ G: end-of-file() Update(warp) \n\ E: Editor() \n\ L: redraw-display() Update() \n\ /: Search() Update() \n\ ?: Search() Update() \n\ : SelectStart() SelectWord() \n\ Shift: Update() SelectEnd() PrintSelection() \n\ : Update() SelectEnd() \n\ "; #else /* not EDIT_BUTTON */ static String eTextTranslations = "#override \n\ CtrlV: next-page() Update(warp) \n\ MetaV: previous-page() Update(warp) \n\ CtrlN: next-line() Update() \n\ CtrlP: previous-line() Update() \n\ CtrlZ: scroll-one-line-up() Update(warp) \n\ MetaZ: scroll-one-line-down() Update(warp) \n\ Meta]: forward-paragraph() Update(warp) \n\ Meta[: backward-paragraph() Update(warp) \n\ MetaF: forward-word() Update() \n\ MetaB: backward-word() Update() \n\ CtrlF: forward-character() Update() \n\ CtrlB: backward-character() Update() \n\ Meta<: beginning-of-file() Update(warp) \n\ Meta>: end-of-file() Update(warp) \n\ L: redraw-display() Update() \n\ S: Search() Update() \n\ R: Search() Update() \n\ : SelectStart() SelectWord() \n\ Shift: Update() SelectEnd() PrintSelection() \n\ : Update() SelectEnd() \n\ "; static String vTextTranslations = "#override \n\ CtrlF: next-page() Update(warp) \n\ CtrlB: previous-page() Update(warp) \n\ CtrlD: next-page() Update() \n\ CtrlU: previous-page() Update() \n\ Return: next-line() Update() \n\ -: previous-line() Update() \n\ j: next-line() Update() \n\ k: previous-line() Update() \n\ space: forward-character() Update() \n\ BackSpace: backward-character() Update() \n\ 1: beginning-of-file() Update(warp) \n\ G: end-of-file() Update(warp) \n\ L: redraw-display() Update() \n\ /: Search() Update() \n\ ?: Search() Update() \n\ : SelectStart() SelectWord() \n\ Shift: Update() SelectEnd() PrintSelection() \n\ : Update() SelectEnd() \n\ "; #endif /* EDIT_BUTTON */ /* fixes keybindings in source window */ static String sbarTranslations = "\ : NotifyResize() \n\ : StartScroll(Continuous) MoveThumb() NotifyThumb() \ Update() \n\ : MoveThumb() NotifyThumb() Update() \n\ : NotifyScroll(Proportional) EndScroll() Update() \n\ "; n = 0; XtSetArg(args[n], XtNdefaultDistance, 0); n++; sourceForm = XtCreateManagedWidget("sourceForm", formWidgetClass, parent, args, n); n = 0; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetArg(args[n], XtNtype, (XtArgVal)XawAsciiFile); n++; XtSetArg(args[n], XtNstring, (XtArgVal)"/dev/null"); n++; XtSetArg(args[n], XtNscrollVertical, (XtArgVal) XawtextScrollAlways);n++; sourceWindow = XtCreateManagedWidget("sourceWindow", asciiTextWidgetClass, sourceForm, args, n); ctx = (TextWidget) sourceWindow; if (ctx->text.vbar) XtOverrideTranslations(ctx->text.vbar, XtParseTranslationTable(sbarTranslations)); XtAppAddActions(app_context, sbar_actions, XtNumber(sbar_actions)); /* fixes keybindings in source window */ XtAppAddActions(app_context, text_actions, XtNumber(text_actions)); if (app_resources.bindings && strcmp(app_resources.bindings, "vi") == 0) XtOverrideTranslations((Widget) ctx, XtParseTranslationTable(vTextTranslations)); else XtOverrideTranslations((Widget) ctx, XtParseTranslationTable(eTextTranslations)); /* setup tabulation */ if (app_resources.tabstop >= 0) { int tab, tabs[256]; for (n = 0, tab = 0; n < sizeof tabs / sizeof *tabs; n++) tabs[n] = (tab += app_resources.tabstop); XawTextSinkSetTabs(ctx->text.sink, sizeof tabs / sizeof *tabs, tabs); } } /* * Build the array which gives the starting text position of each line. * > Estimate the number of lines in the file and allocate memory buffer. * > Starting position of line #1 is 0, and is stored in linepos[1]. * > Search for '\n' till end of buffer. */ static void BuildLinePos(file) FileRec *file; { char *p; int line, nlines; nlines = MAX(1, file->filesize/CHARS_PER_LINE); file->linepos = (XawTextPosition *) XtMalloc ((nlines+2) * sizeof(XawTextPosition)); p = file->buf; line = 0; file->linepos[line++] = 0; file->linepos[line++] = 0; while (*p) { if (*p++ == '\n') { if (line == nlines) { /* buffer full, need more memory */ file->linepos = (XawTextPosition *) XtRealloc ((void*)file->linepos, (nlines + ADD_LINES) * sizeof(XawTextPosition)); nlines += ADD_LINES; } file->linepos[line++] = p - file->buf; } } file->lastline = line - 2; file->linepos = (XawTextPosition *) XtRealloc /* shrink to min size */ ((void*)file->linepos, line * sizeof(XawTextPosition)); } /* * Function to check the file table. * This might be useful after a 'dir' or 'cd' command when * there might be another path to the same files. */ static void CheckLookUpFileTable() { int i; char * newfullname; for (i=0; fileTable && ifilename); if (newfullname != NULL) { /* if the two files are different, then it means there is a new full path for this file. So we better forget everything about the old file. */ if (strcmp (newfullname, fileTable[i]->pathname)) { /* if filenames are different */ if (debug) fprintf (stderr, "Clearing file table entry \"%s\" : was \"%s\" : is \"%s\"\n", fileTable[i]->filename, fileTable[i]->pathname, newfullname); AppendDialogText("Warning : new path to \""); AppendDialogText(fileTable[i]->filename); AppendDialogText("\" is \""); AppendDialogText(newfullname); AppendDialogText("\".\n"); if (displayedFile == fileTable[i]) { displayedFile = NULL; } XtFree((char *)fileTable[i]->buf); XtFree((char *)fileTable[i]->linepos); XtFree((char *)fileTable[i]); fileTable[i] = NULL; } XtFree (newfullname); } } } } /* * Function to clean up the file table and update the * display if necessary. * */ void CleanUpFileTable () { CheckLookUpFileTable(); if (displayedFile == NULL) LoadCurrentFile(); } /* * Look up the file table for an entry with "filename" * If not found, create an entry and initialize proper fields, * else, return pointer to entry found. */ static int LookUpFileTable(pathname, filename, file) char *pathname, *filename; FileRec **file; { struct stat fileinfo; int fd; int i, j, n; int available; available = -1; for (i=0; fileTable && ipathname, pathname) == 0) /* file found */ { if (stat(pathname, &fileinfo) == -1) { UpdateMessageWindow("Error: cannot stat file %s", pathname); *file = fileTable[i]; return 0; } if (fileinfo.st_mtime > fileTable[i]->mtime) /* file modified */ { XtFree((char *)fileTable[i]->buf); XtFree((char *)fileTable[i]->linepos); XtFree((char *)fileTable[i]); fileTable[i] = NULL; UpdateMessageWindow("WARNING : file %s was modified", pathname); } if (displayedFile && /* same as displayed file */ strcmp(pathname, displayedFile->pathname) == 0) { if (fileTable[i] == NULL) /* means file was modified */ displayedFile = NULL; else { *file = NULL; return 0; } } else { *file = fileTable[i]; return 0; } } } } /* Record file into file table */ if (available == -1) { /* file table full, enlarge it */ available = fileTableSize; fileTableSize += ADD_SIZE; fileTable = (FileRec **) XtRealloc ((void*)fileTable, fileTableSize * sizeof(FileRec *)); for (j=available; jfilesize = fileinfo.st_size + 1; fileTable[i]->mtime = fileinfo.st_mtime; fileTable[i]->buf = XtMalloc((int)fileTable[i]->filesize); if ((n = read(fd, fileTable[i]->buf, (int) fileTable[i]->filesize)) == -1) { UpdateMessageWindow("Error: cannot read file %s", pathname); XtFree(fileTable[i]->buf); XtFree((void*)fileTable[i]); fileTable[i] = NULL; close(fd); return -1; } fileTable[i]->buf[n] = '\0'; fileTable[i]->pathname = XtNewString(pathname); fileTable[i]->filename = XtNewString(filename); fileTable[i]->currentline = 1; fileTable[i]->topline = 1; fileTable[i]->bottomline = 0; fileTable[i]->topPosition = 0; BuildLinePos(fileTable[i]); close(fd); *file = fileTable[i]; return 0; } /* * Remember file position and current line before closing. */ static void SaveDisplayedFileInfo() { XawTextPosition pos; if (displayedFile) { displayedFile->topPosition = XawTextTopPosition(sourceWindow); pos = XawTextGetInsertionPoint(sourceWindow); displayedFile->currentline = TextPositionToLine(pos); } } /* DisplayFile() displays the file onto the source window. It * uses topPosition to remember where it was last opened. But it * must recalculate bottomline because the window size might be * different. */ static void DisplayFile(file) FileRec *file; { Arg args[MAXARGS]; Cardinal n; TextWidget ctx = (TextWidget) sourceWindow; n = 0; XtSetArg(args[n], XtNdisplayPosition, (XtArgVal)file->topPosition); n++; XtSetArg(args[n], XtNstring, (XtArgVal) file->pathname); n++; XtSetArg(args[n], XtNeditType, (XtArgVal) XawtextRead); n++; XtSetValues(sourceWindow, args, n); file->lines = ctx->text.lt.lines; file->bottomline = MIN (file->topline + file->lines - 1, file->lastline); } /* Given a filename starting with a tilde (`~'), it expands ~[user] to * the home directory of that user, or to the login home directory if user * is not specified. */ static char *expand(filename) char *filename; { struct passwd *pwd; char *string, *name, newfile[MAXNAME]; string = XtNewString(filename+1); if (*string == '\0' || *string == '/') name = (char *) getlogin(); else name = (char *) strtok(string, "/"); if (name == NULL) return filename; pwd = (struct passwd *) getpwnam(name); if (pwd && pwd->pw_dir) { sprintf(newfile, "%s%s", pwd->pw_dir, filename+strlen(name)+1); return XtNewString(newfile); } else return filename; } /* Create a list of directories for searching source files. * It reads the list of directories specified by the user, adding * the current directory into the list if it is not already there. * * With fix from Dave Gagne (daveg@fs1.ee.ubc.ca) 7/30/90 */ void MakeDirList(output) char *output; { /* fix bug where if text of a directories command is > 1k, crashes. Now works to 4k */ char *s, list[LINESIZ], command[LINESIZ]; int i, use_cwd; for (i=0; dirList[i]; i++) /* remove old list */ XtFree(dirList[i]); i = 0; use_cwd = TRUE; if (output) { /* create list */ #ifdef GDB /* GDB uses ':' as separator character */ s = (char *) strtok(output, ": \n"); #else s = (char *) strtok(output, " \n"); #endif /* GDB */ while (s) { dirList[i] = XtNewString(s); if (dirList[i][0] == '~') /* expand '~' */ dirList[i] = expand(dirList[i]); if (LASTCH(dirList[i]) == '/') /* remove last '/' */ LASTCH(dirList[i]) = '\0'; if (strcmp(dirList[i], ".") == 0) /* watch for "." */ use_cwd = FALSE; ++i; #ifdef GDB /* GDB uses ':' as separator character */ s = (char *) strtok(NULL, ": \n"); #else s = (char *) strtok(NULL, " \n"); #endif /* GDB */ } dirList[i] = NULL; } if (use_cwd) { /* include current dir */ dirList[i++] = XtNewString("."); dirList[i] = NULL; } #if defined(NeXT) && defined(GDB) /* for NeXT computer, send 'directory' command for each directory */ 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 */ strcpy(list, ""); /* tell dbx our new list */ for (i=0; dirList[i]; i++) { strcat(list, dirList[i]); strcat(list, " "); } #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 */ } /* Returns the full pathname of a given file. * It searches for the file from a list of directories. */ char *GetPathname(filename) char *filename; { char pathname[LINESIZ]; int i; if (filename == NULL || strcmp(filename, "") == 0) return NULL; for (i=0; dirList[i]; i++) { if (*filename == '/' && access(filename, R_OK) == -1) { /* this handles the exceptional case of sun4 dbx output */ strcpy(filename, &filename[1]); } if (*filename == '/' || *filename == '~') strcpy(pathname, filename); else if (strcmp(dirList[i], ".") == 0) sprintf(pathname, "%s/%s", cwd, filename); #ifdef GDB /* (PW)(SH)11SEP91 : for gdb 4.0 */ else if (strcmp(dirList[i], "$cwd") == 0) sprintf(pathname, "%s/%s", cwd, filename); else if (strcmp(dirList[i], "$cdir") == 0) sprintf(pathname, "%s/%s", cdir, filename); #endif /* GDB */ else if (*dirList[i] == '/' || *dirList[i] == '~') sprintf(pathname, "%s/%s", dirList[i], filename); else sprintf(pathname, "%s/%s/%s", cwd, dirList[i], filename); #ifdef GDB simplify_path (pathname); /* be sure to get only significant path */ #endif if (access(pathname, R_OK) == 0) { if (debug) fprintf(stderr,"Full path of %s is \"%s\"\n", filename, pathname); return XtNewString(pathname); } if (*filename == '/' || *filename == '~') { break; /* no need to loop over all directories */ } } UpdateMessageWindow("File not found: %s", filename); bell(0); return NULL; } /* * Given a file name, LoadFile attempts to open it and displays it onto * the source window: * 1. get the full pathname of the file * 2. LookUpFileTable() returns a pointer to the file's entry if it's * already in the table; else, creates an entry and return a pointer. * 3. save the current displayedFile info * 4. display the file * 5. update the file label and the various signs on the source window. * LoadFile returns 0 upon successful completion, -1 otherwise. */ int LoadFile(filename) char *filename; { FileRec *file; char *pathname; pathname = GetPathname(filename); if (pathname == NULL) { return -1; } if (LookUpFileTable(pathname, filename, &file) != -1) { if (file) { /* load new file */ SaveDisplayedFileInfo(); DisplayFile(file); UpdateFileLabel(pathname); XawTextUnsetSelection(sourceWindow); XawTextSetInsertionPoint(sourceWindow, file->linepos[file->currentline]); UpdateLineLabel(file->currentline); UpdateStops(file); UpdateArrow(file); UpdateUpdown(file); UpdateBomb(file); displayedFile = file; } return 0; } else { /* LookUpFileTable() fails */ return -1; } } int LoadCurrentFile() { #ifdef GDB query_gdb ("info line\n", PARSE_ON | ECHO_OFF | FILTER_OFF); #else query_dbx("file\n"); #endif /* GDB */ return LoadFile(CurrentFile); } #ifdef EDIT_BUTTON /* simply add editor button that calls $XXGDBWINEDIT, $WINEDIT, xxgdbedit in that order */ /* allow invocation of fav. editor from within interface */ /* button and the EdAction action procedure for the source window */ void StartEditor () { XawTextPosition pos; char* editor; char string[128]; int result; if (displayedFile == NULL) return; editor = (char *) getenv("XXGDBWINEDIT"); if (editor == NULL) editor = (char *) getenv("WINEDIT"); if (editor == NULL) editor = "xxgdbedit"; pos = XawTextGetInsertionPoint(sourceWindow); displayedFile->currentline = TextPositionToLine(pos); sprintf(string, "nohup %s +%d %s&\n", editor, displayedFile->currentline, displayedFile->pathname); result = system(string); printf("result from system call: %d \n", result); /* the following is more efficient but needs some work { int pid; if (!(pid = fork())) { execlp(editor, editor, linenum, displayedFile->pathname, (char *) 0); printf("editor command fails\n"); } else { if (pid == -1) printf("unable to start editor\n"); } } */ } #endif /* EDIT_BUTTON */ #ifdef GDB /* * Function to get the full path of a source file. * * This function is implemented by doing a 'list sourcefile;1' * and then a 'info source'. That is the only way I found to * get this fullpath. If there is a better way, change here. * * Note that we have to save and restore the current source * file in case it is not the same as 'filename'. * */ char * GetSourcePathname (filename) char *filename; { char *srcpath; char curr_src [MAXPATHLEN]; char list_src_cmd [MAXPATHLEN+10]; /* +10 for room for "list :1\n" */ if (filename == NULL || strcmp(filename, "") == 0) return NULL; /* (PW)19NOV93: it is important to get new string because, "info source" below will free Token.file (which could be same as filename here. */ filename = XtNewString (filename); /* get current source */ query_gdb("info source\n", PARSE_ON | ECHO_OFF | FILTER_OFF); strcpy (curr_src, source_path); if (*curr_src == 0) { srcpath = GetPathname (filename); /* when info source is not supported */ } else { /* tell gdb to go to filename */ sprintf (list_src_cmd,"list %s:1\n", filename); query_gdb(list_src_cmd, PARSE_OFF | ECHO_OFF | FILTER_OFF); /* get source of filename */ query_gdb("info source\n", PARSE_ON | ECHO_OFF | FILTER_OFF); if (*source_fullpath) srcpath = XtNewString (source_fullpath); else srcpath = NULL; /* reset original source */ sprintf (list_src_cmd,"list %s:1\n", curr_src); query_gdb(list_src_cmd, PARSE_OFF | ECHO_OFF | FILTER_OFF); if (srcpath == NULL) srcpath = GetPathname (filename); /* when info source is not supported */ } XtFree (filename); return srcpath; } #endif /* GDB */ xxgdb-1.12.orig/sun_regex.h100644 1012 1010 12706 5662460740 14646 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * *****************************************************************************/ /* sun_regex.h: * * Regular expression pattern matching for Sun dbx. * * The reg_token array indicates the register no. for each token type. * reg_token[0] : message * reg_token[1] : stop number * reg_token[2] : function name * reg_token[3] : line number * reg_token[4] : file name * reg_token[5] : display command output */ #define TK_MESG 0 #define TK_STOP 1 #define TK_FUNC 2 #define TK_LINE 3 #define TK_FILE 4 #define TK_DISP 5 #define O_EXEC_GDB 0 #define O_DONE 1 #define O_STOPAT 2 #define O_STOPIN 3 #define O_UPDOWN 4 #define O_BELL 5 #define O_LIST 6 #define O_SEARCH 6 #define O_FILE 7 #define O_PRINT 8 #define O_DEBUG 9 #define C_ANY -1 #define C_EXEC 0 #define C_STOPAT 1 #define C_STOPIN 2 #define C_UPDOWN 3 #define C_DELETE 4 #define C_FUNC 5 #define C_FILE 6 #define C_DEBUG 7 #define C_CD 8 #define C_USE 9 #define C_PWD 10 #define C_LIST 11 #define C_SEARCH 12 #define C_DISPLAY 13 #define C_PRINT 14 static PatternRec output_pattern[] = { /* exec */ {"\\(.*\n\\)*.*\\(\\(stopped\\|Bus error\\|Segmentation fault\\|\ Interrupt\\|signal.*\\) in \\([^ ]+\\) at line \\([0-9]+\\)\\( in file\ \"\\([^ ]+\\)\"\\)?\\)\n\\(.*\n\\)?\\(\\(.*\n\\)*\\)", NULL, {2, -1, 4, 5, 7, 9} }, /* done */ {"\\(.*\n\\)*\\(execution completed\\|program exited with [0-9]+\\)", NULL, {-1, -1, -1, -1, -1, -1} }, /* stop at */ {"(\\([0-9]+\\)) stop at \\(\"\\([^ ]+\\)\":\\)?\\([0-9]+\\)\n", NULL, {-1, 1, -1, 4, 3, -1} }, /* stop in */ {"(\\([0-9]+\\)) stop in \\([^ ]+\\)\n", NULL, {-1, 1, 2, -1, -1, -1} }, /* up, down */ {"\\(.*\n\\)?\\(Current function is \\([^ ]+\\)\n\\)\\([ ]*\\([0-9]+\\).*\n\\)", NULL, {2, -1, 3, 5, -1, -1} }, /* bell */ {"\\(Already at the \\(top\\|bottom\\) call level\n\\|\ No active stack frames\n\\|no program to run\n\\|no process to run\n\\|\ program is not active\n\\|can't continue execution\n\\|\ .*\ncan't write to process.*\n\\|\ \\(Top\\|End\\)-of-file; did not find search string:.*\n\\)", NULL, {-1, -1, -1, -1, -1} }, /* list, search */ {"[ ]*\\([0-9]+\\).*\n", NULL, {-1, -1, -1, 1, -1, -1} }, /* file */ {"\\(\\([^ ]*\\)\\|No current source file\\)\n", NULL, {-1, -1, -1, -1, 2, -1} }, /* print, display */ {"\\(warning: .*\n\\)?\\(\\(.*\\) = .*\n\\(.*\n\\)*\\)", NULL, { 3, -1, -1, -1, -1, 2} }, /* debug */ {"Reading symbolic information...\nRead [0-9]+ symbols\n", NULL, { -1, -1, -1, -1, -1, -1} }, NULL }; static PatternRec command_pattern[] = { {"[ ]*\\(run\\|rerun\\|cont\\|next\\|step\\)\\( [0-9]+\\)?[ ]*", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*stop[ ]+at[ ]+\\(\"[^ ]+\":\\)?[0-9]+[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*stop[ ]+in[ ]+[^ ]+[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(up\\|down\\)[ ]*\\( [0-9]+\\)?[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(delete\\|d\\)[ ]+\\(all\\|[0-9]+\\)", NULL, {-1, -1, -1, 1, -1, -1}}, {"[ ]*func[ ]+\\([^ ]+\\)[ ]*\n", NULL, {-1, -1, 1, -1, -1, -1}}, {"[ ]*file[ ]*\\([^ ]+\\)?[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*debug[ ]*[^ ]+[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*cd[ ]*[^ ]+[ ]*", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*use[ ]*", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*pwd[ ]*\n", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*list[ ]*", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(/\\|\?\\)[ ]*", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*\\(un\\)?display[ ]*[^ ]+[ ]*", NULL, {-1, -1, -1, -1, -1, -1}}, {"[ ]*print[ ]*[^ ]+[ ]*", NULL, {-1, -1, -1, -1, -1, -1}}, NULL }; xxgdb-1.12.orig/utils.c100644 1012 1010 7755 5663173242 13771 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * *****************************************************************************/ /* utils.c * * Contain common routines used by other functions. * * TextGetLastPos(): Get the last insertion position of text. * TextPositionToLine(): Return text position give a line number. * LineToStopNo(): Return the stop number given a line number. * DisableWindowResize(): Fix the size of a window inside vpane. * bell(): Ring the bell. * concat(): Concatenate two strings together */ #include "global.h" XawTextPosition TextGetLastPos(w) Widget w; { TextWidget ctx = (TextWidget) w; return (ctx->text.lastPos); } /* * Get the line number where the caret is. */ int TextPositionToLine(pos) XawTextPosition pos; { int line; if (displayedFile) { if (pos >= displayedFile->linepos[displayedFile->topline]) { for (line = displayedFile->topline; pos > displayedFile->linepos[line]; line++); return (pos == displayedFile->linepos[line] ? line : line-1); } else { for (line = 1; pos > displayedFile->linepos[line]; line++); return (pos == displayedFile->linepos[line] ? line : line-1); } } else return 0; } /* * Return the stop number associated with a given line number. * Return 0 if stop number not found. */ int LineToStop_no(line) int line; { int i; for (i=1; i <= nstops; i++) if (stops[i].line == line && stops[i].file && displayedFile && strcmp(stops[i].file, displayedFile->pathname) == 0) { return i; } return 0; } void DisableWindowResize(w) Widget w; { Arg args[MAXARGS]; Cardinal n; Dimension height; n = 0; XtSetArg(args[n], XtNheight, &height); n++; XtGetValues(w, args, n); XawPanedSetMinMax(w, height, height); XawPanedAllowResize(w, False); } void bell(volume) int volume; { if (debug) fprintf (stderr, "ring the bell\n"); XBell(XtDisplay(toplevel), volume); } /* append string s2 to end of string s1 and return the result */ char *concat(s1, s2) char *s1, *s2; { if (s2) { if (s1 == NULL) { s1 = XtMalloc((strlen(s2)+1)*sizeof(char)); strcpy(s1, s2); } else { s1 = XtRealloc(s1, strlen(s1)+strlen(s2)+2); strcat(s1, s2); } } #if 0 /*(PW)4DEC90 : bug ! if s2 is null, there is no reason to set s1 to 0 */ else s1 = NULL; #endif return (s1); } xxgdb-1.12.orig/windows.c100644 1012 1010 32325 6157015316 14326 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to dbx * * Copyright 1989, 1990 The University of Texas at Austin * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * not be used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * THE UNIVERSITY OF TEXAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS BE LIABLE FOR ANY * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung, The University of Texas at Austin * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* windows.c: * * CreateTitleBar() : Create title bar. * CreateFileLabel() : Create file label in file window. * CreateLineLabel() : Create line label in file window. * CreateFileWindow() : Create file window. * CreateMessageWindow() : Create message window. * CreateDisplayWindow() : Create display window. * CreateSubWindows() : Create the subwindows. * UpdateFileLabel() : Update file label. * UpdateLineLabel() : Update line label. * UpdateMessageWindow() : Update message window. */ #include "global.h" Widget fileWindow, /* parent of fileLabel and lineLabel */ messageWindow, /* window for displaying messages */ separator, /* separator in vpane */ displayWindow; /* area for displaying variables */ static Widget fileLabel, /* filename of displayed text */ lineLabel; /* line number of caret position */ /* * Private routines for creating various subwindows for xdbx. */ static void CreateFileLabel(parent) Widget parent; { Arg args[MAXARGS]; Cardinal n; n = 0; XtSetArg(args[n], XtNlabel, (XtArgVal) "No Source File"); n++; XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0); n++; fileLabel = XtCreateManagedWidget("fileLabel", labelWidgetClass, parent, args, n); } static void CreateLineLabel(parent) Widget parent; { Arg args[MAXARGS]; Cardinal n; n = 0; XtSetArg(args[n], XtNlabel, (XtArgVal) ""); n++; XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0); n++; XtSetArg(args[n], XtNfromHoriz, (XtArgVal) fileLabel); n++; XtSetArg(args[n], XtNhorizDistance, (XtArgVal) 0); n++; lineLabel = XtCreateManagedWidget("lineLabel", labelWidgetClass, parent, args, n); } static void CreateFileWindow(parent) Widget parent; { Arg args[MAXARGS]; Cardinal n; n = 0; XtSetArg(args[n], XtNshowGrip, (XtArgVal) False); n++; fileWindow = XtCreateManagedWidget("fileWindow", formWidgetClass, parent, args, n); CreateFileLabel(fileWindow); CreateLineLabel(fileWindow); } static void CreateMessageWindow(parent) Widget parent; { Arg args[MAXARGS]; Cardinal n; n = 0; XtSetArg(args[n], XtNlabel, (XtArgVal) ""); n++; XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyLeft); n++; XtSetArg(args[n], XtNshowGrip, (XtArgVal) False); n++; messageWindow = XtCreateManagedWidget("messageWindow", labelWidgetClass, parent, args, n); } /* Create a window for displaying variables as specified by the display * command in dbx. */ static void CreateDisplayWindow(parent) Widget parent; { Arg args[MAXARGS]; Cardinal n; #ifndef NEW_INTERFACE n = 0; XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0); n++; XtSetArg(args[n], XtNmin, (XtArgVal) 2); n++; XtSetArg(args[n], XtNmax, (XtArgVal) 2); n++; XtSetArg(args[n], XtNshowGrip, (XtArgVal) False); n++; separator = XtCreateWidget("", labelWidgetClass, parent, args, n); #endif n = 0; XtSetArg(args[n], XtNeditType, (XtArgVal) XawtextRead); n++; #ifdef NEW_INTERFACE displayWindow = XtCreateManagedWidget("displayWindow", asciiTextWidgetClass, parent, args, n); #else displayWindow = XtCreateWidget("displayWindow", asciiTextWidgetClass, parent, args, n); #endif #ifndef NEW_INTERFACE if (app_resources.displayWindow) { XtManageChild(separator); XtManageChild(displayWindow); } #endif } #ifdef NEW_INTERFACE Widget pcWindow; Widget sourceShell; Widget sourceToggle; Widget commandShell; Widget commandToggle; Widget displayShell; Widget displayToggle; Atom wm_delete_window; Widget MatchToggleFromShell(shell) Widget shell; { if (shell == sourceShell) return sourceToggle; if (shell == commandShell) return commandToggle; if (shell == displayShell) return displayToggle; return NULL; } void State_Transient(w, client_data, call_data) Widget w; Widget client_data; XtPointer call_data; { Arg args[MAXARGS]; Cardinal n; Boolean ToggleState; XtVaGetValues(w, XtNstate, &ToggleState, NULL); if (ToggleState) XtPopup(client_data, XtGrabNone); else XtPopdown(client_data); } void WMDeleteWindow(w, client_data, msg) Widget w; XtPointer client_data; XClientMessageEvent *msg; { if (msg->type == ClientMessage && msg->data.l[0] == wm_delete_window) { w = MatchToggleFromShell(client_data); if (w) XawToggleUnsetCurrent(w); } } void SetupWMProtocol(shell) Widget shell; { XtRealizeWidget(shell); XSetWMProtocols(XtDisplay(shell), XtWindow(shell), &wm_delete_window, 1); XtAddEventHandler(shell, NoEventMask, True, WMDeleteWindow, (XtPointer) shell); } void CreatePCToggle(parent, toggle, name, label, shell) Widget parent; Widget *toggle; char *name; XtPointer label; Widget shell; { Arg args[MAXARGS]; Cardinal n; n = 0; XtSetArg(args[n], XtNresize, (XtArgVal) False); n++; XtSetArg(args[n], XtNlabel, label); n++; XtSetArg(args[n], XtNwidth, 130); n++; #ifdef OPEN_ALL_WINDOWS XtSetArg(args[n], XtNstate, True); n++; #endif *toggle = XtCreateManagedWidget(name, toggleWidgetClass, parent, args, n); XtAddCallback(*toggle, XtNcallback, State_Transient, shell); } static void CreatePopupControls(parent) Widget parent; { Widget QuitButtonTwo; Arg args[MAXARGS]; Cardinal n; n = 0; XtSetArg(args[n], XtNshowGrip, (XtArgVal) False); n++; pcWindow = XtCreateManagedWidget("pcWindow", boxWidgetClass, parent, args, n); CreatePCToggle(pcWindow, &sourceToggle , "pcSource" , "Source Listing" , sourceShell ); CreatePCToggle(pcWindow, &commandToggle, "pcCommand" , "Command Buttons" , commandShell); #ifdef GDB CreatePCToggle(pcWindow, &displayToggle, "pcDisplay" , "Display Window" , displayShell); #endif n = 0; QuitButtonTwo = XtCreateManagedWidget("Quit", commandWidgetClass, pcWindow, args, n); XtAddCallback(QuitButtonTwo, XtNcallback, Quit, NULL); } #endif /* NEW_INTERFACE */ /* PUBLIC ROUTINES */ /* * Top level function for creating all the xdbx subwindows. */ void CreateSubWindows(parent) Widget parent; { Widget vpane; /* outer widget containing various subwindows */ #ifdef NEW_INTERFACE Widget listingForm; /* file listing Shell */ Widget displayForm; /* file listing Shell */ #endif Arg args[MAXARGS]; Cardinal n; n = 0; vpane = XtCreateManagedWidget("vpane", panedWidgetClass, parent, args, n); #ifdef NEW_INTERFACE wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False); n = 0; XtSetArg(args[n], XtNtitle, "xxgdb Source Display"); n++; sourceShell = XtCreatePopupShell("sourceShell", transientShellWidgetClass, toplevel, args, n); n=0; listingForm = XtCreateManagedWidget("listingForm", formWidgetClass, sourceShell, args, n); CreateFileWindow(listingForm); CreateSourceWindow(listingForm); SetupWMProtocol(sourceShell); #else CreateFileWindow(vpane); CreateSourceWindow(vpane); #endif CreateMessageWindow(vpane); #ifdef NEW_INTERFACE n = 0; XtSetArg(args[n], XtNtitle, "xxgdb Commands"); n++; commandShell = XtCreatePopupShell("commandShell", transientShellWidgetClass, toplevel, args, n); CreateCommandPanel(commandShell); SetupWMProtocol(commandShell); #else CreateCommandPanel(vpane); #endif CreateDialogWindow(vpane); #ifdef GDB #ifdef NEW_INTERFACE n = 0; XtSetArg(args[n], XtNtitle, "xxgdb Variable Display"); n++; displayShell = XtCreatePopupShell("displayShell", transientShellWidgetClass, toplevel, args, n); n=0; displayForm = XtCreateManagedWidget("displayForm", formWidgetClass, displayShell, args, n); CreateDisplayWindow(displayForm); SetupWMProtocol(displayShell); #else CreateDisplayWindow(vpane); #endif #else /* not GDB */ #ifndef BSD CreateDisplayWindow(vpane); #endif #endif /* not GDB */ #ifdef NEW_INTERFACE CreatePopupControls(vpane); #endif } /* * Routines for updating fields for the filename and line number * in the file window, and the execution status in the message window. */ void UpdateFileLabel(string) char *string; { Arg args[MAXARGS]; Cardinal n; n = 0; XtSetArg(args[n], XtNlabel, (XtArgVal) string); n++; XtSetValues(fileLabel, args, n); } void UpdateLineLabel(line) Cardinal line; { Arg args[MAXARGS]; Cardinal n; char string[10]; n = 0; if (line > 0) sprintf(string, "%d", line); else strcpy(string, ""); XtSetArg(args[n], XtNlabel, (XtArgVal) string); n++; XtSetValues(lineLabel, args, n); } /*--------------------------------------------------------------------------+ | | | Note : UpdateMessageWindow assumes that the format string | | can only contain one %s specifier. | | arg is either NULL or is a string. | | format is a string (never NULL). | | | +--------------------------------------------------------------------------*/ void UpdateMessageWindow(format, arg) char *format, *arg; { char *message; char string[LINESIZ]; int fulllength; Arg args[MAXARGS]; Cardinal n; /* fix bug where if a debugged program function arg is a string that looks like "%s", and UpdateMesssageWindow is passed that string in format (with a NULL arg), then UpdateMessageWindow expects another arg. We fix by seeing if arg is NULL. If so, then make format "%s" and arg whatever the format string was. */ if (arg == NULL) { arg = format; format = "%s"; } fulllength = strlen (" ") + strlen (format) + 1 + ((arg == NULL) ? 0 : strlen (arg)); if (fulllength > LINESIZ) message = (char*) XtMalloc (fulllength); else message = string; strcpy(message, " "); sprintf(message + strlen(message), format, arg); n = 0; XtSetArg(args[n], XtNlabel, (XtArgVal) message); n++; XtSetValues(messageWindow, args, n); if (fulllength > LINESIZ) XtFree(message); } void ClearMessageWindow() { Arg args[MAXARGS]; Cardinal n; n = 0; XtSetArg(args[n], XtNlabel, (XtArgVal) ""); n++; XtSetValues(messageWindow, args, n); } xxgdb-1.12.orig/xdbx.c100644 1012 1010 42723 5745615153 13613 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* xdbx.c * * Contain main program and initialization, command line options handling, * and resource database management. * * Syntax(): Print an error message if xdbx is invoked with an * incorrect number of arguments. * main_init(): Initialization routine. * dbxoptions(): Construct command line arguments for dbx. * main(): Main program. */ #ifdef GDB #define XGDBVERSION "1.12" #endif #ifdef SYSV # include # include # include #endif #include "global.h" #include "bitmaps.h" #include "patchlevel.h" #define VERSION "2.1" #define Offset(field) (XtOffset(XdbxResources *, field)) char *progname; char cwd[MAXPATHLEN]; /* The current working directory */ XtAppContext app_context; /* application context */ Widget toplevel; /* top level widget */ Display *display; /* connection to X server */ Cursor watch; /* XC_watch cursor */ XdbxResources app_resources; /* application resources of xdbx */ char xdbxinit[LINESIZ]; /* initialization file name */ Boolean Tstartup = False; /* if True, remove xdbxinit */ Boolean debug = False; /* debug mode for xdbx */ #ifdef GDB char gdbinit[LINESIZ]; /* initialization file name (.gdbinit) */ #endif /* GDB */ static XtResource resources[] = { {"bell", "Bell", XtRBoolean, sizeof(Boolean), Offset(bell), XtRImmediate, (caddr_t)False}, {"displayWindow", "DisplayWindow", XtRBoolean, sizeof(Boolean), Offset(displayWindow), XtRImmediate, (caddr_t)False}, {"prompt", "Prompt", XtRString, sizeof(char *), Offset(prompt), XtRImmediate, (caddr_t)NULL}, /* CRL mod 4 3/15/91 GWC - added two new application resources */ {"db_name", "Prompt", XtRString, sizeof(char *), Offset(db_name), XtRImmediate, (caddr_t)NULL}, {"db_prompt", "Prompt", XtRString, sizeof(char *), 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}, {"stop_color", "StopColor", XtRPixel, sizeof(Pixel), Offset(stop_color), XtRString, "Red"}, {"arrow_color", "ArrowColor", XtRPixel, sizeof(Pixel), Offset(arrow_color), XtRString, "Blue"}, {"updown_color", "UpdownColor", XtRPixel, sizeof(Pixel), Offset(updown_color), XtRString, "Blue"}, {"bomb_color", "bombColor", XtRPixel, sizeof(Pixel), Offset(bomb_color), XtRString, "Red"}, {"dataDpyMaxHeight", "DataDpyMaxHeight", XtRDimension, sizeof(Dimension), Offset(dataDpyMaxHeight), XtRString, "300"}, {"dataDpyMaxWidth", "DataDpyMaxWidth", XtRDimension, sizeof(Dimension), Offset(dataDpyMaxWidth), XtRString, "600"}, {"tabstop", "TabStop", XtRInt, sizeof(int), Offset(tabstop), XtRString, "8"}, {"bigicon", "Xdbxoptions", XtRBoolean, sizeof(Boolean), Offset(bigicon), XtRImmediate, (caddr_t)False}, {"debug", "Xdbxoptions", XtRBoolean, sizeof(Boolean), Offset(debug), XtRImmediate, (caddr_t)False}, {"dbxopt_r", "Dbxoptions", XtRBoolean, sizeof(Boolean), Offset(dbxopt_r), XtRImmediate, (caddr_t)False}, {"dbxopt_i", "Dbxoptions", XtRBoolean, sizeof(Boolean), Offset(dbxopt_i), XtRImmediate, (caddr_t)False}, {"includeDir", "Dbxoptions", XtRString, sizeof(char *), Offset(includeDir), XtRImmediate, (caddr_t)NULL}, {"dbxopt_k", "Dbxoptions", XtRBoolean, sizeof(Boolean), Offset(dbxopt_k), XtRImmediate, (caddr_t)False}, {"cfile", "Dbxoptions", XtRString, sizeof(char *), Offset(cfile), XtRImmediate, (caddr_t)NULL}, {"dbxopt_kbd", "Dbxoptions", XtRBoolean, sizeof(Boolean), Offset(dbxopt_kbd), XtRImmediate, (caddr_t)False}, {"fcount", "Dbxoptions", XtRString, sizeof(char *), Offset(fcount), XtRImmediate, (caddr_t)NULL}, {"bindings", "Xdbxoptions", XtRString, sizeof(char *), Offset(bindings), XtRImmediate, (caddr_t)NULL}, #ifdef GDB {"gdbinit", "Dbxoptions", XtRString, sizeof(char *), Offset(gdbinit), XtRImmediate, (caddr_t)NULL}, #endif /* GDB */ {"startup", "Dbxoptions", XtRString, sizeof(char *), Offset(startup), XtRImmediate, (caddr_t)NULL}, {"tstartup", "Dbxoptions", XtRString, sizeof(char *), Offset(tstartup), XtRImmediate, (caddr_t)NULL}, }; String fallback_resources[] = { "*allowShellResize: True", "*borderWidth: 1", "*font: fixed", "*vpane.width: 550", "*fileWindow*font: variable", "*fileLabel.width: 500", "*lineLabel.width: 50", #ifdef NEW_INTERFACE "*sourceShell.geometry: 550x260+0+380", "*sourceForm.top: ChainTop", "*sourceForm.bottom: ChainBottom", "*sourceForm.left: ChainLeft", "*sourceForm.right: ChainRight", "*sourceForm.fromVert: fileWindow", "*sourceWindow.width: 558", "*sourceWindow.height: 220", #else "*sourceForm.preferredPaneSize: 320", #endif "*sourceWindow.leftMargin: 35", "*sourceWindow.scrollHorizontal: whenNeeded", "*sourceWindow.translations: #override \\n\ : SelectStart() SelectWord() \\n\ Shift: Update() SelectEnd() PrintSelection() \\n\ : Update() SelectEnd() \\n", "*messageWindow*font: variable", "*messageWindow.min: 30", "*messageWindow.max: 30", "*dialogWindow.preferredPaneSize: 240", "*dialogWindow.resizeToPreferred: True", "*dialogWindow.translations: #override \\n\ : SelectStart() SelectWord() \\n\ Shift: SelectEnd() PrintSelection() \\n\ : SelectEnd() \\n", #ifdef NEW_INTERFACE "*commandShell.geometry: 190x370+590+0", #else "*commandWindow.preferredPaneSize: 146", "*commandWindow.skipAdjust: True", #endif "*commandWindow.hSpace: 6", "*commandWindow.vSpace: 6", "*Command.height: 20", "*Command.width: 80", "*List.columnSpacing: 10", #ifdef NEW_INTERFACE "*displayShell.geometry: +590+450", "*displayWindow.top: ChainTop", "*displayWindow.bottom: ChainBottom", "*displayWindow.left: ChainLeft", "*displayWindow.right: ChainRight", "*displayWindow.width: 300", "*displayWindow.height: 100", #else "*displayWindow.preferredPaneSize: 50", "*displayWindow.skipAdjust: True", #endif "*displayWindow.scrollVertical: whenNeeded", "*displayWindow.scrollHorizontal: whenNeeded", "*displayWindow.translations: #override \\n\ : SelectStart() SelectWord() \\n\ Shift: SelectEnd() PrintSelection() \\n\ : SelectEnd() \\n", "*popup*showGrip: False", "*bindings: emacs", NULL, }; static XrmOptionDescRec options[] = { {"-bigicon","bigicon", XrmoptionNoArg, "True"}, {"-debug", "debug", XrmoptionNoArg, "True"}, /* CRL mod 4 4/1/91 GWC - command line options for db_name and db_prompt */ {"-db_name","db_name", XrmoptionSepArg, NULL}, {"-db_prompt","db_prompt", XrmoptionSepArg, NULL}, #ifdef GDB {"-bindings", "bindings", XrmoptionSepArg, "emacs"}, {"-d", "includeDir", XrmoptionSepArg, NULL}, {"-nx", "nx", XrmoptionNoArg, "True"}, {"-i", "gdbinit", XrmoptionSepArg, NULL}, /* (PW)28DEC93 : add .gdbinit overwrite */ #else {"-r", "dbxopt_r", XrmoptionNoArg, "True"}, {"-i", "dbxopt_i", XrmoptionNoArg, "True"}, {"-I", "includeDir", XrmoptionSepArg, NULL}, {"-k", "dbxopt_k", XrmoptionNoArg, "True"}, #ifdef BSD /* Berkeley dbx */ {"-c", "cfile", XrmoptionSepArg, NULL}, #else /* Sun dbx */ {"-kbd", "dbxopt_kbd", XrmoptionNoArg, "True"}, {"-f", "fcount", XrmoptionSepArg, NULL}, {"-s", "startup", XrmoptionSepArg, NULL}, {"-sr", "tstartup", XrmoptionSepArg, NULL}, #endif #ifdef MIPS /* Mips dbx */ {"-pixie", "pixie", XrmoptionNoArg, "True"}, #endif #endif /* not GDB */ }; XtActionsRec xdbx_actions[] = { {"SelectStart", (XtActionProc) SelectStart}, {"SelectEnd", (XtActionProc) SelectEnd}, {"SelectWord", (XtActionProc) SelectWord}, {"PrintSelection", (XtActionProc) PrintSelection}, {"Update", (XtActionProc) Update}, {"DeleteWord", (XtActionProc) DeleteWord}, {"DeleteLine", (XtActionProc) DeleteLine}, {NULL, NULL} }; static void Syntax(call) char *call; { fprintf(stderr, #ifdef GDB "Usage: %s [-toolkitoptions] [-gdboptions] [objfile [corefile]]\n", #else "Usage: %s [-toolkitoptions] [-dbxoptions] [objfile [corefile]]\n", #endif /* not GDB */ call); exit(1); } /* Set window manager hints to indicate display accepts input. * Initialize routines in source.c, signs.c and parser.c. * Disable window resize of fileWindow. * Get the name of the dbx command initialization file. */ static void main_init() { XWMHints wmhints; char title[100]; display = XtDisplay(toplevel); watch = XCreateFontCursor(display, XC_watch); #ifdef GDB sprintf(title, "xxgdb %s", XGDBVERSION); XStoreName(display, XtWindow(toplevel), title); XSetIconName(display, XtWindow(toplevel), "xxgdb"); #else sprintf(title, "xdbx %s (patch level %d)", VERSION, PATCHLEVEL); XStoreName(display, XtWindow(toplevel), title); XSetIconName(display, XtWindow(toplevel), "xdbx"); #endif /* not GDB */ wmhints.input = True; if (app_resources.bigicon) wmhints.icon_pixmap = XCreateBitmapFromData(display, XtWindow(toplevel), xdbx64_bits, xdbx64_width, xdbx64_height); else wmhints.icon_pixmap = XCreateBitmapFromData(display, XtWindow(toplevel), xdbx48_bits, xdbx48_width, xdbx48_height); wmhints.flags = IconPixmapHint | InputHint; XSetWMHints(display, XtWindow(toplevel), &wmhints); if (!app_resources.delimiters || strcmp(app_resources.delimiters, "") == 0) app_resources.delimiters = XtNewString(DELIMITERS); if (app_resources.prompt && strcmp(app_resources.prompt, "") != 0) xdbxprompt = app_resources.prompt; else xdbxprompt = XtNewString(XDBXPROMPT); debug = app_resources.debug; DisableWindowResize(fileWindow); #ifdef GDB /* (PW)28DEC93: we can override the default .gdbinit file */ if (app_resources.gdbinit) strcpy(gdbinit, app_resources.gdbinit); else strcpy (gdbinit, ".gdbinit"); if (debug) fprintf(stderr,"Startup file would be \"%s\"\n", gdbinit); 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"); 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(); parser_init(); } /* Reconstruct command line arguments for calling dbx. * Return the argument list for dbx and new value of argc. */ static char **dbxoptions(argc, argv, app_resources) int *argc; char **argv; XdbxResources *app_resources; { char **dbxargv; #ifndef GDB char *temp = (char *)XtNewString("xdbx.XXXXXX"); #endif int i=0; dbxargv = (char **) XtMalloc (MAXARGS * sizeof(char *)); for (i=0; i < *argc; i++) dbxargv[i] = argv[i]; #ifdef GDB dbxargv[i++] = "-fullname"; /* see gdb_regex.h */ #endif /* GDB */ if (app_resources->dbxopt_r) dbxargv[i++] = "-r"; if (app_resources->dbxopt_i) dbxargv[i++] = "-i"; if (app_resources->includeDir) { #ifdef GDB dbxargv[i++] = "-d"; #else dbxargv[i++] = "-I"; #endif /* not GDB */ dbxargv[i++] = app_resources->includeDir; } if (app_resources->dbxopt_k) dbxargv[i++] = "-k"; if (app_resources->cfile) { dbxargv[i++] = "-c"; dbxargv[i++] = app_resources->cfile; } if (app_resources->dbxopt_kbd) dbxargv[i++] = "-kbd"; if (app_resources->fcount) { dbxargv[i++] = "-f"; dbxargv[i++] = app_resources->fcount; } /* If .dbxinit exists in the local or home directory, include the option * -c (Berkeley dbx) or -s (Sun dbx) and a dummy filename as the option * argument. This will prevent dbx from reading the user's command * initialization file. Xdbx will read each line and pass it to dbx * 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"; #else dbxargv[i++] = "-s"; #endif dbxargv[i++] = (char *) mktemp(temp); } #endif /* not GDB */ if (app_resources->startup) { /* overwrites dbxinit */ Tstartup = False; strcpy(xdbxinit, app_resources->startup); } if (app_resources->tstartup) { /* overwrites dbxinit */ Tstartup = True; strcpy(xdbxinit, app_resources->tstartup); } #ifndef GDB #ifdef MIPS if (app_resources->pixie) { /* pixie output */ dbxargv[i++] = "-pixie"; } #endif #endif /* not GDB */ dbxargv[i] = NULL; *argc = i; return dbxargv; } void main(argc, argv) int argc; char **argv; { char **dbxargv; progname = argv[0]; /* (MJH) */ #ifndef GDB /* (PW)12MAR93 : for gdb, use pwd command of gdb */ #ifdef SYSV getcwd((char *)cwd, MAXPATHLEN); #endif #endif /* not GDB */ trap_signals(); toplevel = XtAppInitialize(&app_context, "XDbx", options, XtNumber(options), &argc, argv, fallback_resources, NULL, 0); if (argc > 3) Syntax(argv[0]); XtGetApplicationResources(toplevel, &app_resources, resources, XtNumber(resources), NULL, 0); XtAppAddActions(app_context, xdbx_actions, XtNumber(xdbx_actions)); CreateSubWindows(toplevel); XtRealizeWidget(toplevel); main_init(); #ifdef GDB AppendDialogText("XXGDB comes with ABSOLUTELY NO WARRANTY.\n"); #endif dbxargv = dbxoptions(&argc, argv, &app_resources); calldbx(argc, dbxargv); #ifdef NEW_INTERFACE State_Transient(sourceToggle, sourceShell, NULL); State_Transient(commandToggle, commandShell, NULL); #ifdef GDB State_Transient(displayToggle, displayShell, NULL); #endif XtRealizeWidget(toplevel); /* just to bring the window ahead */ #endif /* NEW_INTERFACE */ XtAppMainLoop(app_context); } xxgdb-1.12.orig/xdbx.man100644 1012 1010 25234 5667746427 14156 0ustar geyerAlgebra.TH XDBX 1 "July 25 1990" "X Version 11" .SH NAME xdbx \- X window system interface to the dbx debugger. .SH SYNOPSIS .B xdbx [ \fI-toolkitoption ... \fP] [\fI-xdbxoption ... \fP] [\fI-dbxoption ... \fP] [\fIobjfile\fP [ \fIcorefile\fP ]] .SH DESCRIPTION \fIXdbx\fP is a graphical user interface to the \fIdbx\fP debugger under the X Window System. It provides visual feedback and mouse input for the user to control program execution through breakpoints, to examine and traverse the function call stack, to display values of variables and data structures, and to browse source files and functions. .LP \fIXdbx\fP allows initial dbx commands stored in the file \fI.dbxinit\fP to be executed immediately after the symbolic information is read. If \fI.dbxinit\fP does not exist in the current directory, the user's home directory is searched (\fI~/.dbxinit\fP). .LP \fIObjfile\fP is an object file produced by a compiler with the appropriate option (-g) specified to produce symbol table information for dbx. For Sun dbx, if no \fIobjfile\fP is specified, the \fBdebug\fP command can be used later to specify the program to be debugged. .LP If a file named \fIcore\fP exists in the current directory or a \fIcorefile\fP is specified, \fIxdbx\fP can be used to examine the state of the program when the core dump occurred. .LP The name of the debugger invoked by \fIxdbx\fP is, by default, dbx, but it can be overridden with the environment variable DEBUGGER. .SH OPTIONS \fIXdbx\fP accepts all of the standard X Toolkit command line options (see \fIX\fP(1)), and all the dbx options (see \fIdbx\fP(1)), plus the following xdbx specific options: .IP -bigicon Uses a 64x64 icon instead of the default 48x48 icon. .SH SUBWINDOWS \fIXdbx\fP consists of the following subwindows: .IP "File Window" 20 Display the full pathname of the file displayed in the source window, and the line number of the caret. .IP "Source Window" 20 Display the contents of a source file. .IP "Message Window" 20 Display the execution status and error messages of \fIxdbx\fP . .IP "Command Window" 20 Provide a list of the common dbx commands which are invoked by simply clicking the LEFT mouse button. .IP "Dialogue Window" 20 Provide a typing interface to dbx. .IP "Display Window" 20 Provide a window for displaying variables each time execution stops. (Sun dbx only) .LP The relative sizes of the source window, command window, and the dialogue window can be adjusted by dragging the grip (a small square near the right edge of a horizontal border) with the LEFT mouse button down. .SH SELECTION Text selection in the source window is modified to make it easier to select C expressions. LEFT mouse button down selects a C expression by highlighting it in reverse-video. LEFT mouse button down also positions the caret and updates the line label accordingly. .LP C expression selection is based on the resource \fIdelimiters\fP which determines the set of characters that delimits a C expression. (The default word selection behavior in the Athena text widget selects a word delimited by white spaces.) Text selection adjustment is possible by holding the LEFT mouse button down and dragging. .LP A LEFT mouse button click with the SHIFT button down prints the value of the expression selected. .LP .SH SCROLLBAR Pressing the LEFT mouse button scrolls the text forward, whereas pressing the RIGHT mouse button scrolls the text backward. The amount of scrolling depends on the distance of the pointer button away from the top of the scrollbar. If the button is pressed at the top of the scrollbar, only one line of text is scrolled. If the button is pressed at the bottom of the scrollbar, one screenful of text is scrolled. .LP Pressing the MIDDLE mouse button changes the thumb position of the scrollbar. Dragging the MIDDLE mouse button down moves the thumb along and changes the text displayed. .SH COMMAND BUTTONS .SS "Execution Commands" .IP "\fBrun\fP" 12 Begin program execution. .IP "\fBcont\fP" Continue execution from where it stopped. .IP "\fBstep\fP" Execute one source line, stepping into a function if the source line contains a function call. .IP "\fBnext\fP" Execute one source line, without stepping into any function call. .IP "\fBreturn\fP" (Berkeley dbx only) Continue execution until the selected procedure returns; the current procedure is used if none is selected. .LP .SS "Breakpoint Commands" .IP "\fBstop at\fP" 10 Stop program execution at the line selected. To set a breakpoint in the program, place the caret on the source line and click the \fBstop at\fP button. A stop sign will appear next to the source line. .IP "\fBstop in\fP" Stop program execution in the function selected. To set a breakpoint in a function, select the function name and click the \fBstop in\fP button. A stop sign will be placed near the first executable line of the function. .IP "\fBdelete\fP" Remove the breakpoint on the source line selected or the breakpoint number selected. .IP "\fBstatus\fP" Show the current breakpoints and traces. .LP .SS "Stack Commands" .IP "\fBwhere\fP" 10 Show a stack trace of the functions called. .IP "\fBup\fP" Move up one level on the call stack. .IP "\fBdown\fP" Move down one level on the call stack. .LP .SS "Data Display Commands" .IP "\fBprint\fP" 10 Print the value of a selected expression. .IP "\fBprint *\fP" Print the value of the object the selected expression is pointing to. .IP "\fBdisplay\fP" Display the value of a selected expression in the display window, updating its value every time execution stops. (Sun dbx only) .IP "\fBundisplay\fP" Stop displaying the value of the selected expression in the display window. If the selected expression is a constant, it refers to the display number associated with an expression in the display window. (Sun dbx only) .IP "\fBdump\fP" Print the names and values of local variables and parameters in the current or selected function. .LP .SS "Miscellaneous Commands" .IP "\fBfunc\fP" Display a selected function on the source window, and change the scope for variable name resolution to the selected function. The file scope is changed to the file containing the function. .IP "\fBfile\fP" Pop up a directory browser that allows the user to move up and down in the directory tree, to select a text file to be displayed, or (in Sun dbx) to select an executable file to debug. Directory entries are marked with a trailing slash (`/') and executables with a trailing asterisk (`*'). Filenames beginning with a dot (`.') or ending with a tilde (`~') are not listed in the menu. .IP "\fBsearch\fP" Pop up a search panel which allows both forward (>>) and reverse (<<) search of text strings in the source file. Hitting carriage return after entering the search string will begin a forward search and pop down the search panel. .IP "\fBquit\fP" Exit \fIxdbx\fP. .LP .SS "Displaying C Data Structures (Sun dbx only)" \fIXdbx\fP provides some primitive support for graphically displaying C structures and the ability of following pointers. Pressing the RIGHT mouse button on the \fBprint\fP (or \fBprint *\fP) command button displays the value of the selected expression (or the value the selected expression is pointing to) in a popup. If the value is a pointer or a structure containing pointers, the user can examine the value of the object that pointer is pointing to by clicking the pointer value. This will create another popup that displays the object the pointer points to. Clicking the label of the popup pops down itself and all of its descendants. .SH X DEFAULTS To change the default values of widget resources used in \fIxdbx\fP, you need to reference the widgets by name or by class. The widget hierarchies for the main window, the file menu, the search dialog box, and the popup data display used in xdbx are shown as follows, with the name of the widget followed by the name of its class in parentheses: .nf Main window: toplevel (ToplevelShell) vpane (Paned) fileWindow (Form) fileLabel (Label) lineLabel (Label) sourceForm (Form) sourceWindow (AsciiText) messageWindow (Label) commandWindow (Box) run (Command) cont (Command) next (Command) return (Command) step (Command) stop at (Command) stop in (Command) delete (Command) where (Command) up (Command) down (Command) print (Command) print * (Command) func (Command) file (Command) status (Command) display (Command) undisplay (Command) dump (Command) search (Command) quit (Command) dialogWindow (AsciiText) displayWindow (AsciiText) File menu: File Directory (TransientShell) popup (Paned) fileMenuLabel (Label) fileMenu (List) cancelButton (Command) Search dialog box: Search (TransientShell) searchPopup (Dialog) << (Command) >> (Command) DONE (Command) Data display popup: Data Popup (TransientShell) popup (Form) label (Label) dataDpyWindow (AsciiText) .LP .fi In addition to the standard X resources, \fIxdbx\fP uses the following application-specific resources for user customization. The value in parentheses is the default value. .IP \fBbell\fP If True, the bell is on. (True) .IP \fBdisplayWindow\fP If True, the display window appears on start up. (False) .IP \fBdelimiters\fP The set of delimiters for word selection. (" !%^&*()+=~|;:{},/#>) and reverse (<<) search of text strings in the source file. Hitting carriage return after entering the search string will begin a forward search and pop down the search panel. file Pop up a directory browser that allows the user to move up and down in the directory tree, to select a text file to be displayed, to select an executable file to debug, or to select a core file to debug. Directory entries are marked with a trailing slash (`/') and exe- cutables with a trailing asterisk (`*'). Filenames beginning with a dot (`.') or ending with a tilde (`~') are not listed in the menu. search Pop up a search panel which allows both forward (>>) X Version 11 Last change: November 1993 4 XXGDB(1.08) MISC. REFERENCE MANUAL PAGES XXGDB(1.08) and reverse (<<) search of text strings in the source file. Hitting carriage return after entering the search string will begin a forward search and pop down the search panel. yes Send 'y' (yes) to gdb. To be used when gdb requires a yes/no response. no Send 'n' (no) to gdb. To be used when gdb requires a yes/no response. quit Exit _x_x_g_d_b. Displaying C Data Structures _X_x_g_d_b provides some primitive support for graphically displaying C structures and the ability of following pointers. Pressing the RIGHT mouse button on the print (or print *) command button displays the value of the selected expression (or the value the selected expression is pointing to) in a popup. If the value is a pointer or a structure containing pointers, the user can examine the value of the object that pointer is pointing to by clicking the pointer value. This will create another popup that displays the object the pointer points to. Clicking the label of the popup pops down itself and all of its descendants. X DEFAULTS To change the default values of widget resources used in _x_x_g_d_b, you need to reference the widgets by name or by class. The widget hierarchies for the main window, the file menu, the search dialog box, and the popup data display used in xxgdb are shown as follows, with the name of the widget followed by the name of its class in parentheses: Main window: toplevel (ToplevelShell) vpane (Paned) fileWindow (Form) fileLabel (Label) lineLabel (Label) sourceForm (Form) sourceWindow (AsciiText) messageWindow (Label) commandWindow (Box) run (Command) cont (Command) next (Command) step (Command) finish (Command) break (Command) tbreak (Command) X Version 11 Last change: November 1993 5 XXGDB(1.08) MISC. REFERENCE MANUAL PAGES XXGDB(1.08) delete (Command) up (Command) down (Command) print (Command) print * (Command) display (Command) undisplay (Command) args (Command) locals (Command) stack (Command) search (Command) file (Command) show display (Command) show brkpts (Command) yes (Command) no (Command) quit (Command) dialogWindow (AsciiText) displayWindow (AsciiText) File menu: File Directory (TransientShell) popup (Paned) fileMenuLabel (Label) fileMenu (List) cancelButton (Command) Search dialog box: Search (TransientShell) searchPopup (Dialog) << (Command) >> (Command) DONE (Command) Data display popup: Data Popup (TransientShell) popup (Form) label (Label) dataDpyWindow (AsciiText) In addition to the standard X resources, _x_x_g_d_b uses the fol- lowing application-specific resources for user customiza- tion. The value in parentheses is the default value. bell If True, the bell is on. (True) displayWindow If True, the display window appears on start up. (False) delimiters The set of delimiters for word selection. (" X Version 11 Last change: November 1993 6 XXGDB(1.08) MISC. REFERENCE MANUAL PAGES XXGDB(1.08) !%^&*()+=~|;:{},/#>) and reverse (<<) search of text strings in the source file. Hitting carriage return after entering the search string will begin a forward search and pop down the search panel. .IP "\fBfile\fP" Pop up a directory browser that allows the user to move up and down in the directory tree, to select a text file to be displayed, to select an executable file to debug, or to select a core file to debug. Directory entries are marked with a trailing slash (`/') and executables with a trailing asterisk (`*'). Filenames beginning with a dot (`.') or ending with a tilde (`~') are not listed in the menu. .IP "\fBsearch\fP" Pop up a search panel which allows both forward (>>) and reverse (<<) search of text strings in the source file. Hitting carriage return after entering the search string will begin a forward search and pop down the search panel. .IP "\fByes\fP" Send 'y' (yes) to gdb. To be used when gdb requires a yes/no response. .IP "\fBno\fP" Send 'n' (no) to gdb. To be used when gdb requires a yes/no response. .IP "\fBquit\fP" Exit \fIxxgdb\fP. .LP .SS "Displaying C Data Structures \fIXxgdb\fP provides some primitive support for graphically displaying C structures and the ability of following pointers. Pressing the RIGHT mouse button on the \fBprint\fP (or \fBprint *\fP) command button displays the value of the selected expression (or the value the selected expression is pointing to) in a popup. If the value is a pointer or a structure containing pointers, the user can examine the value of the object that pointer is pointing to by clicking the pointer value. This will create another popup that displays the object the pointer points to. Clicking the label of the popup pops down itself and all of its descendants. .SH X DEFAULTS To change the default values of widget resources used in \fIxxgdb\fP, you need to reference the widgets by name or by class. The widget hierarchies for the main window, the file menu, the search dialog box, and the popup data display used in xxgdb are shown as follows, with the name of the widget followed by the name of its class in parentheses: .nf Main window: toplevel (ToplevelShell) vpane (Paned) fileWindow (Form) fileLabel (Label) lineLabel (Label) sourceForm (Form) sourceWindow (AsciiText) messageWindow (Label) commandWindow (Box) run (Command) cont (Command) next (Command) step (Command) finish (Command) break (Command) tbreak (Command) delete (Command) up (Command) down (Command) print (Command) print * (Command) display (Command) undisplay (Command) args (Command) locals (Command) stack (Command) search (Command) file (Command) show display (Command) show brkpts (Command) yes (Command) no (Command) quit (Command) dialogWindow (AsciiText) displayWindow (AsciiText) File menu: File Directory (TransientShell) popup (Paned) fileMenuLabel (Label) fileMenu (List) cancelButton (Command) Search dialog box: Search (TransientShell) searchPopup (Dialog) << (Command) >> (Command) DONE (Command) Data display popup: Data Popup (TransientShell) popup (Form) label (Label) dataDpyWindow (AsciiText) .LP .fi In addition to the standard X resources, \fIxxgdb\fP uses the following application-specific resources for user customization. The value in parentheses is the default value. .IP \fBbell\fP If True, the bell is on. (True) .IP \fBdisplayWindow\fP If True, the display window appears on start up. (False) .IP \fBdelimiters\fP The set of delimiters for word selection. (" !%^&*()+=~|;:{},/# #include #include #include #include #include #if ( defined(SYSV) || defined(SVR4) ) && !defined(HPUX) #define signal sigset #endif static void handler (sig) int sig; { } main () { int sock; struct sockaddr_un name; char ttypid[40]; #if 0 /* for debug only */ { char *myname; char buf[10000]; fprintf(stderr, "\n\nHello ! !\n\n"); fprintf(stderr, "\n\nisatty == %d\n\n", isatty(0)); myname = ttyname(0); if (myname == 0) { fprintf (stderr, "\n\n ERROR ttyname == 0 \n\n\n"); } else { fprintf (stderr, "\n\n ttyname == %s\n\n\n", myname); } sprintf(ttypid, "%s,%d", myname, getpid()); } #else sprintf(ttypid, "%s,%d", ttyname(0), getpid()); #endif sock = socket(AF_UNIX, SOCK_DGRAM, 0); name.sun_family = AF_UNIX; strcpy(name.sun_path, "/tmp/iowindowtty"); sendto(sock, ttypid, 40, 0, (struct sockaddr*)&name, sizeof(struct sockaddr_un)); close(sock); signal(SIGINT, handler); signal(SIGQUIT, handler); signal(SIGTSTP, handler); #ifdef SVR4 setpgid(0,0); #else setpgrp(0,0); #endif close(0); close(1); while (1) pause(); } xxgdb-1.12.orig/gdb_parser.c100644 1012 1010 111737 6224427401 14766 0ustar geyerAlgebra/***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * ***************************************************************************** * * xxgdb - X Window System interface to the gdb debugger * * Copyright 1990,1993 Thomson Consumer Electronics, Inc. * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of Thomson Consumer * Electronics (TCE) not be used in advertising or publicity pertaining * to distribution of the software without specific, written prior * permission. TCE makes no representations about the suitability of * this software for any purpose. It is provided "as is" without express * or implied warranty. * * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * * Adaptation to GDB: Pierre Willard * XXGDB Created: December, 1990 * *****************************************************************************/ /* gdb_parser.c: * * WARNING : gdb_parser.c is included by parser.c for GDB. * * Parse output messages from dbx using regular expression pattern matching, * and take appropriate action. * * parse(): Parse the dbx output and invoke the appropriate action * handler. * filter(): Modify the dbx output before it gets displayed on the * dialog window. * gdb_source_command(): Test for source command. */ /* * iand 94/02/10 cope better with non-blocking I/O. Exit when pty is closed rather * than spinning in a loop. * */ #include #include #include 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. | | | | This function is used in parser() before matching the output | | because this message can happen any time. | | | +--------------------------------------------------------------------------*/ void filter_reading_symbols(output) char *output; { struct re_registers regs; int r; char *p1; char *p2; /* test for reading symbols message */ while (re_match(output_pattern[O_READING_SYMBOLS].buf,output,strlen(output),0,®s) > 0) { /* we found a "Reading in symbols for ...done." pattern */ r = output_pattern[O_READING_SYMBOLS].reg_token[TK_MESG]; p1= output+regs.start[r]; p2 = output+regs.end[r]; /* remove "Reading in symbols for ...done." */ while((*(p1++) = *(p2++))); } } /*--------------------------------------------------------------------------+ | | | * This routine first parses the command string. | | * If the command is one of run, cont, next, step, stop at, stop in, | | * where, up, or down, it parses the dbx output to decide what action | | * to take and dispatch it to one of the handlers. | | * For other commands, the appropriate handler is called. | | * | | * !!! This routine has to be re-entrant. | | * | +--------------------------------------------------------------------------*/ void parse(output, command, flags) char *output; char *command; int flags; { int command_type; char *output_string; if (debug) { char *temp; if(!command)temp="";else temp=command; fprintf(stderr, "parse(output = %s, command = %s, flags = %d)\n", output, temp, flags); } /* Make a local copy of `output' and use that instead */ output_string = XtNewString(output); 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; } /* 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; } command_type = match(command_pattern, command, C_ANY); /* remove all "Reading in symbols for pw.c...done." */ filter_reading_symbols(output_string); switch (command_type) { case C_EXEC: case C_FINISH: { char * message; int signal = 0; if (debug) { fprintf(stderr, "C_EXEC or C_FINISH\n"); } message = 0; if (match(output_pattern, output_string, O_RECEIVED_SIGNAL) != -1) { message = XtNewString(Token.mesg); signal = Token.stop; /* signal number received */ } /* warning : the order of the matching tests is important */ if ((match(output_pattern, output_string, O_EXEC_MESS_AFTER) != -1) || (match(output_pattern, output_string, O_EXEC_MESS_BEFORE) != -1) || (match(output_pattern, output_string, O_EXEC_GDB) != -1)) { exec_handler(message,signal); } else { if (match(output_pattern, output_string, O_DONE) != -1) done_handler(message,signal); else unknown_output(output_string, command, flags); } if (message) { bell(0); XtFree(message); } } break; case C_UPDOWN: if (debug) { fprintf(stderr, "C_UPDOWN\n"); } if (match(output_pattern, output_string, O_UPDOWN) != -1) updown_handler(); else if (match(output_pattern, output_string, O_UPDOWN_NOSOURCE) != -1) /* here Token.msg and Token.func are updated. Do nothing with them. We are in a function with no source information. */ bell(0); else unknown_output (output_string, command, flags); break; case C_SEARCH: if (debug) { fprintf(stderr, "C_SEARCH\n"); } if (match(output_pattern, output_string, O_SEARCH) != -1) search_handler(); else unknown_output(output_string, command, flags); break; case C_DELETE: if (debug) { fprintf(stderr, "C_DELETE\n"); } delete_handler(); break; case C_LIST: if (debug) { fprintf(stderr, "C_LIST\n"); } if (match(output_pattern, output_string, O_LIST) != -1) list_handler(); else unknown_output(output_string, command, flags); break; case C_BREAK: if (debug) { fprintf(stderr, "C_BREAK\n"); } if (match(output_pattern, output_string, O_BREAK) != -1) break_handler(); else unknown_output(output_string, command, flags); break; case C_INFO_DIR: if (debug) { fprintf(stderr, "C_INFO_DIR\n"); } if (match(output_pattern, output_string, O_INFO_DIR) != -1) info_dir_handler(); else unknown_output(output_string, command, flags); break; case C_DIRECTORY: if (debug) { fprintf(stderr, "C_DIRECTORY\n"); } directory_handler(); break; case C_INFO_LINE: if (debug) { fprintf(stderr, "C_INFO_LINE\n"); } if (match(output_pattern, output_string, O_INFO_LINE) != -1) info_line_handler(); /* command was 'info line' */ else unknown_output(output_string, command, flags); break; case C_INFO_BREAK: if (debug) { fprintf(stderr, "C_INFO_BREAK\n"); } info_break_handler(output_string); break; case C_DISPLAY: /* means "display foo\n" command */ if (debug) { fprintf(stderr, "C_DISPLAY\n"); } { if ((strcmp(output_string, "") == 0) || (match(output_pattern, output_string, O_DISPLAY) != -1)) display_handler(); else unknown_output(output_string, command, flags); } break; case C_UNDISPLAY: if (debug) { fprintf(stderr, "C_UNDISPLAY\n"); } if (strcmp(output_string, "") == 0) display_handler(); else unknown_output(output_string, command, flags); break; case C_DISPLAY_INFO: /* means "display\n" command */ if (debug) { fprintf(stderr, "C_DISPLAY_INFO\n"); } { if ((strcmp(output_string, "") == 0) || (match(output_pattern, output_string, O_DISPLAY_INFO) != -1)) display_info_handler(); else unknown_output(output_string, command, flags); } break; case C_CD: if (debug) { fprintf(stderr, "C_CD\n"); } if (new_gdb4()) /* this fixes where cd and pwd dont work right for 4.x (cd doesn't do anything but beep, pwd doesn't work when cwd is not cannonical) */ query_gdb ("pwd\n", PARSE_ON); else if (match(output_pattern, output_string, O_CD) != -1) cd_handler(Token.mesg); else unknown_output(output_string, command, flags); break; case C_PWD: if (debug) { fprintf(stderr, "C_PWD\n"); } if (match(output_pattern, output_string, O_PWD) != -1) pwd_handler(Token.display? Token.display : Token.mesg); else unknown_output(output_string, command, flags); break; case C_FRAME_CURR: if (debug) { fprintf(stderr, "C_FRAME_CURR\n"); } if (match(output_pattern, output_string, O_FRAME_CURR) != -1) frame_curr_handler(); else unknown_output(output_string, command, flags); break; case C_PRINT: if (debug) { fprintf(stderr, "C_PRINT\n"); } { /* for GDB, the label of the popup display is the expression string which is printed instead of $n */ char * prtname; prtname = 0; if ((Token.mesg) && (PopupMode)) prtname = XtNewString(Token.mesg); if (match(output_pattern, output_string, O_PRINT) != -1) { if (prtname) { XtFree(Token.mesg); Token.mesg = prtname; prtname = 0; /* not to XtFree twice this string */ } print_handler(output_string); } else unknown_output(output_string, command, flags); /* if PopupMode was true but GDB found an error in print statement (ie match() returned -1), PopupMode was never reset */ PopupMode = FALSE; XtFree(prtname); } break; case C_SYMBOL_FILE: case C_FILE: if (debug) { fprintf(stderr, "C_FILE or C_SYMBOL_FILE\n"); } debug_handler(); break; case C_SOURCE: /* WE SHOULD NEVER ARRIVE HERE */ if (debug) { fprintf(stderr, "C_SOURCE - WE SHOULD NEVER ARRIVE HERE\n"); } break; case C_EXEC_FILE: if (debug) { fprintf(stderr, "C_EXEC_FILE\n"); } break; case C_CORE_FILE: if (debug) { fprintf(stderr, "C_CORE_FILE\n"); } 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... (PW)8JUN93 : we also test for current source and current source full pathname. */ case C_INFO_SOURCE: if (debug) { fprintf(stderr, "C_INFO_SOURCE\n"); } cdir[0] = 0; source_fullpath[0] = 0; source_path[0] = 0; if (match(output_pattern, output_string, O_INFO_SOURCE) != -1) info_source_handler(Token.mesg, Token.file, Token.func); break; default: if (debug) { fprintf(stderr, "C UNKNOWN\n"); } break; } XtFree(output_string); } #ifdef NEED_STRSTR /*--------------------------------------------------------------------------+ | | | Some systems DO NOT have the ANSI strstr function | | | +--------------------------------------------------------------------------*/ char * strstr (source, substr) char *source; char *substr; { char *src; char *sub; if (!source || !substr) return NULL; while (*source) { for (src = source, sub = substr; (*src) && (*sub) && (*src == *sub); src++,sub++); if (!*sub) return source; source++; } return NULL; } #endif /*--------------------------------------------------------------------------+ | | | Function to filter all the display information in a string | | | | input : string pointer, | | already_taken_care is number of char in string already | | processed (eg, displayed). | | | | output : none. | | | | See O_EXEC_DISPLAY in gdb_regex.h for the display pattern. | | | | Take care when GDB send some message after '\032\032...\n' | | which is not a display line. | | | | (gdb) finish | | Run till exit from #0 foo (n=1) (pw.c line 9) | | main () (pw.c line 41) | | /usr1/gnu_sun4/xxgdb/pw.c:41:590:beg:0x232c | | 1: i = 1 | | Value returned is $1 = 1 | | (gdb) | | | +--------------------------------------------------------------------------*/ void filter_display_info(output, already_taken_care) char *output; unsigned int already_taken_care; { struct re_registers regs; int r; char *p; char *p1; char *p2; char *cp_output; int begin_struct; p = cp_output = XtNewString(output); p1 = strstr(p,"\032\032"); /* find beginning of special gdb line */ if ((p1 == 0) || ((p2 = strchr(p1+1,'\n')) == 0)) { AppendDialogText(p + already_taken_care); /* something wrong here */ XtFree(cp_output); return; } *p1 = 0; if (p1 > (p + already_taken_care)) { AppendDialogText(p + already_taken_care); /* print everything before that line */ } p = p2 + 1; /* end of that line + skip \n */ /* test for beginning of a display */ while (re_match(output_pattern[O_EXEC_DISPLAY].buf,p,strlen(p),0,®s) > 0) { /* we found a "X:....\n" pattern */ r = output_pattern[O_EXEC_DISPLAY].reg_token[TK_DISP]; p1= p+regs.start[r]; p2 = p+regs.end[r]; /* count number of { and } : if not equal, the next lines are part of this display */ begin_struct = 0; while (p1 < p2) { switch(*(p1++)) { case '{': begin_struct++; break; case '}': begin_struct--; break; } } p1=p+regs.start[r]; *p1 = 0; if (p != p1) { /* do not print anything already printed */ if (p < (cp_output + already_taken_care)) { p = cp_output + already_taken_care; } if (p < p1) { AppendDialogText(p); /* print what is before display */ } } 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'); } } if (p < (cp_output + already_taken_care)) { p = cp_output + already_taken_care; /* do not print anything already printed */ } AppendDialogText(p); /* print what is after display */ XtFree(cp_output); } /*--------------------------------------------------------------------------+ | | | * This function edits the dbx output so that unnecessary information is | | * not displayed on the dialog window. | | * It filters away the some output returned by the execution commands; | | * output from the search commands, and the display command. | | * On Sun dbx, it also filters away part of the output returned by the | | * up and down commands. | | * | +--------------------------------------------------------------------------*/ void filter (string, output, command) char *string, *output, *command; { struct re_registers regs; char *p; char *p2; static Boolean deleteRest = False; static Boolean for_gdb_only = False; int command_type = -1; static unsigned int already_taken_care = 0; Boolean previous_for_gdb_only; if (output == NULL || strcmp(output, "") == 0) return; /* for GDB, the only things we want to filter are: - the line displayed because of the -fullname option : "\032\032/usr1/gnu_sun4/xdbx/pw.c:6:40:beg:0x22b0\n", - the displayed info which goes into the display window, - list and search outputs */ if (!string) string = ""; if (command) command_type = match(command_pattern, command, C_ANY); if ((command_type == C_EXEC)||(command_type == C_FINISH)) { if ((re_match(output_pattern[O_EXEC_MESS_AFTER].buf,output,strlen(output),0,®s) > 0) || (re_match(output_pattern[O_EXEC_MESS_BEFORE].buf,output,strlen(output),0,®s) > 0) || (re_match(output_pattern[O_EXEC_GDB].buf,output,strlen(output),0,®s) > 0)) { /* Remove display messages from output and print what is not a display */ if (Prompt) { filter_display_info (output, already_taken_care); for_gdb_only = False; already_taken_care = 0; deleteRest = False; } else { deleteRest = True; } return; } else /* does not match exec pattern yet */ { if (deleteRest) /* if already matched before */ { /* Remove display messages from output and print what is not a display */ if (Prompt) { filter_display_info (output, already_taken_care); for_gdb_only = False; already_taken_care = 0; deleteRest = False; } return; } } } /* remember what was the output length was output was matched */ already_taken_care = strlen(output); /* filter any line starting with \032\032 */ /* (PW)18NOV94: we have a problem with some system where the \032\032 comes in several times. In that case we might end-up showing ^Z^Z in dialog window. SO now do no test for end of line, and note that all following outputs are for gdb, not for the user. Here we assume that at least the double ^Z^Z is read in one piece. */ previous_for_gdb_only = for_gdb_only; p = strchr(string,'\032'); if (p && (*(p+1) == '\032') && (p == string || *(p-1) == '\n') /* && (p2 = strchr(p,'\n'))*/) { if ((p2 = strchr(p,'\n'))) { while ((*(p++) = *(++p2))); } else { *p = 0; } for_gdb_only = True; } if ((command_type == C_EXEC)||(command_type == C_FINISH)) { if (!previous_for_gdb_only) { AppendDialogText(string); } if (Prompt) { for_gdb_only = False; already_taken_care = 0; deleteRest = False; } return; } if (Prompt) { char *s; for_gdb_only = False; already_taken_care = 0; deleteRest = False; s = XtNewString(output); switch (command_type) { case C_DISPLAY: if (match(output_pattern, s, O_DISPLAY) != -1) strcpy(s, ""); break; case C_DISPLAY_INFO: /* (PW)7MAY91 : display error messages */ if (match(output_pattern, s, O_DISPLAY_INFO) != -1) { if (Token.mesg && strcmp(Token.mesg, "")) { AppendDialogText(Token.mesg); bell(0); } strcpy(s, ""); } break; case C_SEARCH: if (match(output_pattern, s, O_SEARCH) != -1) strcpy(s, ""); break; case C_LIST: /* (PW)22MAY91 : display messages ") */ if (match(output_pattern, s, O_LIST) != -1) { if (Token.mesg && strcmp(Token.mesg, "")) { AppendDialogText(Token.mesg); if (strstr(Token.mesg,"Source file is more recent than executable.")) bell(0); /* Warn user WYSIWYG not true */ } strcpy(s, ""); } break; case C_PRINT: if (PopupMode && /* if print goes in a window, don't display here */ (match(output_pattern, s, O_PRINT) != -1)) strcpy(s, ""); break; default: XtFree(s); s = XtNewString(string); /* append 'string' only */ break; } AppendDialogText(s); XtFree(s); } else /* no prompt yet */ { switch (command_type) { case C_DISPLAY: case C_DISPLAY_INFO: case C_SEARCH: case C_LIST: case C_PRINT: break; default: if (!previous_for_gdb_only) { AppendDialogText(string); } break; } } return; } /*--------------------------------------------------------------------------+ | | | Function to filter 'source' command | | | | input : command (from .gdbinit or source command or keyboard), | | echo is TRUE if source command must be echoed. | | | | output : TRUE if source command was recognized | | | | In case source command is recognized, it is executed here. | | | +--------------------------------------------------------------------------*/ int gdb_source_command(command,echo) char *command; int echo; { if (command && (match(command_pattern, command, C_SOURCE) != -1)) { if (echo) AppendDialogText(command); source_handler(); return TRUE; } return FALSE; } /*--------------------------------------------------------------------------+ | | | Function to filter 'define' & 'document' commands | | | | input : command (from .gdbinit or source command), | | fp = file pointer. | | | | output : TRUE if define or document command was recognized | | | | In case the command is recognized, it is executed here. | | | +--------------------------------------------------------------------------*/ static int command_sent = 0; /* flag gdb is busy : send no more command to gdb. */ int gdb_define_command(command,fp) char *command; FILE *fp; { char s[LINESIZ]; int error_cmd; int end_found; if ((command && (match(command_pattern, command, C_DEFINE) != -1)) || (command && (match(command_pattern, command, C_DOCUMENT) != -1))) { 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 : "Redefine command \"%s\"? " "Really redefine built-in command \"%s\"? " gdb could display "Type commands for definition of \"%s\".\n" "End with a line saying just \"end\" or "Type documentation for \"%s\".\n" "End with a line saying just \"end\".\n" or "Command \"%s\" is built-in." */ error_cmd = FALSE; /* read message from gdb */ while (1) if (fgets(s, LINESIZ, dbxfp)) { if (debug) fprintf(stderr, "=>%s", s); if (strstr(s," is built-in.")) /* error for document of built-in command */ { AppendDialogText(s); error_cmd = TRUE; bell(0); break; } if (strstr(s,"Redefine command ") || strstr(s,"Really redefine built-in command ")) write_dbx ("y\n"); /* answer to question if any */ else { if (strcmp(s,"End with a line saying just \"end\".\n") == 0) break; } } /* write command definition */ end_found = FALSE; while (fgets (s, LINESIZ, fp)) { if (!error_cmd) { AppendDialogText(s); write_dbx (s); } if (match(command_pattern, s, C_END) != -1) { end_found = TRUE; break; } } if ((!error_cmd) && (!end_found)) { AppendDialogText("Error : missing \"end\" in file.\n"); bell(0); write_dbx ("end\n"); } 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; } return FALSE; } #ifndef NO_MY_FGETS /* * cope with non-blocking I/O correctly * ie: exit if child closes pty, but return if would block. * * This function seems to fail on some systems (??) * */ static char * #ifdef __STDC__ my_fgets(char *buf, int size, FILE *f) #else my_fgets(buf, size, f) char *buf; int size; FILE *f; #endif { char *orig_buf = buf; while(size > 1) { int cc; cc = read(fileno(f), buf, 1); if(cc == -1) { if(errno == EAGAIN || errno == EWOULDBLOCK) { break; } perror("read from gdb"); exit(1); /*NOTREACHED*/ } if(cc == 0) { #ifdef READ_ZERO_NOT_EOF /* for RS6000 */ break; #else (void) fprintf(stderr, "EOF from gdb\n"); exit(1); #endif /*NOTREACHED*/ } buf++; size--; if(*(buf-1) == '\n') break; } *buf = '\0'; if (buf == orig_buf) { return NULL; } else { return(orig_buf); } } #endif /* NO_MY_FGETS */ /*--------------------------------------------------------------------------+ | | | 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 *prompt_pointer; char s[LINESIZ]; int before_prompt; Boolean more; Boolean local_prompt; parse_flags = flags; /* just remember flags for read_dbx() */ more = True; Prompt = False; local_prompt = False; while (more) { /* keep reading until no more or until prompt arrives */ #ifdef NO_MY_FGETS while ((more = (fgets(s, LINESIZ, dbxfp) != NULL))) #else while ((more = (my_fgets(s, LINESIZ, dbxfp) != NULL))) #endif { if (debug) fprintf(stderr, "=>%s", s); /* new gdb might add '>' characters in front of input for define commands, we have to test for them here ! */ /* receive prompt? */ #if 1 /* (PW)16NOV94 : new gdb might add '>' characters in front of input when defining commands, we have to test for them here ! so use strstr() to catch all prompts... */ if ((prompt_pointer = strstr(s, dbxprompt)) != NULL) #else if (strncmp(s, dbxprompt, strlen(dbxprompt)) == 0) #endif { Prompt = True; local_prompt = True; before_prompt = prompt_pointer - s; /* more stuff behind prompt? */ if (s[before_prompt+ strlen(dbxprompt)]) { /* remember it */ next_string = XtNewString(s+before_prompt+strlen(dbxprompt)); } /* destroy contents */ strcpy(s, ""); if (debug) fprintf(stderr, " Prompt detected\n"); } string = concat(string, s); strcpy(s, ""); if (local_prompt) { /* do not read next line if prompt is found */ break; } } output = concat(output, string); command = get_command(); /* read queue's top command */ if (flags & FILTER_ON) { filter (string, output, command); } if ((flags & ECHO_ON) && local_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) && local_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 (local_prompt) { delete_command(); /* remove top command from queue */ if (command && command_sent) command_sent--; XtFree(output); output = NULL; local_prompt = False; } } } /*--------------------------------------------------------------------------+ | * | | * 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. | | * | +--------------------------------------------------------------------------*/ static volatile int in_read_dbx; /* ARGSUSED */ void read_dbx(master, source, id) XtPointer master; int *source; XtInputId *id; { if (in_read_dbx++) /* already running */ return; do { read_gdb (parse_flags); /* do not write any more command, if prompt was not seen yet */ if (Prompt) { write_dbx_available (); } } while (--in_read_dbx); } /*--------------------------------------------------------------------------+ | | | 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_ON | FILTER_OFF); return; } if (xxgdb_command (command, FALSE)) { delete_command(); /* remove xxgdb command from top of queue */ command_sent--; /* tell gdb to send its prompt */ query_gdb(" \n", PARSE_OFF | ECHO_ON | 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; } } } /*--------------------------------------------------------------------------+ | | | Function to filter xxgdb only commands | | | | input : command (from .gdbinit or source command or keyboard), | | echo is TRUE if source command must be echoed. | | | | output : TRUE if source command was recognized | | | | In case source command is recognized, it is executed here. | | | +--------------------------------------------------------------------------*/ int xxgdb_command (command, echo) char *command; int echo; { #ifdef CREATE_IO_WINDOW if (command && (!strcmp(command,"iowin\n"))) /* test for 'iowin' command */ { if (echo) AppendDialogText(command); if (!iowinpid) { char ttycommand[50]; create_io_window (); sprintf (ttycommand, "tty %s\n", iowintty); query_gdb (ttycommand, PARSE_OFF | ECHO_OFF | FILTER_OFF); } return TRUE; } #endif /* CREATE_IO_WINDOW */ return FALSE; } xxgdb-1.12.orig/XDbx.NEW_INTERFACE100644 1012 1010 5544 6224427511 15252 0ustar geyerAlgebra! ! XXgdb 1.08 Application defaults file with NEW_INTERFACE ! (derived from Xdbx 2.1 app-defaults) *background: snow1 *foreground: black *fileWindow*background: snow2 *messageWindow.background: snow2 *commandWindow.background: snow2 *Scrollbar.foreground: black XDbx.geometry: +0+0 *allowShellResize: True *borderWidth: 1 *font: fixed *vpane.width: 550 *fileWindow*font: variable *fileLabel.width: 500 *lineLabel.width: 50 *sourceShell.geometry: 550x260+0+380 *sourceForm.top: ChainTop *sourceForm.bottom: ChainBottom *sourceForm.left: ChainLeft *sourceForm.right: ChainRight *sourceForm.fromVert: fileWindow *sourceWindow.width: 558 *sourceWindow.height: 220 *sourceWindow.leftMargin: 35 *sourceWindow.scrollHorizontal: whenNeeded *sourceWindow.translations: #override \n\ : SelectStart() SelectWord() \n\ Shift: Update(warp) SelectEnd() PrintSelection() \n\ : Update(warp) SelectEnd() \n\ Down: next-line() Update()\n\ Up: previous-line() Update() \n\ CtrlL: redraw-display() Update() \n\ CtrlN: next-line() Update() \n\ CtrlP: previous-line() Update() \n\ CtrlV: next-page() Update() \n\ CtrlZ: scroll-one-line-up() Update() \n\ MetaV: previous-page() Update() \n\ MetaZ: scroll-one-line-down() Update() \n\ :Meta\>: end-of-file() Update() \n\ :Meta]: forward-paragraph() Update() \n\ :Meta[: backward-paragraph() Update() *messageWindow*font: variable *messageWindow.min: 30 *messageWindow.max: 30 *dialogWindow.preferredPaneSize: 240 *dialogWindow.resizeToPreferred: True *dialogWindow.translations: #override \n\ : SelectStart() SelectWord() \n\ Shift: SelectEnd() PrintSelection() \n\ : SelectEnd() \n *commandShell.geometry: 190x370+590+0 *commandWindow.hSpace: 6 *commandWindow.vSpace: 6 *Command.height: 20 *Command.width: 80 *List.columnSpacing: 10 *displayShell.geometry: +590+450 *displayWindow.top: ChainTop *displayWindow.bottom: ChainBottom *displayWindow.left: ChainLeft *displayWindow.right: ChainRight *displayWindow.width: 300 *displayWindow.height: 100 *displayWindow.scrollVertical: whenNeeded *displayWindow.scrollHorizontal: whenNeeded *displayWindow.translations: #override \n\ : SelectStart() SelectWord() \n\ Shift: SelectEnd() PrintSelection() \n\ : SelectEnd() \n *popup*showGrip: False *bindings: emacs