home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-17 | 40.1 KB | 1,328 lines |
- Newsgroups: alt.sources
- From: jtsillas@sprite.ma30.bull.com (James Tsillas)
- Subject: mxgdb Part 5/9
- Date: 16 Jul 91 13:08:33
- Message-ID: <JTSILLAS.91Jul16130833@sprite.ma30.bull.com>
-
-
-
- ---- Cut Here and feed the following to sh ----
- #!/bin/sh
- # this is mxgdb.05 (part 5 of a multipart archive)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file mxgdb/source.c continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 5; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping mxgdb/source.c'
- else
- echo 'x - continuing file mxgdb/source.c'
- sed 's/^X//' << 'SHAR_EOF' >> 'mxgdb/source.c' &&
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), next_bits, next_width,
- X next_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X nextbutton = XtCreateManagedWidget("nextbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(nextbutton, XmNactivateCallback, DoIt, "next\n");
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), print_bits, print_width,
- X print_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X printbutton = XtCreateManagedWidget("printbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(printbutton, XmNactivateCallback, Print, (XtPointer)0);
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), down_bits, down_width,
- X down_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X downbutton = XtCreateManagedWidget("downbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(downbutton, XmNactivateCallback, DoIt, "down\n");
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), up_bits, up_width,
- X up_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X upbutton = XtCreateManagedWidget("upbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(upbutton, XmNactivateCallback, DoIt, "up\n");
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), stack_bits, stack_width,
- X stack_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X stackbutton = XtCreateManagedWidget("stackbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(stackbutton, XmNactivateCallback, DoIt, "info stack\n");
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), cont_bits, cont_width,
- X cont_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X contbutton = XtCreateManagedWidget("contbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(contbutton, XmNactivateCallback, DoIt, "cont\n");
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), finish_bits, finish_width,
- X finish_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X finishbutton = XtCreateManagedWidget("finishbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(finishbutton, XmNactivateCallback, DoIt, "finish\n");
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), run_bits, run_width,
- X run_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X runbutton = XtCreateManagedWidget("runbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args,7);
- X XtAddCallback(runbutton, XmNactivateCallback, DoIt, "run\n");
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), disp_bits, disp_width,
- X disp_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X dispbutton = XtCreateManagedWidget("dispbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(dispbutton, XmNactivateCallback, Display_, NULL);
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), undisp_bits, undisp_width,
- X undisp_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X undispbutton = XtCreateManagedWidget("undispbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(undispbutton, XmNactivateCallback, Undisplay, NULL);
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), clear_bits, clear_width,
- X clear_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X clearbutton = XtCreateManagedWidget("clearbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(clearbutton, XmNactivateCallback, Clear, NULL);
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), prints_bits, prints_width,
- X prints_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X printsbutton = XtCreateManagedWidget("printsbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(printsbutton, XmNactivateCallback, Print, (XtPointer)1);
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), args_bits, args_width,
- X args_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X argsbutton = XtCreateManagedWidget("argsbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(argsbutton, XmNactivateCallback, DoIt, "info args\n");
- X
- X XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
- X topdisplay, DefaultRootWindow(topdisplay), locals_bits, locals_width,
- X locals_height, app_resources.stop_color, bg,
- X DefaultDepth(topdisplay, screen)));
- X localsbutton = XtCreateManagedWidget("localsbutton",
- X xmPushButtonWidgetClass, sourceForm,
- X args, 7);
- X XtAddCallback(localsbutton, XmNactivateCallback, DoIt, "info locals\n");
- X
- X
- X XtAppAddActions(app_context, command_actions, XtNumber(command_actions));
- }
- X
- X
- /*
- X * Build the array which gives the starting text position of each line.
- X * > Estimate the number of lines in the file and allocate memory buffer.
- X * > Starting position of line #1 is 0, and is stored in linepos[1].
- X * > Search for '\n' till end of buffer.
- X */
- static void BuildLinePos(file)
- FileRec *file;
- {
- X char *p;
- X int line, nlines;
- X
- X nlines = MAX(1, file->filesize/CHARS_PER_LINE);
- X file->linepos = (XmTextPosition *)
- X XtMalloc ((nlines+2) * sizeof(XmTextPosition));
- X p = file->buf;
- X line = 0;
- X file->linepos[line++] = 0;
- X file->linepos[line++] = 0;
- X while (*p) {
- X if (*p++ == '\n') {
- X if (line == nlines) { /* buffer full, need more memory */
- X file->linepos = (XmTextPosition *) XtRealloc (file->linepos,
- X (nlines + ADD_LINES) * sizeof(XmTextPosition));
- X nlines += ADD_LINES;
- X }
- X file->linepos[line++] = p - file->buf;
- X }
- X }
- X file->lastline = line - 2;
- X file->linepos = (XmTextPosition *) XtRealloc /* shrink to min size */
- X (file->linepos, line * sizeof(XmTextPosition));
- }
- X
- X
- /*
- X * Look up the file table for an entry with "filename"
- X * If not found, create an entry and initialize proper fields,
- X * else, return pointer to entry found.
- X */
- static LookUpFileTable(pathname, filename, file)
- char *pathname, *filename;
- FileRec **file;
- {
- X struct stat fileinfo;
- X int fd;
- X int i, j, n;
- X
- X for (i=0; fileTable && fileTable[i] && i<fileTableSize; i++) {
- X if (!strcmp(fileTable[i]->pathname, pathname)) { /* file found */
- X if (stat(pathname, &fileinfo) == -1) {
- X UpdateMessageWindow("Error: cannot stat file %s", pathname);
- X *file = fileTable[i];
- X return 0;
- X }
- X if (fileinfo.st_mtime > fileTable[i]->mtime) { /* file modified */
- X XtFree((char *)fileTable[i]->buf);
- X XtFree((char *)fileTable[i]->linepos);
- X XtFree((char *)fileTable[i]);
- X displayedFile = NULL;
- X break;
- X }
- X else if (displayedFile && /* same as displayed file */
- X strcmp(pathname, displayedFile->pathname) == 0) {
- X *file = NULL;
- X return 0;
- X }
- X else {
- X *file = fileTable[i];
- X return 0;
- X }
- X }
- X }
- X
- X /* Record file into file table */
- X
- X if (i == fileTableSize) { /* file table full, enlarge it */
- X fileTableSize += ADD_SIZE;
- X fileTable = (FileRec **)
- X XtRealloc (fileTable, fileTableSize * sizeof(FileRec *));
- X for (j=i; j<fileTableSize; j++)
- X fileTable[j] = NULL;
- X }
- X if ((fd = open(pathname, O_RDONLY)) == -1) {
- X UpdateMessageWindow("Error: cannot open file %s", pathname);
- X return -1;
- X }
- X if (fstat(fd, &fileinfo) == -1) {
- X UpdateMessageWindow("Error: cannot fstat file %s", pathname);
- X close(fd);
- X return -1;
- X }
- X fileTable[i] = (FileRec *) XtMalloc (sizeof(FileRec));
- X fileTable[i]->filesize = fileinfo.st_size + 1;
- X fileTable[i]->mtime = fileinfo.st_mtime;
- X fileTable[i]->buf = XtMalloc((int)fileTable[i]->filesize);
- X if ((n = read(fd, fileTable[i]->buf, (int) fileTable[i]->filesize)) == -1) {
- X UpdateMessageWindow("Error: cannot read file %s", pathname);
- X XtFree(fileTable[i]->buf);
- X XtFree(fileTable[i]);
- X fileTable[i] = NULL;
- X close(fd);
- X return -1;
- X }
- X fileTable[i]->buf[n] = '\0';
- X fileTable[i]->pathname = XtNewString(pathname);
- X fileTable[i]->filename = XtNewString(filename);
- X fileTable[i]->currentline = 1;
- X fileTable[i]->topline = 1;
- X fileTable[i]->bottomline = 0;
- X fileTable[i]->topPosition = 0;
- X BuildLinePos(fileTable[i]);
- X close(fd);
- X *file = fileTable[i];
- X return 0;
- }
- X
- /*
- X * Remember file position and current line before closing.
- X */
- static void SaveDisplayedFileInfo()
- {
- X XmTextPosition pos;
- X Arg args[MAXARGS];
- X
- X if (displayedFile) {
- X XtSetArg(args[0], XmNtopPosition, &(displayedFile->topPosition));
- X XtGetValues(sourceWindow, args, 1);
- X XtSetArg(args[0], XmNcursorPosition, &pos);
- X XtGetValues(sourceWindow, args, 1);
- X displayedFile->currentline = TextPositionToLine(pos);
- X }
- }
- X
- X
- /* DisplayFile() displays the file onto the source window. It
- X * uses topPosition to remember where it was last opened. But it
- X * must recalculate bottomline because the window size might be
- X * different.
- X */
- static void DisplayFile(file)
- FileRec *file;
- {
- X Arg args[MAXARGS];
- X short columns, rows, rowcount;
- X int slidersize;
- X Dimension height, width;
- X
- X XtSetArg(args[0], XmNeditable, False);
- X XtSetArg(args[1], XmNvalue, file->buf);
- X XtSetValues(sourceWindow, args, 2);
- X
- X XtSetArg(args[0], XmNrows, &rows);
- X XtSetArg(args[1], XmNcolumns, &columns);
- X XtGetValues(sourceWindow, args, 2);
- X
- X file->lines = rows;
- X file->bottomline = MIN (file->topline + file->lines - 1, file->lastline);
- X
- X if(file->lastline < rows)
- X {
- X if(XtIsManaged(scrollV))
- X XtUnmanageChild(scrollV);
- X }
- X else
- X {
- X XtManageChild(scrollV);
- X XtSetArg(args[0], XmNheight, &height);
- X XtGetValues(scrollV, args, 1);
- X slidersize = ((int)rows * (int)height)/(int)file->lastline;
- X XmScrollBarSetValues(scrollV, 1, slidersize, 1, 0, True);
- X XtSetArg(args[0], XmNmaximum, file->lastline+slidersize);
- X XtSetArg(args[1], XmNminimum, 0);
- X XtSetValues(scrollV, args, 2);
- X
- X }
- }
- X
- X
- /* Given a filename starting with a tilde (`~'), it expands ~[user] to
- X * the home directory of that user, or to the login home directory if user
- X * is not specified.
- X */
- static char *expand(filename)
- char *filename;
- {
- X struct passwd *pwd;
- X char *string, *name, newfile[MAXNAME];
- X
- X string = XtNewString(filename+1);
- X if (*string == '\0' || *string == '/')
- X name = (char *) getlogin();
- X else
- X name = (char *) strtok(string, "/");
- X if (name == NULL)
- X return filename;
- X pwd = (struct passwd *) getpwnam(name);
- X if (pwd && pwd->pw_dir) {
- X sprintf(newfile, "%s%s", pwd->pw_dir, filename+strlen(name)+1);
- X return XtNewString(newfile);
- X }
- X else
- X return filename;
- }
- X
- X
- /* Create a list of directories for searching source files.
- X * It reads the list of directories specified by the user, adding
- X * the current directory into the list if it is not already there.
- X *
- X * With fix from Dave Gagne (daveg@fs1.ee.ubc.ca) 7/30/90
- X */
- void MakeDirList(output)
- char *output;
- {
- X char *s, list[BUFSIZ], command[LINESIZ];
- X int i, use_cwd;
- X
- X for (i=0; dirList[i]; i++) /* remove old list */
- X XtFree(dirList[i]);
- X i = 0;
- X use_cwd = TRUE;
- X if (output) { /* create list */
- X s = (char *) strtok(output, ": \n");
- X while (s) {
- X dirList[i] = XtNewString(s);
- X
- X if (dirList[i][0] == '~') /* expand '~' */
- X dirList[i] = expand(dirList[i]);
- X if (LASTCH(dirList[i]) == '/') /* remove last '/' */
- X LASTCH(dirList[i]) = '\0';
- X if (!strcmp(dirList[i], ".")) /* watch for "." */
- X use_cwd = FALSE;
- X
- X ++i;
- X s = (char *) strtok(NULL, " \n");
- X }
- X dirList[i] = NULL;
- X }
- X
- X if (use_cwd) { /* include current dir */
- X dirList[i++] = XtNewString(".");
- X dirList[i] = NULL;
- X }
- X strcpy(list, ""); /* tell dbx our new list */
- X for (i=0; dirList[i]; i++) {
- X strcat(list, dirList[i]);
- X strcat(list, " ");
- X }
- X sprintf(command, "directory %s\n", list);
- X Parse = False;
- X query_dbx(command);
- }
- X
- X
- /* Returns the full pathname of a given file.
- X * It searches for the file from a list of directories.
- X */
- char *GetPathname(filename)
- char *filename;
- {
- X char pathname[LINESIZ];
- X int i;
- X
- X if (filename == NULL || !strcmp(filename, ""))
- X return NULL;
- X for (i=0; dirList[i]; i++) {
- X if (*filename == '/' && access(filename, R_OK) == -1) {
- X /* this handles the exceptional case of sun4 dbx output */
- X strcpy(filename, &filename[1]);
- X }
- X if (*filename == '/' || *filename == '~')
- X strcpy(pathname, filename);
- X else if (!strcmp(dirList[i], "."))
- X sprintf(pathname, "%s/%s", cwd, filename);
- X else if (*dirList[i] == '/' || *dirList[i] == '~')
- X sprintf(pathname, "%s/%s", dirList[i], filename);
- X else
- X sprintf(pathname, "%s/%s/%s", cwd, dirList[i], filename);
- X if (access(pathname, R_OK) == 0)
- X return XtNewString(pathname);
- X }
- X UpdateMessageWindow("File not found: %s", filename);
- X return NULL;
- }
- X
- /*
- X * Given a file name, LoadFile attempts to open it and displays it onto
- X * the source window:
- X * 1. get the full pathname of the file
- X * 2. LookUpFileTable() returns a pointer to the file's entry if it's
- X * already in the table; else, creates an entry and return a pointer.
- X * 3. save the current displayedFile info
- X * 4. display the file
- X * 5. update the file label and the various signs on the source window.
- X * LoadFile returns 0 upon successful completion, -1 otherwise.
- X */
- int LoadFile(filename)
- char *filename;
- {
- X FileRec *file;
- X char *pathname;
- X Arg args[5];
- X Position Py;
- X
- X
- X pathname = GetPathname(filename);
- X if (pathname == NULL) {
- X return -1;
- X }
- X if (LookUpFileTable(pathname, filename, &file) != -1) {
- X if (file) { /* load new file */
- X SaveDisplayedFileInfo();
- X DisplayFile(file);
- X UpdateFileLabel(pathname);
- X XmTextClearSelection(sourceWindow,0);
- X XmTextSetInsertionPosition(sourceWindow,
- X file->linepos[file->currentline]);
- X UpdateLineLabel(file->currentline);
- X UpdateStops(file, -1);
- X UpdateArrow(file);
- X UpdateUpdown(file);
- X UpdateBomb(file);
- X displayedFile = file;
- X }
- X return 0;
- X }
- X else { /* LookUpFileTable() fails */
- X return -1;
- X }
- }
- X
- int LoadCurrentFile()
- {
- X query_dbx("info line\n");
- X return LoadFile(CurrentFile);
- }
- X
- X
- SHAR_EOF
- echo 'File mxgdb/source.c is complete' &&
- chmod 0664 mxgdb/source.c ||
- echo 'restore of mxgdb/source.c failed'
- Wc_c="`wc -c < 'mxgdb/source.c'`"
- test 29383 -eq "$Wc_c" ||
- echo 'mxgdb/source.c: original size 29383, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= mxgdb/gdb_parser.c ==============
- if test -f 'mxgdb/gdb_parser.c' -a X"$1" != X"-c"; then
- echo 'x - skipping mxgdb/gdb_parser.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting mxgdb/gdb_parser.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/gdb_parser.c' &&
- /* $Id: gdb_parser.c,v 1.2 1991/06/28 20:35:00 jtsillas Exp $ */
- X
- /*****************************************************************************
- X *
- X * xdbx - X Window System interface to the dbx debugger
- X *
- X * Copyright 1989 The University of Texas at Austin
- X * Copyright 1990 Microelectronics and Computer Technology Corporation
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * 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, and that the name of The University of Texas
- X * and Microelectronics and Computer Technology Corporation (MCC) not be
- X * used in advertising or publicity pertaining to distribution of
- X * the software without specific, written prior permission. The
- X * University of Texas and MCC makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X *
- X * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
- X * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- X * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
- X * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- X * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- X * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- X *
- X * Author: Po Cheung
- X * Created: March 10, 1989
- X *
- X *****************************************************************************
- X *
- X * xxgdb - X Window System interface to the gdb debugger
- X *
- X * Copyright 1990 Thomson Consumer Electronics, Inc.
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * 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, and that the name of Thomson Consumer
- X * Electronics (TCE) not be used in advertising or publicity pertaining
- X * to distribution of the software without specific, written prior
- X * permission. TCE makes no representations about the suitability of
- X * this software for any purpose. It is provided "as is" without express
- X * or implied warranty.
- X *
- X * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
- X * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
- X * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- X * SOFTWARE.
- X *
- X * Adaptation to GDB: Pierre Willard
- X * XXGDB Created: December, 1990
- X *
- X *****************************************************************************
- X
- /* gdb_parser.c:
- X *
- X * WARNING : gdb_parser.c is included by parser.c for GDB.
- X *
- X * Parse output messages from dbx using regular expression pattern matching,
- X * and take appropriate action.
- X *
- X * parse(): Parse the dbx output and invoke the appropriate action
- X * handler.
- X * filter(): Modify the dbx output before it gets displayed on the
- X * dialog window.
- X * gdb_source_command(): Test for source command.
- X */
- X
- #include <string.h>
- X
- /*--------------------------------------------------------------------------+
- | |
- | 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;
- X
- X /* test for reading symbols message */
- X
- X while (re_match(output_pattern[O_READING_SYMBOLS].buf,output,strlen(output),0,®s) > 0)
- X {
- X /* we found a "Reading in symbols for ...done." pattern */
- X
- X r = output_pattern[O_READING_SYMBOLS].reg_token[TK_MESG];
- X p1= output+regs.start[r];
- X p2 = output+regs.end[r];
- X
- X /* remove "Reading in symbols for ...done." */
- X
- X while(*(p1++) = *(p2++));
- X }
- }
- X
- /*--------------------------------------------------------------------------+
- | |
- | * 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;
- {
- X int command_type;
- X char *output_string;
- X
- X if (debug) {
- X char *temp;
- X if(!command)temp="";else temp=command;
- X fprintf(stderr, "parse(output = %s, command = %s)\n", output, temp);
- X }
- X
- X /* Make a local copy of `output' and use that instead */
- X output_string = XtNewString(output);
- X if (output) strcpy(output, "");
- X
- X if (!command) {
- X if (match(output_pattern, output_string, O_DEBUG) != -1)
- X debug_handler();
- X debug_init();
- X XtFree(output_string);
- X return;
- X }
- X
- X if (!Parse)
- X {
- X XtFree(output_string);
- X return;
- X }
- X
- X if (match(output_pattern, output_string, O_BELL) != -1)
- X {
- X bell(0);
- X XtFree(output_string);
- X return;
- X }
- X
- X command_type = match(command_pattern, command, C_ANY);
- X
- X
- X /* remove all "Reading in symbols for pw.c...done." */
- X
- X filter_reading_symbols(output_string);
- X
- X switch (command_type) {
- X case C_EXEC:
- X case C_FINISH:
- X {
- X char * message;
- X int signal;
- X message = 0;
- X if (match(output_pattern, output_string, O_RECEIVED_SIGNAL) != -1)
- X {
- X message = XtNewString(Token.mesg);
- X signal = Token.stop; /* signal number received */
- X }
- X
- X /* warning : the order of the matching tests is important */
- X
- X if ((match(output_pattern, output_string, O_EXEC_MESS_AFTER) != -1)
- X || (match(output_pattern, output_string, O_EXEC_MESS_BEFORE) != -1)
- X || (match(output_pattern, output_string, O_EXEC) != -1))
- X {
- X exec_handler(message,signal);
- X }
- X else
- X {
- X if (match(output_pattern, output_string, O_DONE) != -1)
- X done_handler(message,signal);
- X else
- X bell(0);
- X }
- X
- X if (message)
- X {
- X bell(0);
- X XtFree(message);
- X }
- X }
- X break;
- X
- X case C_UPDOWN:
- X if (match(output_pattern, output_string, O_UPDOWN) != -1)
- X updown_handler();
- X else
- X bell(0);
- X break;
- X case C_SEARCH:
- X if (match(output_pattern, output_string, O_SEARCH) != -1)
- X search_handler();
- X else
- X bell(0);
- X break;
- X case C_CLEAR:
- X clear_handler();
- X break;
- X case C_LIST:
- X if (match(output_pattern, output_string, O_LIST) != -1)
- X list_handler();
- X else
- X bell(0);
- X break;
- X
- X case C_BREAK:
- X if (match(output_pattern, output_string, O_BREAK) != -1)
- X break_handler();
- X else
- X bell(0);
- X break;
- X
- X case C_INFO_DIR:
- X if (match(output_pattern, output_string, O_INFO_DIR) != -1)
- X info_dir_handler();
- X else
- X bell(0);
- X break;
- X
- X case C_DIRECTORY:
- X directory_handler();
- X break;
- X
- X case C_INFO_LINE:
- X if (match(output_pattern, output_string, O_INFO_LINE) != -1)
- X info_line_handler(); /* command was 'info line' */
- X else
- X bell(0);
- X break;
- X
- X case C_INFO_BREAK:
- X info_break_handler(output_string);
- X break;
- X
- X case C_DISPLAY:
- X {
- X if ((!strcmp(output_string, "")) ||
- X (match(output_pattern, output_string, O_DISPLAY) != -1))
- X display_handler();
- X else
- X bell(0);
- X }
- X break;
- X
- X case C_UNDISPLAY:
- X if (!strcmp(output_string, ""))
- X display_handler();
- X else
- X bell(0);
- X break;
- X
- X case C_DISPLAY_INFO:
- X {
- X if ((!strcmp(output_string, "")) ||
- X (match(output_pattern, output_string, O_DISPLAY_INFO) != -1))
- X display_info_handler();
- X else
- X bell(0);
- X }
- X break;
- X
- X case C_CD:
- X if (match(output_pattern, output_string, O_CD) != -1)
- X cd_handler(Token.mesg);
- X else
- X bell(0);
- X break;
- X
- X case C_PWD:
- X if (match(output_pattern, output_string, O_PWD) != -1)
- X pwd_handler(Token.mesg);
- X else
- X bell(0);
- X break;
- X
- X case C_FRAME_CURR:
- X if (match(output_pattern, output_string, O_FRAME_CURR) != -1)
- X frame_curr_handler();
- X else
- X bell(0);
- X break;
- X
- X case C_PRINT:
- X match(output_pattern, output_string, O_PRINT);
- X break;
- X case C_HELP:
- X if(match(output_pattern, output_string, O_HELP) != -1)
- X help_handler(command, output_string);
- X break;
- X case C_SYMBOL_FILE:
- X debug_handler();
- X break;
- X
- X case C_SOURCE: /* WE SHOULD NEVER ARRIVE HERE */
- X break;
- X
- X case C_EXEC_FILE:
- X break;
- X
- X default:
- X break;
- X }
- X XtFree(output_string);
- }
- X
- /*--------------------------------------------------------------------------+
- | |
- | Function to filter all the display information in a string |
- | |
- | input : string pointer. |
- | |
- | 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)
- char *output;
- {
- struct re_registers regs;
- int r;
- char *p;
- char *p1;
- char *p2;
- char *cp_output;
- int begin_struct;
- X
- X p = cp_output = XtNewString(output);
- X
- X p1 = strstr(p,"\032\032"); /* find beginning of special gdb line */
- X
- X if ((p1 == 0) || ((p2 = strchr(p1+1,'\n')) == 0))
- X {
- X AppendDialogText(p); /* something wrong here */
- X XtFree(cp_output);
- X return;
- X }
- X
- X *p1 = 0;
- X AppendDialogText(p); /* print everything before that line */
- X p = p2 + 1; /* end of that line + skip \n */
- X
- X /* test for beginning of a display */
- X
- X while (re_match(output_pattern[O_EXEC_DISPLAY].buf,p,strlen(p),0,®s) > 0)
- X {
- X /* we found a "X:....\n" pattern */
- X
- X r = output_pattern[O_EXEC_DISPLAY].reg_token[TK_DISP];
- X p1= p+regs.start[r];
- X p2 = p+regs.end[r];
- X
- X /* count number of { and } : if not equal, the next lines are part of this display */
- X begin_struct = 0;
- X while (p1 < p2)
- X {
- X switch(*(p1++))
- X {
- X case '{':
- X begin_struct++;
- X break;
- X case '}':
- X begin_struct--;
- X break;
- X }
- X }
- X
- X p1=p+regs.start[r];
- X *p1 = 0;
- X if (p != p1)
- X AppendDialogText(p); /* print what is before display */
- X p = p2; /* skip display text */
- X
- X if (begin_struct)
- X {
- X /* try to find end of display structure */
- X
- X if (p1 = strstr(p,"\n}\n"))
- X p = p1 + strlen("\n}\n");
- X }
- X }
- X
- X AppendDialogText(p); /* print what is after display */
- X XtFree(cp_output);
- }
- X
- /*--------------------------------------------------------------------------+
- | |
- | * 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;
- {
- X struct re_registers regs;
- X char *p;
- X char *p2;
- X char *p3;
- X int r;
- X static Boolean deleteRest = False;
- X int command_type = -1;
- X static unsigned int already_taken_care;
- X
- X if (output == NULL || !strcmp(output, ""))
- X return;
- X
- /* for GDB, the only things we want to filter are:
- X
- X - the line displayed because of the -fullname option :
- X "\032\032/usr1/gnu_sun4/xdbx/pw.c:6:40:beg:0x22b0\n",
- X
- X - the displayed info which goes into the display window,
- X
- X - list and search outputs
- X
- */
- X if (!string)
- X string = "";
- X
- X if (command)
- X command_type = match(command_pattern, command, C_ANY);
- X
- X if ((command_type == C_EXEC)||(command_type == C_FINISH))
- X {
- X if ((re_match(output_pattern[O_EXEC_MESS_AFTER].buf,string,strlen(string),0,®s) > 0)
- X || (re_match(output_pattern[O_EXEC_MESS_BEFORE].buf,string,strlen(string),0,®s) > 0)
- X || (re_match(output_pattern[O_EXEC].buf,string,strlen(string),0,®s) > 0))
- X {
- X /* remember what was the output length was output was matched */
- X already_taken_care = strlen(output) - strlen(string);
- X
- X /* Remove display messages from output and print what is no a display */
- X
- X if (Prompt)
- X filter_display_info(output + already_taken_care);
- X else
- X deleteRest = True;
- X
- X return;
- X }
- X else
- X {
- X if (deleteRest)
- X {
- X /* Remove display messages from output and print what is no a display */
- X if (Prompt)
- X {
- X filter_display_info(output + already_taken_care);
- X deleteRest = False;
- X }
- X return;
- X }
- X }
- X }
- X
- X /* filter any line starting with \032\032 */
- X
- X p = strchr(string,'\032');
- X if (p && (*(p+1) == '\032') && (p == string || *(p-1) == '\n') && (p2 = strchr(p,'\n')))
- X {
- X while (*(p++) = *(++p2));
- X }
- X
- X if ((command_type == C_EXEC)||(command_type == C_FINISH))
- X {
- X AppendDialogText(string);
- X return;
- X }
- X
- X if (Prompt)
- X {
- X char *s;
- X
- X s = XtNewString(output);
- X switch (command_type)
- X {
- X case C_DISPLAY:
- X if (match(output_pattern, s, O_DISPLAY) != -1)
- X strcpy(s, "");
- X break;
- X case C_SEARCH:
- X if (match(output_pattern, s, O_SEARCH) != -1)
- X strcpy(s, "");
- X break;
- X case C_LIST:
- X if (match(output_pattern, s, O_LIST) != -1)
- X strcpy(s, "");
- X break;
- X case C_PRINT:
- X if(match(output_pattern, s, O_PRINT) == -1)
- X strcpy(s, "");
- X break;
- X
- X default:
- X XtFree(s);
- X s = XtNewString(string); /* append 'string' only */
- X break;
- X }
- X AppendDialogText(s);
- X XtFree(s);
- X }
- X else
- X {
- X switch (command_type)
- X {
- X case C_DISPLAY:
- X case C_SEARCH:
- X case C_LIST:
- X case C_PRINT:
- X break;
- X default:
- X AppendDialogText(string);
- X break;
- X }
- X }
- }
- X
- X
- /*--------------------------------------------------------------------------+
- | |
- | 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;
- {
- X if (command && (match(command_pattern, command, C_SOURCE) != -1))
- X {
- X if (echo)
- X AppendDialogText(command);
- X source_handler();
- X send_command(" \n"); /* ask GDB to redisplay its prompt */
- X return TRUE;
- X }
- X
- X return FALSE;
- }
- X
- X
- /*--------------------------------------------------------------------------+
- | |
- | 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. |
- | |
- +--------------------------------------------------------------------------*/
- int gdb_define_command(command,fp)
- char *command;
- FILE *fp;
- {
- char s[LINESIZ];
- int error_cmd;
- int end_found;
- X
- X if ((command && (match(command_pattern, command, C_DEFINE) != -1))
- X || (command && (match(command_pattern, command, C_DOCUMENT) != -1)))
- X {
- X AppendDialogText(command);
- X send_command(command);
- X
- /*
- X gdb could ask :
- X
- X "Redefine command \"%s\"? "
- X "Really redefine built-in command \"%s\"? "
- X
- X gdb could display
- X
- X "Type commands for definition of \"%s\".\n"
- X "End with a line saying just \"end\"
- X
- X or
- X "Type documentation for \"%s\".\n"
- X "End with a line saying just \"end\".\n"
- X
- X or
- X "Command \"%s\" is built-in."
- */
- X
- X error_cmd = FALSE;
- X
- X /* read message from gdb */
- X
- X while (1)
- X if (fgets(s, LINESIZ, dbxfp))
- X {
- X if (debug)
- X fprintf(stderr, "=>%s", s);
- X
- X if (strstr(s," is built-in.")) /* error for document of built-in command */
- X {
- X AppendDialogText(s);
- X error_cmd = TRUE;
- X bell(0);
- X break;
- X }
- X
- X while (strstr(s,"Redefine command ")
- X || strstr(s,"Really redefine built-in command ")) {
- X write_dbx ("y\n"); /* answer to question if any */
- X fgets(s, LINESIZ, dbxfp);
- X }
- X if (!strcmp(s,"End with a line saying just \"end\".\n"))
- X break;
- X }
- X
- X /* write command definition */
- X
- X end_found = FALSE;
- X
- X while (fgets (s, LINESIZ, fp))
- X {
- X if (!error_cmd)
- X {
- X AppendDialogText(s);
- X write_dbx (s);
- X }
- X
- X if (match(command_pattern, s, C_END) != -1)
- X {
- X end_found = TRUE;
- X break;
- X }
- X }
- X
- X if ((!error_cmd) && (!end_found))
- X {
- X AppendDialogText("Error : missing \"end\" in file.\n");
- X bell(0);
- X write_dbx ("end\n");
- X }
- X
- X return TRUE;
- X }
- X
- X return FALSE;
- }
- X
- X
- SHAR_EOF
- chmod 0664 mxgdb/gdb_parser.c ||
- echo 'restore of mxgdb/gdb_parser.c failed'
- Wc_c="`wc -c < 'mxgdb/gdb_parser.c'`"
- test 18249 -eq "$Wc_c" ||
- echo 'mxgdb/gdb_parser.c: original size 18249, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= mxgdb/gdb_regex.h ==============
- if test -f 'mxgdb/gdb_regex.h' -a X"$1" != X"-c"; then
- echo 'x - skipping mxgdb/gdb_regex.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting mxgdb/gdb_regex.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/gdb_regex.h' &&
- /* $Id: gdb_regex.h,v 1.2 1991/06/28 20:32:32 jtsillas Exp $ */
- X
- /*****************************************************************************
- X *
- X * xdbx - X Window System interface to the dbx debugger
- X *
- X * Copyright 1989 The University of Texas at Austin
- X * Copyright 1990 Microelectronics and Computer Technology Corporation
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * 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, and that the name of The University of Texas
- X * and Microelectronics and Computer Technology Corporation (MCC) not be
- X * used in advertising or publicity pertaining to distribution of
- X * the software without specific, written prior permission. The
- X * University of Texas and MCC makes no representations about the
- X * suitability of this software for any purpose. It is provided "as is"
- X * without express or implied warranty.
- X *
- X * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
- X * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- X * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
- X * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- X * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- X * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- X *
- X * Author: Po Cheung
- X * Created: March 10, 1989
- X *
- X *****************************************************************************
- X *
- X * xxgdb - X Window System interface to the gdb debugger
- X *
- X * Copyright 1990 Thomson Consumer Electronics, Inc.
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * 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, and that the name of Thomson Consumer
- X * Electronics (TCE) not be used in advertising or publicity pertaining
- X * to distribution of the software without specific, written prior
- X * permission. TCE makes no representations about the suitability of
- X * this software for any purpose. It is provided "as is" without express
- X * or implied warranty.
- X *
- X * TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
- X * SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
- X * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- X * SOFTWARE.
- X *
- X * Adaptation to GDB: Pierre Willard
- X * XXGDB Created: December, 1990
- X *
- X *****************************************************************************/
- X
- /*
- X * gdb_regex.h:
- X *
- X * Regular expression pattern matching for GNU gdb.
- 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 * reg_token[5] : display command output
- X */
- X
- #define TK_MESG 0
- #define TK_STOP 1
- #define TK_FUNC 2
- #define TK_LINE 3
- #define TK_FILE 4
- #define TK_DISP 5
- X
- #define O_EXEC_MESS_AFTER 0
- #define O_EXEC_MESS_BEFORE 1
- #define O_EXEC 2
- #define O_DONE 3
- #define O_BREAK 4 /* Instead of O_STOPAT & O_STOPIN */
- SHAR_EOF
- true || echo 'restore of mxgdb/gdb_regex.h failed'
- fi
- echo 'End of part 5'
- echo 'File mxgdb/gdb_regex.h is continued in part 6'
- echo 6 > _shar_seq_.tmp
- exit 0
- --
- == James Tsillas Bull HN Information Systems Inc. ==
- == (508) 294-2937 300 Concord Road 826A ==
- == jtsillas@bubba.ma30.bull.com Billerica, MA 01821 ==
- == ==
- == The opinions expressed above are solely my own and do not reflect ==
- == those of my employer. ==
- -== no solicitations please ==-
-