v08i108: xdbx -- Dbx for X11, Part04/07
Po Cheung
cheung%SW.MCC.COM at MCC.COM
Tue Aug 28 18:04:12 AEST 1990
Submitted-by: cheung%SW.MCC.COM at MCC.COM (Po Cheung)
Posting-number: Volume 8, Issue 108
Archive-name: xdbx/part04
#! /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 4 (of 7)."
# Contents: handler.c signs.c xdbx.c
# Wrapped by cheung at espresso.sw.mcc.com on Fri Aug 24 03:24:50 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'handler.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'handler.c'\"
else
echo shar: Extracting \"'handler.c'\" \(13092 characters\)
sed "s/^X//" >'handler.c' <<'END_OF_FILE'
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/* handler.c
X *
X * Contain action handlers for the parser to invoke upon a dbx command.
X *
X * TextSetTopPosition(): Set the top character position of text displayed
X * AdjustText(): Adjust the portion of text displayed.
X * exec_handler(): Update file, line label, arrow position.
X * done_handler(): Progrm execution completed, clear breakpoints
X * stop_at_handler(): Place stop sign on line specified.
X * stop_in_handler(): Place stop sign on function specified.
X * updown_handler(): Update file, line label, updown arrow position.
X * delete_handler(): Remove stop sign.
X * func_handler(): Display function, if specified.
X * file_handler(): Display file, if specified.
X * debug_handler(): Check directory use list, display source file.
X * cd_handler(): Record current working directory.
X * use_handler(): Record directory paths.
X * search_handler(): Adjust source file to display matched line.
X * list_handler(); Adjust source file to display result.
X * display_handler(): Display results in display window.
X */
X
X#include <ctype.h>
X#include "global.h"
X#ifdef BSD
X#define BRACKET "[%d]"
X#else
X#define BRACKET "(%d)"
X#endif
X
XBoolean Echo = True; /* display dbx output if true */
Xstatic Boolean Skip_func_handler = False;
X
X/* Display text starting from the top position specified by pos */
X
Xvoid TextSetTopPosition(w, pos)
X Widget w;
X XawTextPosition pos;
X{
X Arg args[MAXARGS];
X Cardinal n;
X
X n = 0;
X XtSetArg(args[n], XtNdisplayPosition, (XtArgVal) pos); n++;
X XtSetValues(w, args, n);
X}
X
X/*
X * Adjust text so that 'line' will fall into the viewable part of the
X * source window.
X * Arrows, stop signs, and line label are updated accordingly.
X */
Xvoid AdjustText(line)
X int line;
X{
X FileRec *file;
X int nlines = 0;
X int i;
X XawTextPosition pos;
X
X if ((file = displayedFile) == NULL || line <= 0) return;
X file->currentline = line;
X
X if (line < file->topline || line > file->bottomline ) {
X /* Position line about 30% from the top */
X nlines = file->lines*0.3;
X if (line < nlines) /* near top */
X file->topline = 1;
X else if (line > file->lastline - nlines) /* near bottom */
X file->topline = MAX(file->lastline - file->lines + 1, 1);
X else
X file->topline = line - nlines;
X file->bottomline = MIN(file->topline + file->lines - 1, file->lastline);
X TextSetTopPosition(sourceWindow, file->linepos[file->topline]);
X file->topPosition = file->linepos[file->topline];
X }
X XawTextSetInsertionPoint(sourceWindow, file->linepos[line]);
X
X /* Text window might have scrolled, check topline & bottomline */
X pos = XawTextTopPosition(sourceWindow);
X for (i=1; pos >= file->linepos[i]; i++);
X if (file->topline != i-1) {
X file->topline = i-1;
X file->bottomline = MIN (file->topline + file->lines - 1,
X file->lastline);
X }
X UpdateLineLabel(line);
X UpdateStops(file);
X UpdateArrow(file);
X UpdateUpdown(file);
X UpdateBomb(file);
X}
X
X
X/* Handle dbx output of run, cont, next, step, return commands.
X * Result of output parsing is returned in a set of tokens.
X */
Xvoid exec_handler()
X{
X int line, status;
X char *func, *mesg;
X char *segv = "signal SEGV";
X char *segfault = "Segmentation fault";
X
X /* Print "stopped in ..." line in message window
X * Adjust text displayed
X */
X if (Token.func == NULL || Token.line == 0)
X return;
X UpdateMessageWindow(Token.mesg);
X line = Token.line;
X func = XtNewString(Token.func);
X mesg = XtNewString(Token.mesg);
X#ifdef MIPS
X status = LoadCurrentFile();
X#else
X if (Token.file)
X status = LoadFile(Token.file);
X#endif
X arrow.line = line; /* update arrow sign position */
X strcpy(arrow.func, func);
X updown.line = 0; /* remove updown, if any */
X if (displayedFile) {
X strcpy(arrow.file, displayedFile->pathname);
X }
X /* Display bomb sign if segmentation fault occurs in source code */
X if (status != -1 && (strncmp(mesg, segv, strlen(segv)) == NULL ||
X strncmp(mesg, segfault, strlen(segfault)) == NULL)) {
X arrow.line = 0;
X bomb.line = line;
X strcpy(bomb.func, func);
X if (displayedFile) strcpy(bomb.file, displayedFile->pathname);
X }
X else
X bomb.line = 0;
X
X AdjustText(line);
X#ifndef BSD
X display_handler();
X#endif
X XtFree(func);
X XtFree(mesg);
X}
X
X
X/* Remove all the arrow and updown signs, print message, then
X * change the file variable to the file name displayed.
X */
Xvoid done_handler()
X{
X char command[LINESIZ];
X
X arrow.line = 0;
X updown.line = 0;
X UpdateArrow(displayedFile);
X UpdateUpdown(displayedFile);
X UpdateMessageWindow("Ready for execution");
X if (displayedFile == NULL) return;
X#ifdef MIPS
X sprintf(command, "file %s\n", displayedFile->filename);
X#else
X sprintf(command, "file %s\n", displayedFile->pathname);
X#endif
X Parse = False;
X query_dbx(command);
X}
X
X
X/* Place a stop sign next to the line specified on the source file window
X * if it is to be viewable.
X */
Xvoid stop_at_handler()
X{
X if (Token.stop == 0 || Token.line == 0 || displayedFile == NULL)
X return;
X if (Token.file == NULL)
X stops[Token.stop].file = displayedFile->pathname;
X else
X stops[Token.stop].file = GetPathname(Token.file);
X DisplayStop(displayedFile, Token.line);
X stops[Token.stop].line = Token.line;
X stops[Token.stop].tag = 0;
X nstops = Token.stop;
X}
X
X
X/*
X * Place a stop sign next to the function routine, getting the line number
X * by "list <func>", (or "func <func>" on a MIPS), and resetting the file
X * variable properly.
X */
Xvoid stop_in_handler()
X{
X char command[LINESIZ], *file;
X int stop;
X int line;
X
X if (Token.stop == 0 || Token.func == NULL || displayedFile == NULL)
X return;
X stop = Token.stop;
X#ifdef MIPS
X /* For mips dbx, need to use func command to locate the function */
X Skip_func_handler = True;
X sprintf(command, "func %s\n", Token.func);
X query_dbx(command);
X#else
X#ifdef BSD
X sprintf(command, "list %s\n", Token.func);
X query_dbx(command);
X#else
X sprintf(command, "list %s\n", Token.func);
X query_dbx(command);
X if (Token.line <= 0)
X return;
X else
X Token.line += 5;
X#endif
X#endif
X
X stops[stop].line = Token.line;
X nstops = stop;
X line = Token.line;
X
X /* Check the name of the file containing Token.func */
X query_dbx("file\n");
X if ((file = GetPathname(CurrentFile)) &&
X strcmp(file, displayedFile->pathname)) { /* new file, record stop */
X stops[nstops].file = file;
X#ifdef MIPS
X sprintf(command, "file %s\n", displayedFile->filename);
X#else
X sprintf(command, "file %s\n", displayedFile->pathname);
X#endif
X Parse = False;
X query_dbx(command);
X }
X else { /* same file, display stop */
X stops[nstops].file = displayedFile->pathname;
X DisplayStop(displayedFile, line);
X }
X}
X
X
X/*
X * Display an outlined arrow to locate the calling routine in a stack
X * frame. BSD and SUN dbx have slightly different output semantics here.
X * The appropriate file with the calling routine is displayed and the
X * file variable is set accordingly.
X */
Xvoid updown_handler()
X{
X char command[LINESIZ], *func, *file;
X int line;
X
X line = Token.line;
X func = XtNewString(Token.func);
X#ifdef MIPS
X LoadCurrentFile();
X#endif
X#ifdef BSD
X file = GetPathname(Token.file);
X#else
X if (line <= 0) line = 1;
X LoadCurrentFile();
X if (displayedFile)
X file = displayedFile->pathname;
X#endif
X
X if (line <= 0 || func == NULL || file == NULL)
X return;
X if (displayedFile && strcmp(file, displayedFile->pathname)) {
X LoadFile(file);
X /* set dbx file variable to file */
X#ifdef MIPS
X sprintf(command, "file %s\n", displayedFile->filename);
X#else
X sprintf(command, "file %s\n", displayedFile->pathname);
X#endif
X Parse = False;
X query_dbx(command);
X }
X updown.line = line;
X strcpy(updown.func, func);
X if (displayedFile)
X strcpy(updown.file, displayedFile->pathname);
X AdjustText(line);
X XtFree(func);
X}
X
X
X/*
X * Delete handler remove the stop specified and undisplayed the stopsign
X * if it's visible.
X * It calls the dbx status command to find out what stops are left, and
X * then update the array of stops accordingly.
X */
X/* ARGSUSED */
Xvoid delete_handler()
X{
X char s[LINESIZ];
X int i;
X int line;
X
X write_dbx("status\n");
X while (fgets(s, LINESIZ, dbxfp) == NULL);
X do {
X if (strcmp(s, dbxprompt) || strcmp(s, "")) {
X sscanf(s, BRACKET, &i);
X if (i > 0 && i <= nstops && stops[i].line > 0)
X stops[i].tag = 1;
X }
X } while (fgets(s, LINESIZ, dbxfp));
X
X for (i=1; i<=nstops; i++)
X if (stops[i].line > 0) {
X if (stops[i].tag)
X stops[i].tag = 0;
X else {
X line = stops[i].line;
X stops[i].line = 0;
X stops[i].file = NULL;
X if (LineToStop_no(line) == 0)
X RemoveStop(line);
X }
X }
X}
X
X/*
X * This handler displays the function routine on the source window.
X * It locates the function by sending the dbx command "list <func>",
X * and loads the appropriate file accordingly.
X */
Xvoid func_handler()
X{
X int line;
X char command[LINESIZ];
X
X if (Token.func && !Skip_func_handler) {
X#ifdef MIPS
X line = Token.line;
X#else
X sprintf(command, "list %s\n", Token.func);
X query_dbx(command);
X line = Token.line + 5;
X#endif
X LoadCurrentFile();
X AdjustText(line);
X }
X Skip_func_handler = False;
X}
X
X
X/* File handler first queries the current file set by the user command,
X * and then loads the file.
X */
X/* ARGSUSED */
Xvoid file_handler() /* Command was 'file' */
X{
X if (Token.file)
X strcpy(CurrentFile, Token.file);
X else
X strcpy(CurrentFile, "");
X}
X
X/* ARGSUSED */
Xvoid debug_handler()
X{
X query_dbx("use\n");
X displayedFile = NULL; /* force reloading of source file */
X if (LoadCurrentFile() == 0) {
X arrow.line = 0; /* clear arrow sign */
X updown.line = 0; /* clear updown sign */
X bomb.line = 0; /* clear bomb sign */
X UpdateArrow(displayedFile);
X UpdateUpdown(displayedFile);
X UpdateBomb(displayedFile);
X ClearStops();
X UpdateStops(displayedFile);
X UpdateMessageWindow("Ready for execution");
X query_dbx("func main\n");
X#ifndef BSD
X query_dbx("display\n"); /* clear display window */
X#endif
X }
X}
X
X/* ARGSUSED */
Xvoid cd_handler()
X{
X query_dbx("pwd\n");
X}
X
X/* ARGSUSED */
Xvoid pwd_handler(s)
Xchar *s;
X{
X strcpy(cwd, (char *)strtok(s, "\n"));
X}
X
X/* ARGSUSED */
Xvoid use_handler(output)
Xchar *output;
X{
X if (strcmp(output, "") == NULL)
X query_dbx("use\n");
X else
X MakeDirList(output);
X}
X
X/* ARGSUSED */
Xvoid search_handler()
X{
X AdjustText(Token.line);
X}
X
X/* ARGSUSED */
Xvoid list_handler()
X{
X int line;
X
X if (Echo) {
X line = Token.line;
X LoadCurrentFile();
X AdjustText(line);
X }
X}
X
X
X/* ARGSUSED */
X/* Show output on the display window.
X * If output is null but the display window is managed, replace contents of
X * the display window with the null string.
X */
Xvoid display_handler()
X{
X Arg args[MAXARGS];
X Cardinal n;
X
X if (!Token.display || strcmp(Token.display, "") == NULL) {
X if (!XtIsManaged(displayWindow))
X return;
X else {
X XtFree(Token.display);
X Token.display = XtNewString("");
X }
X }
X if (!XtIsManaged(displayWindow)) {
X XtManageChild(separator);
X XtManageChild(displayWindow);
X }
X n = 0;
X XtSetArg(args[n], XtNstring, (XtArgVal) Token.display); n++;
X XtSetValues(displayWindow, args, n);
X XtFree(Token.display);
X}
END_OF_FILE
if test 13092 -ne `wc -c <'handler.c'`; then
echo shar: \"'handler.c'\" unpacked with wrong size!
fi
# end of 'handler.c'
fi
if test -f 'signs.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'signs.c'\"
else
echo shar: Extracting \"'signs.c'\" \(11423 characters\)
sed "s/^X//" >'signs.c' <<'END_OF_FILE'
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/* signs.c
X *
X * This file contains all the routines for the creation and manipulation of
X * symbols used in xdbx. There are 3 different signs:
X * arrow - a solid right arrow to indicate the current execution point.
X * updown - an outlined right arrow to indicate position in stack trace.
X * stop - a stop hand symbol to indicate a breakpoint is set.
X * bomb - a bomb symbol to indicate the point of segmentation fault.
X *
X * To display a sign on a given line in the source window, it is first
X * created and mapped. To undisplay it, the sign is unmapped. It can
X * be mapped again when the sign is needed. Note that the sign is never
X * moved, so that there can be as many signs created (but not mapped) as
X * the number of lines in the source window.
X * For arrow and updown, there can be at most one of each mapped at a time.
X * For stop, there can be more than one mapped at the same time.
X */
X
X#include "global.h"
X#include "bitmaps.h"
X
X#define MAXSTOPS 256 /* max number of stops */
X#define MAXSIGNS 256 /* max number of signs */
X#define OFFSET 2 /* offset for displaying signs */
X
Xtypedef struct {
X Widget w;
X Boolean mapped;
X} ArrowSign;
X
Xtypedef struct {
X Widget w;
X Boolean mapped;
X} UpdownSign;
X
Xtypedef struct {
X Widget w;
X Boolean mapped;
X} StopSign;
X
Xtypedef struct {
X Widget w;
X Boolean mapped;
X} BombSign;
X
Xstatic ArrowSign arrowsign[MAXSIGNS];
Xstatic UpdownSign updownsign[MAXSIGNS];
Xstatic StopSign stopsign[MAXSIGNS];
Xstatic BombSign bombsign[MAXSIGNS];
X
XArrow arrow;
XUpdown updown;
XStops stops[MAXSTOPS]; /* array of stops */
XBomb bomb;
XCardinal nstops; /* number of stops */
X
X/* Initialize data structures */
X
Xvoid signs_init()
X{
X int i;
X
X for (i=0; i<MAXSIGNS; i++) {
X arrowsign[i].w = NULL;
X arrowsign[i].mapped = FALSE;
X }
X for (i=0; i<MAXSIGNS; i++) {
X stopsign[i].w = NULL;
X stopsign[i].mapped = FALSE;
X }
X arrow.i = 0;
X arrow.line = 0;
X strcpy(arrow.file, "");
X updown.i = 0;
X updown.line = 0;
X strcpy(updown.file, "");
X nstops = 0;
X bomb.i = 0;
X bomb.line = 0;
X strcpy(bomb.file, "");
X}
X
X
X/* Create an arrow symbol, updown symbol or stop symbol:
X * calculate the position of the symbol based on i, the number of lines
X * from the top line.
X * create the pixmap of the symbol
X * display the symbol as a bitmap in a label widget.
X */
Xstatic Widget CreateSign(parent, sign, i)
X Widget parent;
X char *sign;
X Cardinal i;
X{
X TextWidget ctx = (TextWidget) sourceWindow;
X Arg args[15];
X Cardinal n;
X Dimension source_height, height, width;
X char *bits;
X Pixel fg, bg;
X int horizDistance, vertDistance, height_per_line;
X int screen;
X Dimension vbar_width = 0;
X Dimension border_width = 0;
X
X if (displayedFile == NULL) return NULL;
X
X /* Get height and background pixel values of parent window */
X n = 0;
X XtSetArg(args[n], XtNheight, &source_height); n++;
X XtSetArg(args[n], XtNbackground, &bg); n++;
X XtGetValues(parent, args, n);
X
X height_per_line = source_height/displayedFile->lines;
X vertDistance = OFFSET + (i * height_per_line);
X
X screen = DefaultScreen(display);
X
X if (sign && !strcmp(sign, "arrow")) {
X bits = arrow_bits;
X width = arrow_width;
X height = arrow_height;
X horizDistance = 0;
X fg = app_resources.arrow_color;
X }
X else if (sign && !strcmp(sign, "updown")) {
X bits = updown_bits;
X width = updown_width;
X height = updown_height;
X horizDistance = 0;
X fg = app_resources.updown_color;
X }
X else if (sign && !strcmp(sign, "stop")) {
X bits = stop_bits;
X width = stop_width;
X height = stop_height;
X horizDistance = arrow_width;
X fg = app_resources.stop_color;
X }
X else if (sign && !strcmp(sign, "bomb")) {
X bits = bomb_bits;
X width = bomb_width;
X height = bomb_height;
X horizDistance = 0;
X fg = app_resources.bomb_color;
X };
X
X if( ctx->text.vbar != NULL )
X {
X n = 0;
X XtSetArg(args[n], XtNwidth, &vbar_width); n++;
X XtSetArg(args[n], XtNborderWidth, &border_width); n++;
X XtGetValues(ctx->text.vbar, args, n);
X vbar_width += (border_width * 2);
X }
X
X n = 0;
X XtSetArg(args[n], XtNborderWidth, 0); n++;
X XtSetArg(args[n], XtNwidth, (XtArgVal) width); n++;
X XtSetArg(args[n], XtNheight, (XtArgVal) height); n++;
X XtSetArg(args[n], XtNresize, (XtArgVal) False); n++;
X XtSetArg(args[n], XtNmappedWhenManaged, (XtArgVal) False); n++;
X XtSetArg(args[n], XtNbitmap, XCreatePixmapFromBitmapData (
X display, DefaultRootWindow(display), bits, width, height,
X fg, bg, DefaultDepth(display, screen))); n++;
X
X XtSetArg(args[n], XtNfromVert, (XtArgVal) NULL); n++;
X XtSetArg(args[n], XtNfromHoriz, (XtArgVal) NULL); n++;
X XtSetArg(args[n], XtNhorizDistance, (XtArgVal) horizDistance+vbar_width);
X n++;
X XtSetArg(args[n], XtNvertDistance, (XtArgVal) vertDistance); n++;
X XtSetArg(args[n], XtNtop, (XtArgVal) XawChainTop); n++;
X XtSetArg(args[n], XtNleft, (XtArgVal) XawChainLeft); n++;
X XtSetArg(args[n], XtNbottom, (XtArgVal) XawChainTop); n++;
X XtSetArg(args[n], XtNright, (XtArgVal) XawChainLeft); n++;
X
X return XtCreateManagedWidget(sign, labelWidgetClass, parent, args, n);
X}
X
X/*
X * Given a line number, displays a stop sign if that line is viewable.
X * If the stop widget for that line does not exist, create one and map it.
X * If the stop widget exists but not mapped, map it.
X */
Xvoid DisplayStop(file, line)
XFileRec *file;
Xint line;
X{
X Cardinal i;
X
X if (line >= file->topline && line <= file->bottomline) {
X i = line - file->topline;
X if (stopsign[i].w == NULL) { /* widget does not exist */
X stopsign[i].w = CreateSign(sourceForm, "stop", i);
X XtMapWidget(stopsign[i].w);
X stopsign[i].mapped = 1;
X }
X else if (!stopsign[i].mapped) { /* widget not mapped */
X XtMapWidget(stopsign[i].w);
X stopsign[i].mapped = 1;
X }
X }
X}
X
X/*
X * Unmap all stop signs and then display only those stops that are viewable.
X */
Xvoid UpdateStops(file)
XFileRec *file;
X{
X Cardinal i;
X int line;
X
X if (file == NULL) return;
X for (i=0; i<file->lines; i++)
X if (stopsign[i].w && stopsign[i].mapped) {
X XtUnmapWidget(stopsign[i].w);
X stopsign[i].mapped = 0;
X }
X
X for (i=1; i<=nstops; i++)
X if (stops[i].file && !strcmp(stops[i].file, file->pathname) &&
X (line=stops[i].line) && line >= file->topline &&
X line <= file->bottomline) {
X DisplayStop(file, line);
X }
X}
X
X/*
X * Given a line number, unmap the stop sign associated with that line.
X */
Xvoid RemoveStop(line)
Xint line;
X{
X Cardinal i;
X
X if (displayedFile && line >= displayedFile->topline &&
X line <= displayedFile->bottomline) {
X i = line - displayedFile->topline;
X if (stopsign[i].w && stopsign[i].mapped) {
X XtUnmapWidget(stopsign[i].w);
X stopsign[i].mapped = 0;
X }
X }
X}
X
Xvoid ClearStops()
X{
X int i;
X
X for (i=1; i<=nstops; i++) {
X stops[i].file = NULL;
X stops[i].line = 0;
X }
X}
X
X/* Unmap the current arrow sign.
X * Display a new arrow sign if it is viewable.
X */
Xvoid UpdateArrow(file)
XFileRec *file;
X{
X Cardinal i;
X int line;
X
X if (file == NULL) return;
X i = arrow.i;
X if (i>=0 && i<file->lines)
X if (arrowsign[i].w && arrowsign[i].mapped) {
X XtUnmapWidget(arrowsign[i].w);
X arrowsign[i].mapped = 0;
X }
X line = arrow.line;
X if (arrow.file && !strcmp(arrow.file, file->pathname) &&
X line >= file->topline && line <= file->bottomline) {
X i = line - file->topline;
X arrow.i = i;
X if (arrowsign[i].w == NULL) {
X arrowsign[i].w = CreateSign(sourceForm, "arrow", i);
X XtMapWidget(arrowsign[i].w);
X arrowsign[i].mapped = TRUE;
X }
X else if (!arrowsign[i].mapped) {
X XtMapWidget(arrowsign[i].w);
X arrowsign[i].mapped = TRUE;
X }
X }
X}
X
X
X/* If the new updown is on the same line as the arrow, remove the updown.
X * Unmap current updown sign.
X * Display the updown if it is viewable.
X */
Xvoid UpdateUpdown(file)
XFileRec *file;
X{
X Cardinal i;
X int line;
X
X if (file == NULL) return;
X if (updown.file && !strcmp(updown.file, arrow.file) &&
X !strcmp(updown.func, arrow.func)) {
X updown.line = 0;
X strcpy(updown.file, "");
X }
X i = updown.i;
X if (i>=0 && i<file->lines)
X if (updownsign[i].w && updownsign[i].mapped) {
X XtUnmapWidget(updownsign[i].w);
X updownsign[i].mapped = 0;
X }
X line = updown.line;
X if (updown.file && !strcmp(updown.file, file->pathname) &&
X line >= file->topline && line <= file->bottomline) {
X i = line - file->topline;
X updown.i = i;
X if (updownsign[i].w == NULL) {
X updownsign[i].w = CreateSign(sourceForm, "updown", i);
X XtMapWidget(updownsign[i].w);
X updownsign[i].mapped = TRUE;
X }
X else if (!updownsign[i].mapped) {
X XtMapWidget(updownsign[i].w);
X updownsign[i].mapped = TRUE;
X }
X }
X}
X
X/* Unmap the current bomb sign, if any.
X * Display a new bomb sign.
X */
Xvoid UpdateBomb(file)
XFileRec *file;
X{
X Cardinal i;
X int line;
X
X if (file == NULL) return;
X i = bomb.i;
X if (i>=0 && i<file->lines)
X if (bombsign[i].w && bombsign[i].mapped) {
X XtUnmapWidget(bombsign[i].w);
X bombsign[i].mapped = 0;
X }
X line = bomb.line;
X if (bomb.file && !strcmp(bomb.file, file->pathname) &&
X line >= file->topline && line <= file->bottomline) {
X i = line - file->topline;
X bomb.i = i;
X if (bombsign[i].w == NULL) {
X bombsign[i].w = CreateSign(sourceForm, "bomb", i);
X XtMapWidget(bombsign[i].w);
X bombsign[i].mapped = TRUE;
X }
X else if (!bombsign[i].mapped) {
X XtMapWidget(bombsign[i].w);
X bombsign[i].mapped = TRUE;
X }
X }
X}
END_OF_FILE
if test 11423 -ne `wc -c <'signs.c'`; then
echo shar: \"'signs.c'\" unpacked with wrong size!
fi
# end of 'signs.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'\" \(12215 characters\)
sed "s/^X//" >'xdbx.c' <<'END_OF_FILE'
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/* xdbx.c
X *
X * Contain main program and initialization, command line options handling,
X * and resource database management.
X *
X * Syntax(): Print an error message if xdbx is invoked with an
X * incorrect number of arguments.
X * main_init(): Initialization routine.
X * dbxoptions(): Construct command line arguments for dbx.
X * main(): Main program.
X */
X
X#include "global.h"
X#include "bitmaps.h"
X#include "patchlevel.h"
X
X#define VERSION "2.1"
X#define Offset(field) (XtOffset(XdbxResources *, field))
X
XXtAppContext app_context; /* application context */
XWidget toplevel; /* top level widget */
XDisplay *display; /* connection to X server */
XCursor watch; /* XC_watch cursor */
XXdbxResources app_resources; /* application resources of xdbx */
Xchar xdbxinit[LINESIZ]; /* initialization file name */
XBoolean Tstartup = False; /* if True, remove xdbxinit */
XBoolean debug = False; /* debug mode for xdbx */
X
X
Xstatic XtResource resources[] = {
X {"bell", "Bell", XtRBoolean, sizeof(Boolean),
X Offset(bell), XtRImmediate, (caddr_t)False},
X {"displayWindow", "DisplayWindow", XtRBoolean, sizeof(Boolean),
X Offset(displayWindow), XtRImmediate, (caddr_t)False},
X {"prompt", "Prompt", XtRString, sizeof(char *),
X Offset(prompt), XtRImmediate, (caddr_t)NULL},
X {"delimiters", "Delimiters", XtRString, sizeof(char *),
X Offset(delimiters), XtRImmediate, (caddr_t)NULL},
X {"stop_color", "StopColor", XtRPixel, sizeof(Pixel),
X Offset(stop_color), XtRString, "Red"},
X {"arrow_color", "ArrowColor", XtRPixel, sizeof(Pixel),
X Offset(arrow_color), XtRString, "Blue"},
X {"updown_color", "UpdownColor", XtRPixel, sizeof(Pixel),
X Offset(updown_color), XtRString, "Blue"},
X {"bomb_color", "bombColor", XtRPixel, sizeof(Pixel),
X Offset(bomb_color), XtRString, "Red"},
X {"dataDpyMaxHeight", "DataDpyMaxHeight", XtRDimension, sizeof(Dimension),
X Offset(dataDpyMaxHeight), XtRString, "300"},
X {"dataDpyMaxWidth", "DataDpyMaxWidth", XtRDimension, sizeof(Dimension),
X Offset(dataDpyMaxWidth), XtRString, "600"},
X {"bigicon", "Xdbxoptions", XtRBoolean, sizeof(Boolean),
X Offset(bigicon), XtRImmediate, (caddr_t)False},
X {"debug", "Xdbxoptions", XtRBoolean, sizeof(Boolean),
X Offset(debug), XtRImmediate, (caddr_t)False},
X {"dbxopt_r", "Dbxoptions", XtRBoolean, sizeof(Boolean),
X Offset(dbxopt_r), XtRImmediate, (caddr_t)False},
X {"dbxopt_i", "Dbxoptions", XtRBoolean, sizeof(Boolean),
X Offset(dbxopt_i), XtRImmediate, (caddr_t)False},
X {"includeDir", "Dbxoptions", XtRString, sizeof(char *),
X Offset(includeDir), XtRImmediate, (caddr_t)NULL},
X {"dbxopt_k", "Dbxoptions", XtRBoolean, sizeof(Boolean),
X Offset(dbxopt_k), XtRImmediate, (caddr_t)False},
X {"cfile", "Dbxoptions", XtRString, sizeof(char *),
X Offset(cfile), XtRImmediate, (caddr_t)NULL},
X {"dbxopt_kbd", "Dbxoptions", XtRBoolean, sizeof(Boolean),
X Offset(dbxopt_kbd), XtRImmediate, (caddr_t)False},
X {"fcount", "Dbxoptions", XtRString, sizeof(char *),
X Offset(fcount), XtRImmediate, (caddr_t)NULL},
X {"startup", "Dbxoptions", XtRString, sizeof(char *),
X Offset(startup), XtRImmediate, (caddr_t)NULL},
X {"tstartup", "Dbxoptions", XtRString, sizeof(char *),
X Offset(tstartup), XtRImmediate, (caddr_t)NULL},
X};
X
X
XString fallback_resources[] = {
X "*allowShellResize: True",
X "*borderWidth: 1",
X "*font: fixed",
X "*vpane.width: 550",
X "*fileWindow*font: variable",
X "*fileLabel.width: 500",
X "*lineLabel.width: 50",
X "*sourceForm.preferredPaneSize: 320",
X "*sourceWindow.leftMargin: 35",
X "*sourceWindow.scrollHorizontal: whenNeeded",
X "*sourceWindow.translations: #override \\n\
X <Btn1Down>: SelectStart() SelectWord() \\n\
X Shift<Btn1Up>: Update() SelectEnd() PrintSelection() \\n\
X <Btn1Up>: Update() SelectEnd() \\n",
X "*messageWindow*font: variable",
X "*messageWindow.min: 30",
X "*messageWindow.max: 30",
X "*dialogWindow.preferredPaneSize: 200",
X "*dialogWindow.resizeToPreferred: True",
X "*dialogWindow.translations: #override \\n\
X <Btn1Down>: SelectStart() SelectWord() \\n\
X Shift<Btn1Up>: SelectEnd() PrintSelection() \\n\
X <Btn1Up>: SelectEnd() \\n",
X "*commandWindow.preferredPaneSize: 106",
X "*commandWindow.skipAdjust: True",
X "*commandWindow.hSpace: 14",
X "*commandWindow.vSpace: 10",
X "*Command.height: 20",
X "*Command.width: 60",
X "*List.columnSpacing: 10",
X "*displayWindow.preferredPaneSize: 50",
X "*displayWindow.skipAdjust: True",
X "*displayWindow.scrollVertical: whenNeeded",
X "*displayWindow.scrollHorizontal: whenNeeded",
X "*displayWindow.translations: #override \\n\
X <Btn1Down>: SelectStart() SelectWord() \\n\
X Shift<Btn1Up>: SelectEnd() PrintSelection() \\n\
X <Btn1Up>: SelectEnd() \\n",
X "*popup*showGrip: False",
X NULL,
X};
X
Xstatic XrmOptionDescRec options[] = {
X {"-bigicon","bigicon", XrmoptionNoArg, "True"},
X {"-debug", "debug", XrmoptionNoArg, "True"},
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 dbx */
X {"-kbd", "dbxopt_kbd", XrmoptionNoArg, "True"},
X {"-f", "fcount", XrmoptionSepArg, NULL},
X {"-s", "startup", XrmoptionSepArg, NULL},
X {"-sr", "tstartup", XrmoptionSepArg, NULL},
X#endif
X#ifdef MIPS /* Mips dbx */
X {"-pixie", "pixie", XrmoptionNoArg, "True"},
X#endif
X};
X
XXtActionsRec xdbx_actions[] = {
X {"SelectStart", (XtActionProc) SelectStart},
X {"SelectEnd", (XtActionProc) SelectEnd},
X {"SelectWord", (XtActionProc) SelectWord},
X {"PrintSelection", (XtActionProc) PrintSelection},
X {"Update", (XtActionProc) Update},
X {"DeleteWord", (XtActionProc) DeleteWord},
X {"DeleteLine", (XtActionProc) DeleteLine},
X {NULL, NULL}
X};
X
Xstatic void Syntax(call)
Xchar *call;
X{
X fprintf(stderr,
X "Usage: %s [-toolkitoptions] [-dbxoptions] [objfile [corefile]]\n",
X call);
X exit(1);
X}
X
X/* Set window manager hints to indicate display accepts input.
X * Initialize routines in source.c, signs.c and parser.c.
X * Disable window resize of fileWindow.
X * Get the name of the dbx command initialization file.
X */
Xstatic void main_init()
X{
X XWMHints wmhints;
X char title[100];
X
X display = XtDisplay(toplevel);
X watch = XCreateFontCursor(display, XC_watch);
X
X sprintf(title, "xdbx %s (patch level %d)", VERSION, PATCHLEVEL);
X XStoreName(display, XtWindow(toplevel), title);
X XSetIconName(display, XtWindow(toplevel), "xdbx");
X wmhints.input = True;
X if (app_resources.bigicon)
X wmhints.icon_pixmap = XCreateBitmapFromData(display, XtWindow(toplevel),
X xdbx64_bits, xdbx64_width, xdbx64_height);
X else
X wmhints.icon_pixmap = XCreateBitmapFromData(display, XtWindow(toplevel),
X xdbx48_bits, xdbx48_width, xdbx48_height);
X wmhints.flags = IconPixmapHint | InputHint;
X XSetWMHints(display, XtWindow(toplevel), &wmhints);
X
X if (!app_resources.delimiters ||
X strcmp(app_resources.delimiters, "") == NULL)
X app_resources.delimiters = XtNewString(DELIMITERS);
X if (app_resources.prompt && strcmp(app_resources.prompt, "") != NULL)
X xdbxprompt = app_resources.prompt;
X else
X xdbxprompt = XtNewString(XDBXPROMPT);
X debug = app_resources.debug;
X DisableWindowResize(fileWindow);
X
X strcpy(xdbxinit, ".dbxinit");
X if (access(xdbxinit, R_OK) == -1) {
X sprintf(xdbxinit, "%s/%s", (char *) getenv("HOME"), ".dbxinit");
X if (access(xdbxinit, R_OK) == -1) {
X strcpy(xdbxinit, "");
X }
X }
X source_init();
X signs_init();
X parser_init();
X}
X
X
X/* Reconstruct command line arguments for calling dbx.
X * Return the argument list for dbx and new value of argc.
X */
Xstatic char **dbxoptions(argc, argv, app_resources)
X int *argc;
X char **argv;
X XdbxResources *app_resources;
X{
X char **dbxargv;
X char *temp = "xdbx.XXXXXX";
X int i=0;
X
X dbxargv = (char **) XtMalloc (MAXARGS * sizeof(char *));
X for (i=0; i < *argc; i++)
X dbxargv[i] = argv[i];
X
X if (app_resources->dbxopt_r)
X dbxargv[i++] = "-r";
X if (app_resources->dbxopt_i)
X dbxargv[i++] = "-i";
X if (app_resources->includeDir) {
X dbxargv[i++] = "-I";
X dbxargv[i++] = app_resources->includeDir;
X }
X if (app_resources->dbxopt_k)
X dbxargv[i++] = "-k";
X if (app_resources->cfile) {
X dbxargv[i++] = "-c";
X dbxargv[i++] = app_resources->cfile;
X }
X if (app_resources->dbxopt_kbd)
X dbxargv[i++] = "-kbd";
X if (app_resources->fcount) {
X dbxargv[i++] = "-f";
X dbxargv[i++] = app_resources->fcount;
X }
X /* If .dbxinit exists in the local or home directory, include the option
X * -c (Berkeley dbx) or -s (Sun dbx) and a dummy filename as the option
X * argument. This will prevent dbx from reading the user's command
X * initialization file. Xdbx will read each line and pass it to dbx
X * instead.
X */
X if (strcmp(xdbxinit, "")) { /* .dbxinit or ~/.dbxinit exists */
X#ifdef BSD
X dbxargv[i++] = "-c";
X#else
X dbxargv[i++] = "-s";
X#endif
X dbxargv[i++] = (char *) mktemp(temp);
X }
X if (app_resources->startup) { /* overwrites dbxinit */
X Tstartup = False;
X strcpy(xdbxinit, app_resources->startup);
X }
X if (app_resources->tstartup) { /* overwrites dbxinit */
X Tstartup = True;
X strcpy(xdbxinit, app_resources->tstartup);
X }
X#ifdef MIPS
X if (app_resources->pixie) { /* pixie output */
X dbxargv[i++] = "-pixie";
X }
X#endif
X dbxargv[i] = NULL;
X *argc = i;
X return dbxargv;
X}
X
X
Xvoid main(argc, argv)
Xint argc;
Xchar **argv;
X{
X char **dbxargv;
X
X trap_signals();
X
X toplevel = XtAppInitialize(&app_context, "XDbx", options, XtNumber(options),
X &argc, argv, fallback_resources, NULL, 0);
X if (argc > 3) Syntax(argv[0]);
X XtGetApplicationResources(toplevel, &app_resources, resources,
X XtNumber(resources), NULL, 0);
X XtAppAddActions(app_context, xdbx_actions, XtNumber(xdbx_actions));
X CreateSubWindows(toplevel);
X XtRealizeWidget(toplevel);
X
X main_init();
X dbxargv = dbxoptions(&argc, argv, &app_resources);
X calldbx(argc, dbxargv);
X
X XtAppMainLoop(app_context);
X}
END_OF_FILE
if test 12215 -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 4 \(of 7\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 7 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 7 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
dan
----------------------------------------------------
O'Reilly && Associates argv at sun.com / argv at ora.com
Opinions expressed reflect those of the author only.
More information about the Comp.sources.x
mailing list