v03i055: x interface to dbx, Part03/03
Mike Wexler
mikew at wyse.wyse.com
Wed Mar 15 08:01:15 AEST 1989
Submitted-by: po at volta.ece.utexas.edu (Po Ling Cheung)
Posting-number: Volume 3, Issue 55
Archive-name: xdbx/part03
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 3 (of 3)."
# Contents: AUTHOR Imakefile Makefile arrow.bits bsd_regex.h calldbx.c
# dbx.c defs.h make.out parser.c signals.c stop.bits sun_regex.h
# updown.bits utils.c windows.c xdbx.c
# Wrapped by mikew at wyse on Tue Mar 14 13:59:01 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'AUTHOR' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'AUTHOR'\"
else
echo shar: Extracting \"'AUTHOR'\" \(987 characters\)
sed "s/^X//" >'AUTHOR' <<'END_OF_FILE'
X(Message inbox:1270)
XReturn-Path: po at volta.ece.utexas.edu
XReceived: by wyse.wyse.com (5.58/Wyse master/5-13-88)
X id AA17465; Sat, 11 Mar 89 14:04:16 PST
XReceived: from cs.utexas.edu by uunet.UU.NET (5.61/1.14) with SMTP
X id AA04684; Fri, 10 Mar 89 16:38:18 -0500
XPosted-Date: Fri, 10 Mar 89 15:35:42 CST
XReceived: from volta.ece.utexas.edu by cs.utexas.edu (5.59/1.25)
X id AA01288; Fri, 10 Mar 89 15:37:33 CST
XReceived: by volta.ece.utexas.edu (3.2/9.4),
X id AA11938; Fri, 10 Mar 89 15:35:42 CST
XDate: Fri, 10 Mar 89 15:35:42 CST
XFrom: po at volta.ece.utexas.edu (Po Ling Cheung)
XMessage-Id: <8903102135.AA11938 at volta.ece.utexas.edu>
XTo: x-sources at wyse.com
XSubject: xdbx - window interface to dbx (part 1 of 4)
X
X
XEnclosed is the source for xdbx, an X Window System interface to the
Xdbx debugger.
XWould you please send me a note when you post the source in comp.sources.x
X(because I will not be reading comp.sources.x everyday) ?
X
XThank you.
X
XPo Cheung
XUniversity of Texas at Austin
X
X
END_OF_FILE
if test 987 -ne `wc -c <'AUTHOR'`; then
echo shar: \"'AUTHOR'\" unpacked with wrong size!
fi
# end of 'AUTHOR'
fi
if test -f 'Imakefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(457 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
X#ifdef VaxArchitecture
X DEFINES = -DBSD /* Berkeley dbx */
X#endif
X
XLOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X
X SRCS = calldbx.c command.c dbx.c dialog.c handler.c parser.c \
X regex.c signs.c signals.c source.c utils.c windows.c xdbx.c
X
X OBJS = calldbx.o command.o dbx.o dialog.o handler.o parser.o \
X regex.o signs.o signals.o source.o utils.o windows.o xdbx.o
X
XComplexProgramTarget(xdbx)
XInstallAppDefaults(XDbx)
END_OF_FILE
if test 457 -ne `wc -c <'Imakefile'`; then
echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(6760 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space. Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# X Window System Makefile generated from template file Imake.tmpl
X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
X#
X# Do not change the body of the imake template file. Server-specific
X# parameters may be set in the appropriate .macros file; site-specific
X# parameters (but shared by all servers) may be set in site.def. If you
X# make any changes, you'll need to rebuild the makefiles using
X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
X# the top level directory.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit Sun.macros to change
X
X# platform: $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
X# operating system: SunOS 3.4
X
XBOOTSTRAPCFLAGS =
X AS = as
X CC = cc
X CPP = /lib/cpp
X LD = ld
X LINT = lint
X INSTALL = install
X TAGS = ctags
X RM = rm -f
X MV = mv
X LN = ln -s
X RANLIB = ranlib
XRANLIBINSTFLAGS = -t
X AR = ar clq
X LS = ls
X LINTOPTS = -xz
X LINTLIBFLAG = -C
X MAKE = make
XSTD_CPP_DEFINES =
X STD_DEFINES =
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site: $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
X
X###########################################################################
X# definitions common to all Makefiles - do not edit
X
X SHELL = /bin/sh
X
X DESTDIR = /global
X USRLIBDIR = $(DESTDIR)/lib
X BINDIR = $(DESTDIR)/bin/X11
X INCDIR = $(DESTDIR)/include
X ADMDIR = $(DESTDIR)/usr/adm
X LIBDIR = $(USRLIBDIR)/X11
X LINTLIBDIR = $(USRLIBDIR)/lint
X FONTDIR = $(LIBDIR)/fonts
X XINITDIR = $(LIBDIR)/xinit
X XDMDIR = $(LIBDIR)/xdm
X UWMDIR = $(LIBDIR)/uwm
X AWMDIR = $(LIBDIR)/awm
X TWMDIR = $(LIBDIR)/twm
X DTDIR = $(LIBDIR)/dt
X MANPATH = /usr/man
X MANSOURCEPATH = $(MANPATH)/man
X MANDIR = $(MANSOURCEPATH)n
X LIBMANDIR = $(MANSOURCEPATH)n3
X XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X INSTBINFLAGS = -m 0755
X INSTUIDFLAGS = -m 4755
X INSTLIBFLAGS = -m 0664
X INSTINCFLAGS = -m 0444
X INSTMANFLAGS = -m 0444
X INSTAPPFLAGS = -m 0444
X INSTKMEMFLAGS = -m 4755
X FCFLAGS = -t
X CDEBUGFLAGS = -O
X
X PATHSEP = /
X DEPEND = $(BINDIR)/makedepend
X IMAKE = $(BINDIR)/imake
X RGB = $(LIBDIR)/rgb
X FC = $(BINDIR)/bdftosnf
X MKFONTDIR = $(BINDIR)/mkfontdir
X MKDIRHIER = $(BINDIR)/mkdirhier.sh
X
X CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X LDFLAGS = $(CDEBUGFLAGS) -L$(USRLIBDIR) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X
X IRULESRC = $(LIBDIR)/imake.includes
X
X EXTENSIONLIB = $(USRLIBDIR)/libext.a
X XLIB = $(USRLIBDIR)/libX11.a
X XMULIB = $(USRLIBDIR)/libXmu.a
X OLDXLIB = $(USRLIBDIR)/liboldX.a
X XTOOLLIB = $(USRLIBDIR)/libXt.a
X XAWLIB = $(USRLIBDIR)/libXaw.a
X LINTXLIB = $(USRLIBDIR)/lint/llib-lX11.ln
X LINTXMU = $(USRLIBDIR)/lint/llib-lXmu.ln
X LINTXTOOL = $(USRLIBDIR)/lint/llib-lXt.ln
X LINTXAW = $(USRLIBDIR)/lint/llib-lXaw.ln
X INCLUDES = -I$(INCDIR)
X MACROFILE = Sun.macros
X ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
X $(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
X IMAKE_DEFINES =
X IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
X -s Makefile $(IMAKE_DEFINES)
X RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X .emacs_* tags TAGS make.log MakeOut
X
X###########################################################################
X# rules: $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
XLOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X
X SRCS = calldbx.c command.c dbx.c dialog.c handler.c parser.c \
X regex.c signs.c signals.c source.c utils.c windows.c xdbx.c
X
X OBJS = calldbx.o command.o dbx.o dialog.o handler.o parser.o \
X regex.o signs.o signals.o source.o utils.o windows.o xdbx.o
X
X PROGRAM = xdbx
X
Xall:: xdbx
X
Xxdbx: $(OBJS) $(LOCAL_LIBRARIES)
X $(RM) $@
X $(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
X
Xrelink::
X $(RM) $(PROGRAM)
X $(MAKE) $(MFLAGS) $(PROGRAM)
X
Xinstall:: xdbx
X $(INSTALL) -c $(INSTALLFLAGS) xdbx $(BINDIR)
X
Xinstall.man:: xdbx.man
X $(INSTALL) -c $(INSTMANFLAGS) xdbx.man $(MANDIR)/xdbx.n
X
Xdepend:: $(DEPEND)
X
Xdepend::
X $(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND):
X @echo "making $@"; \
X cd $(DEPENDSRC); $(MAKE)
X
Xclean::
X $(RM) $(PROGRAM)
X
Xinstall:: XDbx.ad
X $(INSTALL) -c $(INSTAPPFLAGS) XDbx.ad $(XAPPLOADDIR)/XDbx
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X $(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X $(IRULESRC)/Imake.tmpl \
X $(IRULESRC)/Imake.rules \
X $(IRULESRC)/site.def \
X $(IRULESRC)/$(MACROFILE)
X - at if [ -f Makefile ]; then \
X echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X else exit 0; fi
X $(IMAKE_CMD) -DTOPDIR=$(TOP)
X
X$(IMAKE):
X @echo "making $@"; \
X cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
X
Xtags::
X $(TAGS) -w *.[ch]
X $(TAGS) -xw *.[ch] > TAGS
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X @echo "install done"
X
Xinstall.man::
X @echo "install.man done"
X
XMakefiles::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_FILE
if test 6760 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'arrow.bits' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'arrow.bits'\"
else
echo shar: Extracting \"'arrow.bits'\" \(324 characters\)
sed "s/^X//" >'arrow.bits' <<'END_OF_FILE'
X#define arrow_width 16
X#define arrow_height 16
X#define arrow_x_hot -1
X#define arrow_y_hot -1
Xstatic char arrow_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x01, 0x80, 0x03,
X 0xff, 0x07, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x07, 0x80, 0x03, 0x80, 0x01,
X 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
END_OF_FILE
if test 324 -ne `wc -c <'arrow.bits'`; then
echo shar: \"'arrow.bits'\" unpacked with wrong size!
fi
# end of 'arrow.bits'
fi
if test -f 'bsd_regex.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bsd_regex.h'\"
else
echo shar: Extracting \"'bsd_regex.h'\" \(3267 characters\)
sed "s/^X//" >'bsd_regex.h' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X/*
X * Regular expression pattern matching
X *
X * The reg_token array indicates the register no. for each token type.
X * reg_token[0] : message
X * reg_token[1] : stop number
X * reg_token[2] : function name
X * reg_token[3] : line number
X * reg_token[4] : file name
X */
X
X#define BRACKET "[%d]"
X
X#define TK_MESG 0
X#define TK_STOP 1
X#define TK_FUNC 2
X#define TK_LINE 3
X#define TK_FILE 4
X
X#define O_EXEC 0
X#define O_DONE 1
X#define O_STOPAT 2
X#define O_STOPIN 3
X#define O_UPDOWN 4
X#define O_BELL 5
X#define O_LIST 6
X
X#define C_EXEC 0
X#define C_STOPAT 1
X#define C_STOPIN 2
X#define C_UPDOWN 3
X#define C_DELETE 4
X#define C_FUNC 5
X#define C_FILE 6
X#define C_DEBUG 7
X#define C_CD 8
X
X
Xstatic PatternRec output_pattern[] = {
X /* exec */
X {"\\(.*\n\\)*\\(\[[0-9]+\] \\)?\\(\\(stopped\\|Bus error\\|Segmentation \
Xfault\\|Interrupt\\) in \\([^ ]+\\) at line \
X\\([0-9]+\\)\\( in file \"\\([^ ]+\\)\"\\)?\\)\n",
X NULL,
X {3, -1, 5, 6, 8}
X },
X /* done */
X {"\\(.*\n\\)*execution completed",
X NULL,
X {-1, -1, -1, -1, -1}
X },
X /* stop at */
X {"\\[\\([0-9]+\\)\\] stop at \\(\"\\([^ ]+\\)\":\\)?\\([0-9]+\\)\n",
X NULL,
X {-1, 1, -1, 4, 3}
X },
X /* stop in */
X {"\\[\\([0-9]+\\)\\] stop in \\([^ ]+\\)\n",
X NULL,
X {-1, 1, 2, -1, -1}
X },
X /* updown */
X {"\\([^ ]+\\)(.*), line \\([0-9]+\\) in \"\\([^ ]+\\)\"\n",
X NULL,
X {-1, -1, 1, 2, 3}
X },
X /* bell */
X {"\\(not that many levels\n\\|can't continue execution\n\\)",
X NULL,
X {-1, -1, -1, -1, -1}
X },
X /* list */
X {"\\([ ]*[0-9]+.*\n\\)*[ ]+\\([0-9]+\\)[ ]+{.*\n",
X NULL,
X {-1, -1, -1, 2, -1}
X },
X NULL
X};
X
Xstatic PatternRec command_pattern[] = {
X {"[ ]*\\(run\\|cont\\|next\\|step\\).*\n", NULL, {-1, -1, -1, -1, -1}},
X {"[ ]*stop[ ]+at[ ]+[0-9]+.*\n", NULL, {-1, -1, -1, -1, -1}},
X {"[ ]*stop[ ]+in[ ]+.*\n", NULL, {-1, -1, -1, -1, -1}},
X {"[ ]*\\(up\\|down\\).*\n", NULL, {-1, -1, -1, -1, -1}},
X {"[ ]*delete.*\n", NULL, {-1, -1, -1, 1, -1}},
X {"[ ]*func[ ]*\\([^ ]+\\)[ ]*\n", NULL, {-1, -1, 1, -1, -1}},
X {"[ ]*file[ ]*\\([^ ]+\\)[ ]*\n", NULL, {-1, -1, -1, -1, 1}},
X NULL
X};
END_OF_FILE
if test 3267 -ne `wc -c <'bsd_regex.h'`; then
echo shar: \"'bsd_regex.h'\" unpacked with wrong size!
fi
# end of 'bsd_regex.h'
fi
if test -f 'calldbx.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'calldbx.c'\"
else
echo shar: Extracting \"'calldbx.c'\" \(3261 characters\)
sed "s/^X//" >'calldbx.c' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X#include <sys/ioctl.h>
X#include "global.h"
X
XFILE *dbxfp = NULL; /* file pointer to dbx */
Xint dbxpid; /* dbx process id */
Xint dbxInputId; /* dbx input id */
X
Xstatic char *pty = "/dev/pty??"; /* master side of pseudo-terminal */
Xstatic char *tty = "/dev/tty??"; /* slave side of pseudo-terminal */
X
X/*
X * Xdbx talks to dbx through a pseudo terminal which is a pair of master
X * and slave devices: /dev/pty?? and /dev/tty??, where ?? goes from p0 to
X * qf (system dependent). The pty is opened for both read and write.
X */
Xstatic int openMaster()
X{
X int i, master;
X char c;
X
X for (c='p'; c<='q'; c++) {
X pty[8] = c;
X for (i=0; i<16; i++) {
X pty[9] = "0123456789abcdef"[i];
X if ((master = open(pty, O_RDWR)) != -1)
X return (master);
X }
X }
X fprintf(stderr, "xdbx: all ptys in use: ptyp0 - ptyqf\n");
X exit(1);
X}
X
Xstatic int openSlave()
X{
X int slave;
X
X tty[8] = pty[8];
X tty[9] = pty[9];
X if ((slave = open(tty, O_RDWR)) != -1) {
X return (slave);
X }
X else {
X fprintf(stderr, "open: cannot open slave pty %s", tty);
X exit(1);
X }
X}
X
X/* ARGSUSED */
Xvoid calldbx(argc, argv)
Xint argc;
Xchar *argv[];
X{
X int master; /* file descriptor of master pty */
X int slave; /* file descriptor to slave pty */
X int n = 0;
X
X master = openMaster();
X slave = openSlave();
X
X#ifndef BSD
X ioctl(master, TIOCPKT, &n); /* disable packet mode */
X#endif
X
X dbxpid = fork();
X if (dbxpid == -1) {
X perror("Cannot fork dbx process");
X exit(1);
X }
X else if (dbxpid) {
X /*
X * Parent : close the slave side of pty
X * close stdin and stdout
X * set the dbx file descriptor to nonblocking mode
X * open file pointer with read/write access to dbx
X * set unbuffered mode
X * register dbx input with X
X */
X close(slave);
X close(0);
X close(1);
X fcntl(master, F_SETFL, FNDELAY);
X dbxfp = fdopen(master, "r+");
X setbuf(dbxfp, NULL);
X dbxInputId = XtAddInput(master, XtInputReadMask, readDbx, NULL);
X }
X else {
X /*
X * Child : close master side of pty
X * redirect stdin, stdout, stderr of dbx to pty
X * unbuffer output data from dbx
X * exec dbx with arguments
X */
X close(master);
X dup2(slave, 0);
X dup2(slave, 1);
X dup2(slave, 2);
X if (slave > 2)
X close(slave);
X fcntl(1, F_SETFL, FAPPEND);
X setbuf(stdout, NULL);
X argv[0] = "dbx";
X execvp("dbx", argv);
X perror("Cannot call dbx");
X exit(1);
X }
X}
END_OF_FILE
if test 3261 -ne `wc -c <'calldbx.c'`; then
echo shar: \"'calldbx.c'\" unpacked with wrong size!
fi
# end of 'calldbx.c'
fi
if test -f 'dbx.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dbx.c'\"
else
echo shar: Extracting \"'dbx.c'\" \(3469 characters\)
sed "s/^X//" >'dbx.c' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X#include "global.h"
X
XBoolean EnterCommand; /* To differntiate between xdbx command
X input and debugged program input */
Xstatic char *output = NULL; /* buffer for dbx output */
Xstatic int outputsize = 0; /* size of buffer */
Xstatic Boolean continueFlag; /* read flag for dbxinit commands */
X
Xstatic void Dbxinit(fp)
XFILE *fp;
X{
X char s[LINESIZ];
X
X while (fgets(s, LINESIZ, fp)) {
X strcpy(Command, s);
X AppendDialogText(Command);
X writeDbx(Command);
X continueFlag = TRUE;
X while (continueFlag)
X readDbx();
X }
X close(fp);
X}
X
X/*
X * Called only once to display the source file, if any, right after
X * xdbx is started up.
X */
Xvoid DisplayInit()
X{
X FILE *fp;
X char *path;
X
X displayedFile = LoadFile(QueryFile());
X UpdateMessageWindow("Ready for execution");
X if (fp = fopen(xdbxinit, "r")) {
X if (displayedFile)
X Dbxinit(fp);
X if (Homedir)
X rename(xdbxinit, "~/.dbxinit");
X else
X rename(xdbxinit, ".dbxinit");
X }
X}
X
X/*
X * This is a callback procedure invoked everytime input is pending
X * on the file descriptor to dbx.
X * It reads all the data available on the descriptor line by line
X * into 'string', and write it to the dialog window.
X * Once the dbx prompt is read in, it calls parse() to take appropriate
X * action.
X */
XXtInputCallbackProc readDbx(client_data, source, id)
Xcaddr_t client_data;
Xint *source;
XXtInputId *id;
X{
X char s[LINESIZ], *string;
X int stringsize;
X static Boolean initialFlag = TRUE,
X displayFlag = FALSE;
X
X /* allocate one block to 'output' to begin with */
X if (outputsize == 0) {
X outputsize = BUFSIZ;
X output = XtMalloc(outputsize);
X strcpy(output, "");
X }
X stringsize = BUFSIZ;
X string = XtMalloc(stringsize);
X strcpy(string, "");
X while (fgets(s, LINESIZ, dbxfp)) {
X /* if no echo mode, do not write output to dialog window */
X if (Echo == FALSE) continue;
X EnterCommand = FALSE;
X if (strcmp(s, "(dbx) ")) {
X if (strlen(string) + strlen(s) > stringsize) {
X string = XtRealloc(string, stringsize + BUFSIZ);
X stringsize += BUFSIZ;
X }
X strcat(string, s);
X if (strlen(output) + strlen(s) > outputsize) {
X output = XtRealloc(output, outputsize + BUFSIZ);
X outputsize += BUFSIZ;
X }
X strcat(output, s);
X }
X else {
X parse(output);
X strcpy(output, "");
X strcpy(s, "");
X strcat(string, PROMPT);
X EnterCommand = TRUE;
X continueFlag = FALSE;
X if (initialFlag) {
X initialFlag = FALSE;
X displayFlag = TRUE;
X }
X }
X }
X filter(string);
X AppendDialogText(string);
X if (displayFlag) {
X displayFlag = FALSE;
X DisplayInit();
X }
X}
END_OF_FILE
if test 3469 -ne `wc -c <'dbx.c'`; then
echo shar: \"'dbx.c'\" unpacked with wrong size!
fi
# end of 'dbx.c'
fi
if test -f 'defs.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'defs.h'\"
else
echo shar: Extracting \"'defs.h'\" \(5435 characters\)
sed "s/^X//" >'defs.h' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X#include <stdio.h>
X#include <X11/Xos.h>
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X#include <X11/Cardinals.h>
X#include <X11/Xatom.h>
X#include <X11/Shell.h>
X#include <X11/VPaned.h>
X#include <X11/Form.h>
X#include <X11/AsciiText.h>
X#include <X11/TextP.h>
X#include <X11/Box.h>
X#include <X11/List.h>
X#include <X11/Command.h>
X#include <X11/Label.h>
X
X#define MIN(a,b) ((a)<(b) ? (a) : (b))
X#define MAX(a,b) ((a)>(b) ? (a) : (b))
X
X#define DIALOGSIZE 10000 /* max size of dialog window buffer */
X#define LINESIZ 200 /* input line length */
X#define MAXNAME 30 /* max identifier length */
X#define MAXARGS 10 /* max number of args */
X#define MAXFILES 256 /* max number of files in fileTable */
X#define MAXSTOPS 256 /* max number of stops */
X#define MAXSIGNS 100 /* max number of signs */
X#define OFFSET 2 /* offset for adjusting sign position */
X#define CHARS_PER_LINE 20 /* estimated number of chars per line */
X#define ADD_LINES 50 /* # of lines to be added in realloc */
X#define PROMPT "(xdbx) " /* xdbx prompt string */
X#define TITLE "xdbx 1.0" /* xdbx title string */
X#define CANCEL "<Cancel>" /* string for file menu */
X#define DELIMITERS " !%^&*()+=~|;:{},/#<?\"\n\t"
X
X
Xtypedef int Line;
X
X#ifdef sparc
Xtypedef struct dirent Directory;
X#else
Xtypedef struct direct Directory;
X#endif
X
Xtypedef struct {
X Dimension shellWidth; /* xdbx window width */
X Dimension lineLabelWidth; /* line label width */
X Dimension sourceHeight; /* source window height */
X Dimension leftMargin; /* left margin of source window */
X Dimension dialogHeight; /* dialog window height */
X Dimension dialogMinHeight; /* dialog window minimum height */
X Dimension messageHeight; /* message window height */
X Dimension buttonWidth; /* command button width */
X Dimension commandHSpace; /* command horizontal spacing */
X Dimension commandVSpace; /* command vertical spacing */
X Dimension commandMinHeight; /* source window height */
X Dimension commandMaxHeight; /* source window height */
X Dimension columnSpacing; /* file menu column spacing */
X int filesPerColumn; /* number of files per column in file menu */
X Boolean noTitleBar; /* xdbx option : title bar */
X Pixel stopForeground; /* foreground color of stop sign */
X Pixel arrowForeground; /* foreground color of arrow sign */
X Pixel updownForeground; /* foreground color of updown sign */
X
X Boolean dbxopt_r; /* dbx option -r */
X Boolean dbxopt_i; /* dbx option -i */
X String includeDir; /* dbx option -I includeDir */
X Boolean dbxopt_k; /* dbx option -k */
X String cfile; /* Berkeley dbx option -c file */
X Boolean dbxopt_kbd; /* SunOS 3.4 dbx option -kbd */
X int fcount; /* SunOS 4.0 dbx option -f fcount */
X String startup; /* SunOS 4.0 dbx option -s startup */
X String tstartup; /* SunOS 4.0 dbx option -sr tstartup */
X} XdbxResources;
X
Xtypedef struct {
X char *filename; /* name of file on display */
X char funcname[MAXNAME]; /* current function */
X char *buf; /* buffer holding source file */
X long filesize; /* size of file in bytes */
X Line lines; /* # of lines on display */
X Line currentline; /* line where caret is */
X Line topline; /* top line number in the window */
X Line bottomline; /* bottom line number in window */
X Line lastline; /* number of lines in source file */
X XtTextPosition topPosition; /* top display position of buffer */
X XtTextPosition *linepos; /* array of text pos for each newline */
X} FileRec, *FileRecPtr;
X
X
Xtypedef struct {
X char *mesg; /* part of matched string */
X unsigned stop; /* stop number */
X char *func; /* function name */
X unsigned line; /* line number */
X char *file; /* file name */
X} Tokens;
X
X#define NTOKENS 5 /* number of tokens */
X
Xtypedef struct {
X char *pat; /* regular expression */
X struct re_pattern_buffer *buf; /* buffer for compile regex */
X int reg_token[NTOKENS]; /* register number */
X} PatternRec, *PatternRecPtr;
X
X
Xtypedef struct {
X Cardinal i; /* index to arrowsign[] */
X char filename[MAXNAME]; /* filename associated with */
X Line line; /* line number */
X} Arrow;
X
Xtypedef struct {
X Cardinal i; /* index to updownsign[] */
X char filename[MAXNAME]; /* filename associated with */
X Line line; /* line number */
X} Updown;
X
Xtypedef struct {
X char *filename; /* filename associated with */
X Line line; /* line number of stop */
X unsigned tag; /* used in deleting stops */
X} Stops;
END_OF_FILE
if test 5435 -ne `wc -c <'defs.h'`; then
echo shar: \"'defs.h'\" unpacked with wrong size!
fi
# end of 'defs.h'
fi
if test -f 'make.out' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'make.out'\"
else
echo shar: Extracting \"'make.out'\" \(37 characters\)
sed "s/^X//" >'make.out' <<'END_OF_FILE'
XMake: line 140: syntax error. Stop.
END_OF_FILE
if test 37 -ne `wc -c <'make.out'`; then
echo shar: \"'make.out'\" unpacked with wrong size!
fi
# end of 'make.out'
fi
if test -f 'parser.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'parser.c'\"
else
echo shar: Extracting \"'parser.c'\" \(6748 characters\)
sed "s/^X//" >'parser.c' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X#include "global.h"
X#include "regex.h"
X
X#ifdef BSD
X#include "bsd_regex.h"
X#else
X#include "sun_regex.h"
X#endif
X
X#define BYTEWIDTH 8
X#define RE_BUFFER 100
X
XTokens token; /* token structure */
X
X/*
X * Compile all the regular expression patterns in a pattern table.
X * A pattern table is an array of pattern records.
X * Each pattern record consists of a regular
X * expression, a buffer for the to-be-compiled regular expression,
X * and an array to associate a given token with a matched register number.
X */
Xstatic void compile(patternTable)
XPatternRec *patternTable;
X{
X PatternRec *p;
X char fastmap[(1 << BYTEWIDTH)];
X int i;
X
X for (i=0; patternTable[i].pat; i++) {
X p = &patternTable[i];
X p->buf = (struct re_pattern_buffer *)
X XtMalloc (sizeof (struct re_pattern_buffer));
X p->buf->allocated = RE_BUFFER;
X p->buf->buffer = (char *) XtMalloc (p->buf->allocated);
X p->buf->fastmap = fastmap;
X p->buf->translate = NULL;
X re_compile_pattern(p->pat, strlen(p->pat), p->buf);
X re_compile_fastmap(p->buf);
X }
X}
X
X/*
X * This routine tries to match a given string with each regular
X * expression in a given pattern table. The best match is found, and
X * the function returns an index to the pattern table.
X */
Xstatic int match(patternTable, string)
X PatternRec *patternTable;
X char *string;
X{
X struct re_registers regs;
X int m, bestmatch = -1, index = -1, i, j, r, start, n;
X char *s;
X
X if (strcmp(string, "") == NULL) return -1;
X for (i=0; patternTable[i].pat; i++) {
X m = re_match(patternTable[i].buf, string, strlen(string), 0, ®s);
X if (m > bestmatch) {
X bestmatch = m;
X index = i;
X token.mesg = token.file = token.func = NULL;
X token.line = token.stop = 0;
X for (j=0; j<NTOKENS; j++) {
X if ((r = patternTable[i].reg_token[j]) >= 0) {
X start = regs.start[r];
X if ((n = regs.end[r] - start) > 0) {
X s = (char *) XtMalloc ((n+1) * sizeof(char));
X strncpy(s, string+start, n);
X s[n] = '\0';
X switch (j) {
X case 0: token.mesg = s; break;
X case 1: token.stop = atoi(s); XtFree(s); break;
X case 2: token.func = s; break;
X case 3: token.line = atoi(s); XtFree(s); break;
X case 4: token.file = s; break;
X }
X }
X }
X }
X }
X }
X return index;
X}
X
X/* PUBLIC ROUTINES */
X
X/* Compile the regular expressions in the output and command pattern tables. */
X
Xvoid parser_init()
X{
X compile(output_pattern);
X compile(command_pattern);
X}
X
X
X/* This routine first parses the command string.
X * If the command is one of run, cont, next, step, stop at, stop in,
X * where, up, or down, it parses the dbx output to decide what action
X * to take and dispatch it to one of the handlers.
X * For other commands, the appropriate handler is called.
X */
Xvoid parse(output)
Xchar *output;
X{
X int handler, command_flag;
X
X command_flag = match(command_pattern, Command);
X switch (command_flag) {
X case C_EXEC:
X case C_STOPAT:
X case C_STOPIN:
X case C_UPDOWN:
X handler = match(output_pattern, output);
X switch (handler) {
X case O_EXEC : exec_handler(&token, FALSE); break;
X case O_DONE : exec_handler(&token, TRUE); break;
X case O_STOPAT: stop_at_handler(&token); break;
X case O_STOPIN: stop_in_handler(&token); break;
X case O_UPDOWN: updown_handler(&token); break;
X case O_BELL : Bell(0); break;
X }
X break;
X case C_DELETE:
X delete_handler();
X break;
X case C_FUNC:
X if (strcmp(output, "") == NULL)
X func_handler(&token);
X break;
X case C_FILE:
X file_handler(&token);
X break;
X case C_DEBUG:
X debug_handler();
X break;
X case C_CD:
X if (strcmp(output, "") == NULL)
X cd_handler();
X break;
X }
X}
X
X
X/* This function edits the dbx output so that unnecessary information is
X * not displayed on the dialog window.
X * It filters away the information about the halted execution point,
X * returned by the execution commands.
X * On Sun dbx, it also filters away the output returned by the up and
X * down commands.
X */
Xvoid filter(s)
Xchar *s;
X{
X struct re_registers regs;
X char *p, *q;
X int r;
X static Boolean DeleteNextLine = FALSE;
X
X if ((s && strcmp(s, "") == NULL) || strcmp(Command, "") == NULL)
X return;
X
X#ifndef BSD /* for Sun dbx only */
X if (re_match(command_pattern[C_UPDOWN].buf, Command, strlen(Command),
X 0, NULL) > 0) {
X if (re_match(output_pattern[O_BELL].buf, s, strlen(s), 0, ®s) < 0) {
X if (strcmp(s+strlen(s)-strlen(PROMPT), PROMPT) == NULL)
X strcpy(s, PROMPT);
X else
X strcpy(s, "");
X }
X return;
X }
X#endif
X
X if (re_match(command_pattern[C_EXEC].buf, Command, strlen(Command),
X 0, NULL) > 0
X && re_match(output_pattern[O_EXEC].buf, s, strlen(s), 0, ®s) > 0) {
X r = output_pattern[O_EXEC].reg_token[TK_MESG];
X for (p=s+regs.start[r]; p!=s && *(p-1) != '\n'; p--);
X if (q = (char *) strchr(s+regs.end[r]+1, '\n'))
X strcpy(p, q+1);
X else {
X DeleteNextLine = TRUE;
X *p = '\0';
X }
X return;
X }
X
X if (DeleteNextLine) {
X p = (char *) strchr(s, '\n');
X strcpy(s, p+1);
X DeleteNextLine = FALSE;
X }
X}
X
X
X/* Sends a command to dbx and read the corresponding output, bypassing the
X * Xt input procedure, readDbx.
X */
Xint QueryDbx(command, do_match)
Xchar *command;
XBoolean do_match;
X{
X char s[LINESIZ], *output;
X int outputsize;
X
X Echo = FALSE;
X writeDbx(command);
X /* allocate one block to 'output' to begin with */
X outputsize = BUFSIZ;
X output = XtMalloc(outputsize);
X strcpy(output, "");
X
X while (fgets(s, LINESIZ, dbxfp) == NULL);
X do {
X if (strlen(output) + strlen(s) > outputsize) {
X output = XtRealloc(output, outputsize + BUFSIZ);
X outputsize += BUFSIZ;
X }
X strcat(output, s);
X } while (fgets(s, LINESIZ, dbxfp));
X Echo = TRUE;
X if (do_match)
X return match(output_pattern, output);
X else
X return -1;
X}
END_OF_FILE
if test 6748 -ne `wc -c <'parser.c'`; then
echo shar: \"'parser.c'\" unpacked with wrong size!
fi
# end of 'parser.c'
fi
if test -f 'signals.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'signals.c'\"
else
echo shar: Extracting \"'signals.c'\" \(2792 characters\)
sed "s/^X//" >'signals.c' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X#include <stdio.h>
X#include <signal.h>
X#include <sys/wait.h>
X
Xextern int dbxpid;
X
X/* Kill the dbx child process and then exits. */
X/* ARGSUSED */
Xstatic void kill_handler(sig, code, scp, addr)
X int sig, code;
X struct sigcontext *scp;
X char *addr;
X{
X kill(dbxpid, SIGKILL);
X switch (sig) {
X case SIGINT : fprintf(stderr, "Interrupt\n"); break;
X case SIGQUIT : fprintf(stderr, "Quit\n"); break;
X case SIGILL : fprintf(stderr, "Illegal instruction\n"); break;
X case SIGTRAP : fprintf(stderr, "Trace trap\n"); break;
X case SIGFPE : fprintf(stderr, "Arithmetic exception\n"); break;
X case SIGBUS : fprintf(stderr, "Bus error\n"); break;
X case SIGSEGV : fprintf(stderr, "Segmentation violation\n"); break;
X case SIGSYS : fprintf(stderr, "Bad argument to system call\n"); break;
X }
X exit(sig);
X}
X
X
Xstatic void quit_handler()
X{
X union wait status;
X
X /* wait for the child to report its status; if the child has died,
X * exit gracefully.
X */
X wait3(&status, WNOHANG|WUNTRACED, NULL);
X if (WIFEXITED(status) && !WIFSTOPPED(status)) {
X exit(1);
X }
X}
X
X
Xstatic void stop_handler()
X{
X kill(dbxpid, SIGSTOP); /* stop dbx process */
X kill(0, SIGSTOP); /* stop own process */
X}
X
X
Xstatic void cont_handler()
X{
X kill(dbxpid, SIGCONT); /* continue dbx after stop */
X}
X
X
X/*
X * Trap signals to xdbx so that the child process can be handled properly.
X */
Xvoid trap_signals()
X{
X signal(SIGINT, kill_handler);
X signal(SIGQUIT, kill_handler);
X signal(SIGILL, kill_handler);
X signal(SIGFPE, kill_handler);
X signal(SIGBUS, kill_handler);
X signal(SIGSEGV, kill_handler);
X signal(SIGSYS, kill_handler);
X
X signal(SIGTSTP, stop_handler); /* stop signal from keyboard */
X signal(SIGCONT, cont_handler); /* continue after stop */
X signal(SIGCHLD, quit_handler); /* child status has changed */
X
X signal(SIGTTOU, SIG_IGN); /* allow background write */
X}
END_OF_FILE
if test 2792 -ne `wc -c <'signals.c'`; then
echo shar: \"'signals.c'\" unpacked with wrong size!
fi
# end of 'signals.c'
fi
if test -f 'stop.bits' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'stop.bits'\"
else
echo shar: Extracting \"'stop.bits'\" \(319 characters\)
sed "s/^X//" >'stop.bits' <<'END_OF_FILE'
X#define stop_width 16
X#define stop_height 16
X#define stop_x_hot -1
X#define stop_y_hot -1
Xstatic char stop_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xd0, 0x01, 0x5c, 0x07,
X 0x54, 0x05, 0x54, 0x05, 0x14, 0x04, 0x0c, 0x04, 0x08, 0x04, 0x18, 0x06,
X 0xf0, 0x03, 0xf0, 0x03, 0x00, 0x00, 0x00, 0x00};
END_OF_FILE
if test 319 -ne `wc -c <'stop.bits'`; then
echo shar: \"'stop.bits'\" unpacked with wrong size!
fi
# end of 'stop.bits'
fi
if test -f 'sun_regex.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'sun_regex.h'\"
else
echo shar: Extracting \"'sun_regex.h'\" \(3266 characters\)
sed "s/^X//" >'sun_regex.h' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X/*
X * Regular expression pattern matching
X *
X * The reg_token array indicates the register no. for each token type.
X * reg_token[0] : message
X * reg_token[1] : stop number
X * reg_token[2] : function name
X * reg_token[3] : line number
X * reg_token[4] : file name
X */
X
X#define BRACKET "(%d)"
X
X#define TK_MESG 0
X#define TK_STOP 1
X#define TK_FUNC 2
X#define TK_LINE 3
X#define TK_FILE 4
X
X#define O_EXEC 0
X#define O_DONE 1
X#define O_STOPAT 2
X#define O_STOPIN 3
X#define O_UPDOWN 4
X#define O_BELL 5
X#define O_LIST 6
X
X#define C_EXEC 0
X#define C_STOPAT 1
X#define C_STOPIN 2
X#define C_UPDOWN 3
X#define C_DELETE 4
X#define C_FUNC 5
X#define C_FILE 6
X#define C_DEBUG 7
X#define C_CD 8
X
Xstatic PatternRec output_pattern[] = {
X {"\\(.*\n\\)*\\(\\(stopped\\|Bus error\\|Segmentation fault\\|Interrupt\\|\
Xsignal.*\\) in \\([^ ]+\\) at line \\([0-9]+\\)\\( in file\
X \"\\([^ ]+\\)\"\\)?\\)\n",
X NULL,
X {2, -1, 4, 5, 7}
X },
X {"\\(.*\n\\)*\\(execution completed\\|program exited with [0-9]+\\)",
X NULL,
X {-1, -1, -1, -1, -1}
X },
X {"(\\([0-9]+\\)) stop at \\(\"\\([^ ]+\\)\":\\)?\\([0-9]+\\)\n",
X NULL,
X {-1, 1, -1, 4, 3}
X },
X {"(\\([0-9]+\\)) stop in \\([^ ]+\\)\n",
X NULL,
X {-1, 1, 2, -1, -1}
X },
X {"Current function is \\([^ ]+\\)\n[ ]*\\([0-9]+\\).*\n",
X NULL,
X {-1, -1, 1, 2, 3}
X },
X {"\\(Already at the \\(top\\|bottom\\) call level\n\\|No active stack \
Xframes\n\\|no program to run\n\\|program is not active\n\\|can't continue \
Xexecution\n\\|.*\ncan't write to process.*\\)",
X NULL,
X {-1, -1, -1, -1, -1}
X },
X {"[ ]*[0-9]+.*\n[ ]*[0-9]+.*\n[ ]*[0-9]+.*\n[ ]*[0-9]+.*\n[ ]*[0-9]+.*\n\
X[ ]*\\([0-9]+\\).*\n",
X NULL,
X {-1, -1, -1, 1, -1}
X },
X NULL
X};
X
X
Xstatic PatternRec command_pattern[] = {
X {"[ ]*\\(run\\|cont\\|next\\|step\\).*\n", NULL, {-1, -1, -1, -1, -1}},
X {"[ ]*stop[ ]+at[ ]+[0-9]+.*\n", NULL, {-1, -1, -1, -1, -1}},
X {"[ ]*stop[ ]+in[ ]+.*\n", NULL, {-1, -1, -1, -1, -1}},
X {"[ ]*\\(up\\|down\\).*\n", NULL, {-1, -1, -1, -1, -1}},
X {"[ ]*delete.*\n", NULL, {-1, -1, -1, 1, -1}},
X {"[ ]*func[ ]*\\([^ ]+\\)[ ]*\n", NULL, {-1, -1, 1, -1, -1}},
X {"[ ]*file[ ]*\\([^ ]+\\)[ ]*\n", NULL, {-1, -1, -1, -1, 1}},
X {"[ ]*debug[ ]*\\([^ ]+\\)[ ]*\n", NULL, {-1, -1, -1, -1, 1}},
X {"[ ]*cd[ ]*\\([^ ]+\\)[ ]*\n", NULL, {-1, -1, -1, -1, 1}},
X NULL
X};
END_OF_FILE
if test 3266 -ne `wc -c <'sun_regex.h'`; then
echo shar: \"'sun_regex.h'\" unpacked with wrong size!
fi
# end of 'sun_regex.h'
fi
if test -f 'updown.bits' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'updown.bits'\"
else
echo shar: Extracting \"'updown.bits'\" \(329 characters\)
sed "s/^X//" >'updown.bits' <<'END_OF_FILE'
X#define updown_width 16
X#define updown_height 16
X#define updown_x_hot -1
X#define updown_y_hot -1
Xstatic char updown_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x01, 0x80, 0x03,
X 0xff, 0x06, 0x01, 0x0c, 0x01, 0x0c, 0xff, 0x06, 0x80, 0x03, 0x80, 0x01,
X 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
END_OF_FILE
if test 329 -ne `wc -c <'updown.bits'`; then
echo shar: \"'updown.bits'\" unpacked with wrong size!
fi
# end of 'updown.bits'
fi
if test -f 'utils.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'utils.c'\"
else
echo shar: Extracting \"'utils.c'\" \(3281 characters\)
sed "s/^X//" >'utils.c' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X#include "global.h"
X
XXtTextPosition StartPos; /* starting position of input text */
X
X/* Write s to dbx, and flush the output. */
X
Xvoid writeDbx(s)
Xchar *s;
X{
X fputs(s, dbxfp);
X fflush(dbxfp);
X}
X
X/* Returns the working directory of dbx (for Sun dbx only).
X */
Xchar *dbxpwd()
X{
X char s[LINESIZ], *dir;
X
X#ifdef BSD
X return NULL;
X#else
X if (dbxfp == NULL) return (".");
X Echo = FALSE;
X writeDbx("pwd\n");
X while (fgets(s, LINESIZ, dbxfp) == NULL);
X s[strlen(s)-1] = '\0';
X dir = XtNewString(s);
X while (fgets(s, LINESIZ, dbxfp));
X Echo = TRUE;
X return dir;
X#endif
X}
X
X
XXtTextPosition TextGetLastPos(w)
X Widget w;
X{
X TextWidget ctx = (TextWidget) w;
X return (ctx->text.lastPos);
X}
X
X
Xvoid AppendDialogText(s)
X char *s;
X{
X XtTextPosition i, lastPos;
X XtTextBlock textblock;
X
X if (!s || !strcmp(s, "")) return;
X
X textblock.firstPos = 0;
X textblock.length = strlen(s);
X textblock.ptr = s;
X
X lastPos = TextGetLastPos(dialogWindow);
X if (lastPos + textblock.length > DIALOGSIZE) {
X for (i=lastPos/2; DialogText[i] != '\n'; i++);
X strcpy(DialogText, &DialogText[i+1]);
X lastPos = strlen(DialogText);
X XtTextSetLastPos(dialogWindow, lastPos);
X }
X XtTextReplace(dialogWindow, lastPos, lastPos, &textblock);
X StartPos = TextGetLastPos(dialogWindow);
X XtTextSetInsertionPoint(dialogWindow, StartPos);
X}
X
X/*
X * Get the line number where the caret is.
X */
XLine TextPositionToLine(pos)
XXtTextPosition pos;
X{
X Line line;
X
X if (displayedFile) {
X for (line = displayedFile->topline;
X pos >= displayedFile->linepos[line]; line++);
X return (line-1);
X }
X else
X return 0;
X}
X
X/*
X * Return the stop number associated with a given line number.
X * Return 0 if stop number not found.
X */
Xint LineToStop_no(line)
XLine line;
X{
X int i;
X
X for (i=1; i <= nstops; i++)
X if (stops[i].line == line && stops[i].filename && displayedFile &&
X strcmp(stops[i].filename, displayedFile->filename) == NULL) {
X return i;
X }
X return 0;
X}
X
X
Xvoid DisableWindowResize(w)
XWidget w;
X{
X Arg args[MAXARGS];
X Cardinal n;
X Dimension height;
X
X n = 0;
X XtSetArg(args[n], XtNheight, &height); n++;
X XtGetValues(w, args, n);
X XtPanedSetMinMax(w, height, height);
X XtPanedAllowResize(w, False);
X}
X
X
Xvoid Bell(volume)
Xint volume;
X{
X XBell(XtDisplay(toplevel), volume);
X}
END_OF_FILE
if test 3281 -ne `wc -c <'utils.c'`; then
echo shar: \"'utils.c'\" unpacked with wrong size!
fi
# end of 'utils.c'
fi
if test -f 'windows.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'windows.c'\"
else
echo shar: Extracting \"'windows.c'\" \(5220 characters\)
sed "s/^X//" >'windows.c' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X#include "global.h"
X
X/*
X * Private routines for creating various subwindows for xdbx.
X */
X
Xstatic void CreateTitleBar(parent)
XWidget parent;
X{
X Arg args[MAXARGS];
X Cardinal n;
X
X n = 0;
X XtSetArg(args[n], XtNlabel, (XtArgVal) TITLE); n++;
X XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.shellWidth); n++;
X XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyCenter); n++;
X XtSetArg(args[n], XtNresize, (XtArgVal) False); n++;
X titleBar = XtCreateManagedWidget("titleBar", labelWidgetClass, parent,
X args, n);
X}
X
Xstatic void CreateFileLabel(parent)
XWidget parent;
X{
X Arg args[MAXARGS];
X Cardinal n;
X
X n = 0;
X XtSetArg(args[n], XtNlabel, (XtArgVal) "No Source File"); n++;
X XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.shellWidth); n++;
X XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0); n++;
X XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyCenter); n++;
X XtSetArg(args[n], XtNresizable, (XtArgVal) False); n++;
X fileLabel = XtCreateManagedWidget("fileLabel", labelWidgetClass,
X parent, args, n);
X}
X
Xstatic void CreateLineLabel(parent)
XWidget parent;
X{
X Arg args[MAXARGS];
X Cardinal n;
X int horizDistance;
X
X horizDistance = app_resources.shellWidth - app_resources.lineLabelWidth;
X n = 0;
X XtSetArg(args[n], XtNlabel, (XtArgVal) ""); n++;
X XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.lineLabelWidth); n++;
X XtSetArg(args[n], XtNborderWidth, (XtArgVal) 0); n++;
X XtSetArg(args[n], XtNresizable, (XtArgVal) False); n++;
X XtSetArg(args[n], XtNhorizDistance, (XtArgVal) horizDistance); n++;
X lineLabel = XtCreateManagedWidget("lineLabel", labelWidgetClass,
X parent, args, n);
X}
X
Xstatic void CreateFileWindow(parent)
XWidget parent;
X{
X Arg args[MAXARGS];
X Cardinal n;
X
X n = 0;
X XtSetArg(args[n], XtNdefaultDistance, 0); n++;
X fileWindow = XtCreateManagedWidget("fileWindow", formWidgetClass,
X parent, args, n);
X CreateLineLabel(fileWindow);
X CreateFileLabel(fileWindow);
X}
X
Xstatic void CreateMessageWindow(parent)
XWidget parent;
X{
X Arg args[MAXARGS];
X Cardinal n;
X
X n = 0;
X XtSetArg(args[n], XtNlabel, (XtArgVal) ""); n++;
X XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.shellWidth); n++;
X XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyLeft); n++;
X XtSetArg(args[n], XtNresize, (XtArgVal) False); n++;
X XtSetArg(args[n], XtNmin, (XtArgVal) app_resources.messageHeight); n++;
X XtSetArg(args[n], XtNmax, (XtArgVal) app_resources.messageHeight); n++;
X XtSetArg(args[n], XtNallowResize, (XtArgVal) False); n++;
X messageWindow = XtCreateManagedWidget("messageWindow", labelWidgetClass,
X parent, args, n);
X}
X
X/*
X * Top level function for creating all the xdbx subwindows.
X */
Xvoid CreateSubWindows(parent)
XWidget parent;
X{
X Arg args[MAXARGS];
X Cardinal n;
X
X n = 0;
X XtSetArg(args[n], XtNwidth, (XtArgVal) app_resources.shellWidth); n++;
X vpane = XtCreateManagedWidget("vpane", vPanedWidgetClass, parent, args, n);
X
X if (!app_resources.noTitleBar) CreateTitleBar(vpane);
X CreateFileWindow(vpane);
X CreateSourceWindow(vpane);
X CreateMessageWindow(vpane);
X CreateCommandPanel(vpane);
X CreateDialogWindow(vpane);
X}
X
X/*
X * Public routines for updating fields for the filename and line number
X * in the file window, and the execution status in the message window.
X */
X
Xvoid UpdateFileLabel(string)
Xchar *string;
X{
X Arg args[MAXARGS];
X Cardinal n;
X
X n = 0;
X XtSetArg(args[n], XtNlabel, (XtArgVal) string); n++;
X XtSetValues(fileLabel, args, n);
X}
X
Xvoid UpdateLineLabel(line)
XCardinal line;
X{
X Arg args[MAXARGS];
X Cardinal n;
X char string[10];
X
X n = 0;
X if (line > 0)
X sprintf(string, "%d", line);
X else
X strcpy(string, "");
X XtSetArg(args[n], XtNlabel, (XtArgVal) string); n++;
X XtSetValues(lineLabel, args, n);
X}
X
Xvoid UpdateMessageWindow(message)
Xchar *message;
X{
X char string[LINESIZ];
X Arg args[MAXARGS];
X Cardinal n;
X
X strcpy(string, " ");
X strcat(string, message);
X n = 0;
X XtSetArg(args[n], XtNlabel, (XtArgVal) string); n++;
X XtSetValues(messageWindow, args, n);
X}
END_OF_FILE
if test 5220 -ne `wc -c <'windows.c'`; then
echo shar: \"'windows.c'\" unpacked with wrong size!
fi
# end of 'windows.c'
fi
if test -f 'xdbx.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'xdbx.c'\"
else
echo shar: Extracting \"'xdbx.c'\" \(6204 characters\)
sed "s/^X//" >'xdbx.c' <<'END_OF_FILE'
X/******************************************************************************
X *
X * xdbx - X Window System interface to dbx
X *
X * Copyright 1989 The University of Texas at Austin
X *
X * Author: Po Cheung
X * Date: March 10, 1989
X *
X * Permission to use, copy, modify, and distribute this software and
X * its documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation. The University of Texas at Austin makes no
X * representations about the suitability of this software for any purpose.
X * It is provided "as is" without express or implied warranty.
X *
X ******************************************************************************/
X
X
X#include "global.h"
X
X#define Offset(field) (XtOffset(XdbxResources *, field))
X
XWidget toplevel, /* top level widget */
X vpane, /* parent of all subwindows */
X titleBar, /* label widget displaying title */
X fileWindow, /* form widget containing : */
X fileLabel, /* file name of displayed text */
X lineLabel, /* line number of caret */
X sourceWidget, /* form widget, parent of sourceWindow */
X sourceWindow, /* asciiString widget, source file */
X messageWindow, /* label widget, execution status */
X commandWindow, /* command panel, box widget */
X dialogWindow; /* dialog window, asciiString widget */
X
XXdbxResources app_resources; /* application resources of xdbx */
Xchar *xdbxinit = "xdbx.XXXXXX";
XBoolean Homedir;
X
X
Xstatic XtResource resources[] = {
X {"shellWidth", "ShellWidth", XtRDimension, sizeof(Dimension),
X Offset(shellWidth), XtRString, "550"},
X {"lineLabelWidth", "LineLabelWidth", XtRDimension, sizeof(Dimension),
X Offset(lineLabelWidth), XtRString, "70"},
X {"sourceHeight", "SourceHeight", XtRDimension, sizeof(Dimension),
X Offset(sourceHeight), XtRString, "320"},
X {"leftMargin", "LeftMargin", XtRDimension, sizeof(Dimension),
X Offset(leftMargin), XtRString, "35"},
X {"dialogHeight", "DialogHeight", XtRDimension, sizeof(Dimension),
X Offset(dialogHeight), XtRString, "200"},
X {"dialogMinHeight", "DialogMinHeight", XtRDimension, sizeof(Dimension),
X Offset(dialogMinHeight), XtRString, "15"},
X {"messageHeight", "MessageHeight", XtRDimension, sizeof(Dimension),
X Offset(messageHeight), XtRString, "30"},
X {"buttonWidth", "ButtonWidth", XtRDimension, sizeof(Dimension),
X Offset(buttonWidth), XtRString, "50"},
X {"commandHSpace", "CommandHSpace", XtRDimension, sizeof(Dimension),
X Offset(commandHSpace), XtRString, "14"},
X {"commandVSpace", "CommandVSpace", XtRDimension, sizeof(Dimension),
X Offset(commandVSpace), XtRString, "10"},
X {"commandMinHeight", "CommmandMinHeight", XtRDimension, sizeof(Dimension),
X Offset(commandMinHeight), XtRString, "70"},
X {"commandMaxHeight", "CommandMaxHeight", XtRDimension, sizeof(Dimension),
X Offset(commandMaxHeight), XtRString, "120"},
X {"columnSpacing", "ColumnSpacing", XtRDimension, sizeof(Dimension),
X Offset(columnSpacing), XtRString, "10"},
X {"filesPerColumn", "FilesPerColumn", XtRInt, sizeof(int),
X Offset(filesPerColumn), XtRString, "10"},
X {"noTitleBar", "NoTitleBar", XtRBoolean, sizeof(Boolean),
X Offset(noTitleBar), XtRImmediate, (caddr_t)False},
X {"stopForeground", "StopForeground", XtRPixel, sizeof(Pixel),
X Offset(stopForeground), XtRString, "Red"},
X {"arrowForeground", "ArrowForeground", XtRPixel, sizeof(Pixel),
X Offset(arrowForeground), XtRString, "Blue"},
X {"updownForeground", "UpdownForeground", XtRPixel, sizeof(Pixel),
X Offset(updownForeground), XtRString, "Blue"},
X};
X
Xstatic XrmOptionDescRec options[] = {
X {"-r", "dbxopt_r", XrmoptionNoArg, "True"},
X {"-i", "dbxopt_i", XrmoptionNoArg, "True"},
X {"-I", "includeDir", XrmoptionSepArg, NULL},
X {"-k", "dbxopt_k", XrmoptionNoArg, "True"},
X#ifdef BSD /* Berkeley dbx */
X {"-c", "cfile", XrmoptionSepArg, NULL},
X#else /* Sun Release 3.2 or 3.4 dbx */
X {"-kbd", "dbxopt_kbd", XrmoptionNoArg, "True"},
X#endif
X#ifdef sparc /* SunOS 4.0 dbx */
X {"-f", "fcount", XrmoptionSepArg, NULL},
X {"-s", "startup", XrmoptionSepArg, NULL},
X {"-sr", "tstartup", XrmoptionSepArg, NULL},
X#endif
X};
X
X
Xstatic void Syntax(call)
Xchar *call;
X{
X fprintf(stderr,
X "Usage: %s [-toolkitoptions] [-dbxoptions] [objfile [corefile]]\n",
X call);
X}
X
X
Xstatic void Initialize()
X{
X source_init();
X signs_init();
X parser_init();
X if (!app_resources.noTitleBar) DisableWindowResize(titleBar);
X DisableWindowResize(fileWindow);
X mktemp(xdbxinit);
X Homedir = False;
X if (rename(".dbxinit", xdbxinit) == -1) {
X rename("~/.dbxinit", xdbxinit);
X Homedir = True;
X }
X}
X
X
Xint dbxoptions(argc, argv, app_resources)
X int argc;
X char **argv;
X XdbxResources app_resources;
X{
X if (app_resources.dbxopt_r)
X argv[argc++] = "-r";
X if (app_resources.dbxopt_i)
X argv[argc++] = "-i";
X if (app_resources.includeDir) {
X argv[argc++] = "-I";
X strcpy(argv[argc++], app_resources.includeDir);
X }
X if (app_resources.dbxopt_k)
X argv[argc++] = "-k";
X if (app_resources.cfile) {
X argv[argc++] = "-c";
X strcpy(argv[argc++], app_resources.cfile);
X }
X if (app_resources.dbxopt_kbd)
X argv[argc++] = "-kbd";
X if (app_resources.fcount) {
X argv[argc++] = "-f";
X strcpy(argv[argc++], app_resources.fcount);
X }
X if (app_resources.startup) {
X argv[argc++] = "-s";
X strcpy(argv[argc++], app_resources.startup);
X }
X if (app_resources.tstartup) {
X argv[argc++] = "-sr";
X strcpy(argv[argc++], app_resources.tstartup);
X }
X argv[argc] = NULL;
X return argc;
X}
X
X
Xvoid main(argc, argv)
Xunsigned int argc;
Xchar **argv;
X{
X trap_signals();
X
X toplevel = XtInitialize("toplevel", "XDbx", options, XtNumber(options),
X &argc, argv);
X
X if (argc > 3) Syntax(argv[0]);
X
X XtGetApplicationResources(toplevel, &app_resources, resources,
X XtNumber(resources), NULL, 0);
X
X CreateSubWindows(toplevel);
X
X XtRealizeWidget(toplevel);
X
X Initialize();
X argc = dbxoptions(argc, argv, app_resources);
X calldbx(argc, argv);
X
X XtMainLoop();
X}
END_OF_FILE
if test 6204 -ne `wc -c <'xdbx.c'`; then
echo shar: \"'xdbx.c'\" unpacked with wrong size!
fi
# end of 'xdbx.c'
fi
echo shar: End of archive 3 \(of 3\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 3 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Mike Wexler(wyse!mikew) Phone: (408)433-1000 x1330
Moderator of comp.sources.x
More information about the Comp.sources.x
mailing list