home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1991-09-09 | 39.9 KB | 1,343 lines
Newsgroups: alt.sources Path: wupost!zaphod.mps.ohio-state.edu!think.com!news.bbn.com!mips2!bubba!jtsillas From: jtsillas@bubba.ma30.bull.com (James Tsillas) Subject: mxgdb 1.0.3 (part 4/10) Organization: Bull HN, Worldwide Information Systems, Billerica, Mass., USA Distribution: alt Date: 6 Sep 91 14:24:48 Message-ID: <JTSILLAS.91Sep6142448@bubba.ma30.bull.com> Sender: news@mips2.ma30.bull.com (Usenet News Manager) ---- Cut Here and feed the following to sh ---- #!/bin/sh # this is mxgdb.04 (part 4 of a multipart archive) # do not concatenate these parts, unpack them in order with /bin/sh # file mxgdb/windows.c continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 4; 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/windows.c' else echo 'x - continuing file mxgdb/windows.c' sed 's/^X//' << 'SHAR_EOF' >> 'mxgdb/windows.c' && X * not be used in advertising or publicity pertaining to distribution of X * the software without specific, written prior permission. The X * University of Texas 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 * THE UNIVERSITY OF TEXAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND X * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS BE LIABLE FOR ANY X * 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, The University of Texas at Austin X * Created: March 10, 1989 X * X *****************************************************************************/ X /* windows.c: X * X * CreateTitleBar() : Create title bar. X * CreateFileLabel() : Create file label in file window. X * CreateLineLabel() : Create line label in file window. X * CreateFileWindow() : Create file window. X * CreateMessageWindow() : Create message window. X * CreateDisplayWindow() : Create display window. X * CreateSubWindows() : Create the subwindows. X * UpdateFileLabel() : Update file label. X * UpdateLineLabel() : Update line label. X * UpdateMessageWindow() : Update message window. X */ X #include "global.h" #include "bitmaps.h" X #include <Xm/Xm.h> #include <Xm/PanedW.h> #include <Xm/RowColumn.h> #include <Xm/Form.h> #include <Xm/Label.h> #include <Xm/CascadeB.h> #include <Xm/ScrolledW.h> #include <Xm/PushB.h> #include <Xm/MessageB.h> #include <Xm/Separator.h> X Widget fileWindow, /* parent of fileLabel and lineLabel */ X messageWindow, /* window for displaying messages */ X separator, /* separator in vpane */ X displayWindow, /* area for displaying variables */ X fileSel, X displayFD, X topMenuBar, X topForm, X fileCButton, commandsCButton, X filePMenu, commandPMenu, infoFD, X filePbutton, searchPbutton, quitPbutton, X runningCbutton, helpPMenu, helpCButton, X helpFD; X Widget vpane, exitWarning; X static Widget fileLabel, /* filename of displayed text */ X lineLabel; /* line number of caret position */ X /* X * Private routines for creating various subwindows for xdbx. X */ X static void CreateFileLabel(parent) Widget parent; { X Arg args[MAXARGS]; X X XtSetArg(args[0], XmNlabelString, X XmStringCreateLtoR("No Source File", XmSTRING_DEFAULT_CHARSET)); X XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM); X XtSetArg(args[2], XmNrightAttachment, XmATTACH_WIDGET); X XtSetArg(args[3], XmNrightWidget, lineLabel); X fileLabel = XtCreateManagedWidget("fileLabel", xmLabelWidgetClass, X parent, args, 4); } X static void CreateLineLabel(parent) Widget parent; { X Arg args[MAXARGS]; X X XtSetArg(args[0], XmNlabelString, X XmStringCreateLtoR("0 ", XmSTRING_DEFAULT_CHARSET)); X XtSetArg(args[1], XmNrightAttachment, XmATTACH_FORM); X lineLabel = XtCreateManagedWidget("lineLabel", xmLabelWidgetClass, X parent, args, 2); X } X static void CreateFileWindow(parent) Widget parent; { X Arg args[MAXARGS]; X Dimension height; X X fileWindow = XtCreateManagedWidget("fileWindow", xmFormWidgetClass, X parent, args, 0); X X X XtSetArg(args[0], XmNheight, &height); X XtGetValues(fileWindow, args, 1); X XtSetArg(args[0], XmNpaneMinimum, height); X XtSetArg(args[1], XmNpaneMaximum, height); X XtSetValues(fileWindow, args, 2); X CreateLineLabel(fileWindow); X CreateFileLabel(fileWindow); X } X static void CreateMessageWindow(parent) Widget parent; { X Arg args[MAXARGS]; X Cardinal n; X Dimension height; X X n = 0; X XtSetArg(args[0], XmNalignment, XmALIGNMENT_BEGINNING); X XtSetArg(args[1], XmNlabelString, X XmStringCreateLtoR("", X XmSTRING_DEFAULT_CHARSET)); X X messageWindow = XtCreateManagedWidget("messageWindow", xmLabelWidgetClass, X parent, args, 2); X X XtSetArg(args[0], XmNheight, &height); X XtGetValues(messageWindow, args, 1); X XtSetArg(args[0], XmNpaneMinimum, height); X XtSetArg(args[1], XmNpaneMaximum, height); X XtSetValues(messageWindow, args, 2); X } X static void SelectVar(w, event, params, num_params) X Widget w; X XEvent *event; X String *params; X Cardinal *num_params; { X char *displayString, *term1, *term2; X XmTextPosition pos, bottom, left, right; X X displayString = (char *) XmTextGetString(w); X pos = XmTextGetInsertionPosition(w); X bottom = XmTextGetLastPosition(w); X X if(displayString && *displayString) X { X left = pos; X right = pos; X while(left > 0 && displayString[left-1] != '\n') left--; X while(right <= bottom && displayString[right] != '\n') right++; X X XmTextSetSelection(w, left, right, 0); X } X if(displayString) XtFree(displayString); } X /* Create a window for displaying variables as specified by the display X * command in dbx. X */ static void CreateDisplayWindow(parent) Widget parent; { X Arg args[MAXARGS]; X Widget displaySW; X X static Arg displaywindowargs[] = { X { XmNeditable, False }, X { XmNeditMode, XmMULTI_LINE_EDIT }, X { XmNscrollLeftSide, True }, X { XmNcursorPositionVisible, False }, X { XmNscrollBarDisplayPolicy, XmSTATIC }, X { XmNscrollHorizontal, True }, X { XmNscrollVertical, True }, X }; X X static Arg displaySWargs[] = { X { XmNleftAttachment, XmATTACH_FORM }, X { XmNrightAttachment, XmATTACH_FORM }, X { XmNbottomAttachment, XmATTACH_FORM }, X { XmNtopAttachment, XmATTACH_FORM }, X }; X X static XtActionsRec display_actions[] = { X {"SelectVar", (XtActionProc) SelectVar}, X {NULL, NULL} X }; X X displayFD = XmCreateFormDialog(parent, "displayWindowFD", X NULL, 0); X displayWindow = (Widget) XmCreateScrolledText(displayFD, "displayWindow", X displaywindowargs, 7); X XtManageChild(displayWindow); X XtAppAddActions(app_context, display_actions, XtNumber(display_actions)); X displaySW = XtParent(displayWindow); X XtSetValues(displaySW, displaySWargs, 4); } X void CreateInfoDialog(parent) Widget parent; { X Arg args[MAXARGS]; X Pixel bg; X X infoFD = XmCreateInformationDialog(parent, "MXGDB Info", args, 0); X X XtSetArg(args[0], XmNbackground, &bg); X XtGetValues(sourceForm, args, 1); X X XtSetArg(args[0], XmNlabelPixmap, XCreatePixmapFromBitmapData ( X XtDisplay(toplevel), DefaultRootWindow(XtDisplay(toplevel)), X triton_bits, triton_width, X triton_height, app_resources.stop_color, bg, X DefaultDepth(XtDisplay(toplevel), X DefaultScreen(XtDisplay(toplevel))))); X XtSetValues(XmMessageBoxGetChild(infoFD, XmDIALOG_SYMBOL_LABEL), args, 1); X X XtSetArg(args[0], XmNlabelString, X XmStringCreateLtoR("MXGDB 1.0\nadapted by Jim Tsillas from work by\nPierre Willard (xxgdb) and Po Cheung (xdbx)\nJuly 22, 1991\nTRITON Project, Internal CASE\nBull HN, Billerica Mass.\nQuestions, comments to J.Tsillas@bull.com", XmSTRING_DEFAULT_CHARSET)); X XtSetValues(XmMessageBoxGetChild(infoFD, XmDIALOG_MESSAGE_LABEL), args, 1); X XtUnmanageChild(XmMessageBoxGetChild(infoFD, XmDIALOG_HELP_BUTTON)); } X /* Create a window for displaying variables as specified by the display X * command in dbx. X */ X /* Callback for the Help*Info menu selection */ void Info(w, client_data, call_data) X Widget w; X XtPointer client_data; X XmPushButtonCallbackStruct *call_data; { X XtManageChild(infoFD); } X void HelpQuitActivate(w, client_data, call_data) X Widget w; X XtPointer client_data; X XmPushButtonCallbackStruct *call_data; { X XtUnmanageChild(helpFD); } X X /* ActivationCallback for the up button in */ X /* the help popup dialog */ void HelpUpActivate(w, client_data, call_data) X Widget w; X XtPointer client_data; X XmArrowButtonCallbackStruct *call_data; { X char command[LINESIZ]; X extern int helpstackidx; X extern char helpstack[HELP_LEVELS][HELP_SIZE]; X extern char help_buttons_use_flag; X X --helpstackidx; /* decrement the help stack pointer */ X sprintf(command, "help %s\n", helpstack[helpstackidx-1]); X help_buttons_use_flag=1; /* Ugly: set this flag to tell the handler */ X query_dbx(command); /* that this is a request from the up button */ X help_buttons_use_flag=0; } X void ManageQuit(w, client_data, call_data) X Widget w; X XtPointer client_data; X XmPushButtonCallbackStruct *call_data; { X XtManageChild(exitWarning); } X /* These are used in gdb_handler help_hanlder */ Widget helpselectscroll, helpupbutton, helpupbuttonlabel; X static void CreateHelpWindow(parent) Widget parent; { X Widget helpquitbutton, scrollW; X static Arg helpFDargs[] = { X { XmNwidth, 300 }, X { XmNheight, 200 }, X }; X static Arg scrollWargs[] = { X { XmNscrollingPolicy, XmAUTOMATIC }, X { XmNscrollBarPlacement, XmBOTTOM_LEFT }, X { XmNleftAttachment, XmATTACH_FORM }, X { XmNrightAttachment, XmATTACH_FORM }, X { XmNtopAttachment, XmATTACH_FORM }, X { XmNbottomAttachment, XmATTACH_FORM }, X { XmNbottomOffset, 45 }, X { XmNrightOffset, 5 }, X { XmNleftOffset, 5 }, X { XmNtopOffset, 5 }, X { XmNheight, 270 }, X { XmNwidth, 400 }, X }; X static Arg helpbuttonupargs[] = { X { XmNarrowDirection, XmARROW_UP }, X { XmNbottomAttachment, XmATTACH_FORM }, X { XmNrightAttachment, XmATTACH_FORM }, X { XmNbottomOffset, 5 }, X { XmNrightOffset, 5 }, X }; X static Arg helplabelupargs[] = { X { XmNbottomAttachment, XmATTACH_FORM }, X { XmNrightAttachment, XmATTACH_FORM }, X { XmNbottomOffset, 7 }, X { XmNrightOffset, 30 }, X }; X static Arg helpbuttonquitargs[] = { X { XmNbottomAttachment, XmATTACH_FORM }, X { XmNleftAttachment, XmATTACH_FORM }, X { XmNleftOffset, 5 }, X { XmNbottomOffset, 5}, X }; X static Arg helpseparatorargs[] = { X { XmNbottomAttachment, XmATTACH_FORM }, X { XmNleftAttachment, XmATTACH_FORM }, X { XmNrightAttachment, XmATTACH_FORM }, X { XmNbottomOffset, 35 }, X }; X X helpFD = XmCreateFormDialog(parent, "MXGDB help", helpFDargs, 2); X scrollW = XtCreateManagedWidget("scrollW", X xmScrolledWindowWidgetClass, X helpFD, scrollWargs, 12); X helpselectscroll = XtCreateManagedWidget("helpselectscroll", X xmFormWidgetClass, X scrollW, NULL, 0); X XmScrolledWindowSetAreas(scrollW, NULL, NULL, helpselectscroll); X XtCreateManagedWidget("helpseparator", xmSeparatorWidgetClass, X helpFD, helpseparatorargs, 4); X helpupbutton = (Widget) XmCreateArrowButton(helpFD, "helpupbutton", X helpbuttonupargs, 5); X XtAddCallback(helpupbutton, XmNactivateCallback, HelpUpActivate, NULL); X helpupbuttonlabel = XtCreateWidget("Previous Menu:", X xmLabelWidgetClass, X helpFD, helplabelupargs, 4); X helpquitbutton = XtCreateManagedWidget("Quit", xmPushButtonWidgetClass, X helpFD, helpbuttonquitargs, 4); X XtAddCallback(helpquitbutton, XmNactivateCallback, HelpQuitActivate, NULL); } X static MenuButtonStruct fileButtons[] = { X { NULL, "File...", "", "filePbutton", File, "Ctnrl <Key> f", "!f" }, X { NULL, "Search...", "", "searchPbutton", PopupSearch, "Ctrl <Key> w", X "!w" }, X { NULL, "Commands...", "", "commandsPbutton", PopupCommands, "", "" }, X { NULL, "Exit...", "", "quitPbutton", ManageQuit, "Ctrl <Key> e", "!e" }, }; X static MenuButtonStruct helpButtons[] = { X { NULL, "Gdb Help...", "", "helpPMB", Help, "Ctrl <Key> h", "!h" }, X { NULL, "Info...", "", "infoPMB", Info, "", "" }, }; X static MenuButtonStruct runningButtons[] = { X { NULL, "Run", "run\n", "runPMB", DoIt, "Ctrl <Key> r", "!r" }, X { NULL, "Continue", "cont\n", "contPMB", DoIt, "", "" }, X { NULL, "Next", "next\n", "nextPMB", DoIt, "Ctrl <Key> n", "!n" }, X { NULL, "Step", "step\n", "stepPMB", DoIt, "Ctrl <Key> s", "!s" }, X { NULL, "Finish", "finish\n", "finishPMB", DoIt, "", "" }, }; X static MenuButtonStruct dataButtons[] = { X { NULL, "Print", "", "printPMB", Print, "Ctrl <Key> p", "!p"}, X { NULL, "Display...", "", "displayPMB", Display_, "", ""}, X { NULL, "Undisplay", "", "undisplayPMB", Undisplay, "", "" }, }; X static MenuButtonStruct breakpointsButtons[] = { X { NULL, "Break", "break", "breakPMB", Break, "Ctrl <Key> b", "!b" }, X { NULL, "Clear", "", "clearPMB", Clear, "", "" }, X { NULL, "Tbreak", "tbreak", "tbreakPMB", Break, "", ""}, }; X static MenuButtonStruct stackButtons[] = { X { NULL, "Up", "up\n", "upPMB", DoIt, "Ctrl <Key> g", "!g" }, X { NULL, "Down", "down\n", "downPMB", DoIt, "Ctrl <Key> j", "!j" }, }; X static MenuButtonStruct infoButtons[] = { X { NULL, "Locals", "info locals\n", "ilocalsPMB", DoIt, "", "" }, X { NULL, "Args", "info args\n", "iargsPMB", DoIt, "", "" }, X { NULL, "Stack", "info stack\n", "istackPMB", DoIt, "", "" }, }; X static PMCBStruct commandMB[] = { X { NULL, NULL, "Running", "runningPM", "runningCB", runningButtons, 5, 'R'}, X { NULL, NULL, "Data", "dataPM", "dataCB", dataButtons, 3, 'D' }, X { NULL, NULL, "Breakpoints", "breakpointsPM", "breakpointsCB", X breakpointsButtons, 3, 'B' }, X { NULL, NULL, "Stack", "stackPM", "stackCB", stackButtons, 2, 'S' }, X { NULL, NULL, "Info", "infoPM", "infoCB", infoButtons, 3, 'I' }, }; X void CreateMenuButton(parent, Buttons, nbuttons) Widget parent; MenuButtonStruct Buttons[]; int nbuttons; { X Arg args[5]; X int widgetcount; X Cardinal nargs; X X for(widgetcount=0; widgetcount<nbuttons; widgetcount++) X { X XtSetArg(args[0], XmNlabelString, X XmStringCreateLtoR(Buttons[widgetcount].Label, X XmSTRING_DEFAULT_CHARSET)); X nargs = 1; X if(*Buttons[widgetcount].accel != '\0') X { X XtSetArg(args[1], XmNaccelerator, Buttons[widgetcount].accel); X XtSetArg(args[2], XmNacceleratorText, X XmStringCreateLtoR(Buttons[widgetcount].acceltext, X XmSTRING_DEFAULT_CHARSET)); X nargs = 3; X } X Buttons[widgetcount].Button = (Widget) X XmCreatePushButtonGadget(parent, X Buttons[widgetcount].RN, X args, nargs); X XtManageChild(Buttons[widgetcount].Button); X XtAddCallback(Buttons[widgetcount].Button, X XmNactivateCallback, X Buttons[widgetcount].CB, X Buttons[widgetcount].Argument); X } } X void CreatePulldownMenu(parent, MenuPane, Npanes) Widget parent; PMCBStruct MenuPane[]; int Npanes; { X Arg args[MAXARGS]; X int widgetcount; X X X for(widgetcount=0; widgetcount<Npanes; widgetcount++) X { X MenuPane[widgetcount].PM = X XmCreatePulldownMenu(parent, MenuPane[widgetcount].RNPM, X args, 0); X XtSetArg(args[0], XmNlabelString, X XmStringCreateLtoR(MenuPane[widgetcount].Label, X XmSTRING_DEFAULT_CHARSET)); X XtSetArg(args[1], XmNsubMenuId, MenuPane[widgetcount].PM); X XtSetArg(args[2], XmNmnemonic, MenuPane[widgetcount].mnemonic); X MenuPane[widgetcount].CB = X XmCreateCascadeButton(parent, MenuPane[widgetcount].RNCB, X args, 3); X XtManageChild(MenuPane[widgetcount].CB); X CreateMenuButton(MenuPane[widgetcount].PM, X MenuPane[widgetcount].Buttons, X MenuPane[widgetcount].Nbuttons); X } } X void CreateMenuPane(parent) Widget parent; { X Arg args[MAXARGS]; X X topForm = XtCreateManagedWidget("topForm", xmFormWidgetClass, parent, X args, 0); X X XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM); X XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM); X XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM); X topMenuBar = XmCreateMenuBar(topForm, "topMenuBar", args, 3); X XtManageChild(topMenuBar); X X XtSetArg(args[0], XmNbottomAttachment, XmATTACH_FORM); X XtSetArg(args[3], XmNtopWidget, topMenuBar); X XtSetArg(args[4], XmNtopAttachment, XmATTACH_WIDGET); X vpane = XtCreateManagedWidget( "vpane", xmPanedWindowWidgetClass, X topForm, args, 5); X X filePMenu = XmCreatePulldownMenu(topMenuBar, "filePMenu", args, 0); X X XtSetArg(args[0], XmNsubMenuId, filePMenu); X XtSetArg(args[1], XmNlabelString, X XmStringCreateLtoR("File", XmSTRING_DEFAULT_CHARSET)); X XtSetArg(args[2], XmNmnemonic, 'F'); X fileCButton = XmCreateCascadeButton(topMenuBar,"fileCButton", args, 3); X XtManageChild(fileCButton); X X CreateMenuButton(filePMenu, fileButtons, 4); X X commandPMenu = XmCreatePulldownMenu(topMenuBar, "commandPMenu", args, 0); X X XtSetArg(args[0], XmNsubMenuId, commandPMenu); X XtSetArg(args[1], XmNlabelString, X XmStringCreateLtoR("Commands", XmSTRING_DEFAULT_CHARSET)); X XtSetArg(args[2], XmNmnemonic, 'C'); X commandsCButton = XmCreateCascadeButton(topMenuBar, "commandsCButton", X args, 3); X XtManageChild(commandsCButton); X X CreatePulldownMenu(commandPMenu, commandMB, 5); X X helpPMenu = XmCreatePulldownMenu(topMenuBar, "helpPMenu", args, 0); X XtSetArg(args[0], XmNsubMenuId, helpPMenu); X XtSetArg(args[1], XmNlabelString, X XmStringCreateLtoR("Help", XmSTRING_DEFAULT_CHARSET)); X XtSetArg(args[2], XmNmnemonic, 'H'); X helpCButton = XmCreateCascadeButton(topMenuBar, "helpCButton", X args, 3); X XtManageChild(helpCButton); X CreateMenuButton(helpPMenu, helpButtons, 2); X } X /* X * Top level function for creating all the mxgdb subwindows. X */ void CreateSubWindows(parent) Widget parent; { X Arg args[MAXARGS]; X Cardinal n; X XmFontList labelFontList; X X labelFontList = XmFontListCreate(XLoadQueryFont(XtDisplay(toplevel), X "-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1"), X XmSTRING_DEFAULT_CHARSET); X X CreateMenuPane(parent); X CreateFileWindow(vpane); X CreateSourceWindow(vpane); X CreateMessageWindow(vpane); X CreateDialogWindow(vpane); X X fileSel = (Widget) XmCreateFileSelectionDialog(toplevel, X "fileSelectorBox", X args, 1); X XtSetArg(args[0], XmNkeyboardFocusPolicy, XmPOINTER); X XtSetValues(XtParent(fileSel), args, 1); X X XtAddCallback(fileSel, XmNokCallback, OKCallBack, NULL); X XtAddCallback(fileSel, XmNcancelCallback, CancelCallBack, NULL); X X CreateDisplayWindow(toplevel); X CreateHelpWindow(toplevel); X CreateSearchPopup(toplevel); X CreateInfoDialog(toplevel); X X XtSetArg(args[0], XmNmessageString, X XmStringCreateLtoR("OK to Exit Mxgdb?", X XmSTRING_DEFAULT_CHARSET)); X exitWarning = XmCreateQuestionDialog(toplevel, "MXGDB exit", args, 1); X XtAddCallback(exitWarning, XmNokCallback, Quit, NULL); X XtUnmanageChild(XmMessageBoxGetChild(exitWarning, XmDIALOG_HELP_BUTTON)); X XtSetArg(args[0], XmNfontList, labelFontList); X XtSetValues(XmMessageBoxGetChild(exitWarning, XmDIALOG_CANCEL_BUTTON) X , args, 1); X XtSetValues(XmMessageBoxGetChild(exitWarning, XmDIALOG_OK_BUTTON) X , args, 1); X XtSetValues(XmMessageBoxGetChild(exitWarning, XmDIALOG_CANCEL_BUTTON) X , args, 1); X XtSetValues(XmMessageBoxGetChild(exitWarning, XmDIALOG_MESSAGE_LABEL) X , args, 1); } X /* X * 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 void UpdateFileLabel(string) char *string; { X Arg args[MAXARGS]; X X XtSetArg(args[0], XmNlabelString, X XmStringCreateLtoR(string, XmSTRING_DEFAULT_CHARSET)); X XtSetValues(fileLabel, args, 1); X } X void UpdateLineLabel(line) Cardinal line; { 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[0], XmNlabelString, X XmStringCreateLtoR(string, XmSTRING_DEFAULT_CHARSET)); X XtSetValues(lineLabel, args, 1); } X /*--------------------------------------------------------------------------+ X | | X | Note : UpdateMessageWindow assumes that the format string | X | can only contain one %s specifier. | X | arg is either NULL or is a string. | X | format is a string (never NULL). | X | | X +--------------------------------------------------------------------------*/ void UpdateMessageWindow(format, arg) X char *format, *arg; { X char *message; X char string[LINESIZ]; X int fulllength; X Arg args[MAXARGS]; X Cardinal n; X X fulllength = strlen (" ") + strlen (format) + 1 X + ((arg == NULL) ? 0 : strlen (arg)); X X if (fulllength > LINESIZ) X message = (char*) XtMalloc (fulllength); X else X message = string; X X strcpy(message, " "); X sprintf(message + strlen(message), format, arg); X X XtSetArg(args[0], XmNlabelString, X XmStringCreateLtoR(message, XmSTRING_DEFAULT_CHARSET)); X XtSetValues(messageWindow, args, 1); X X if (fulllength > LINESIZ) X XtFree(message); } X void ClearMessageWindow() { X Arg args[MAXARGS]; X X XtSetArg(args[0], XmNlabelString, X XmStringCreateLtoR("", XmSTRING_DEFAULT_CHARSET)); X XtSetValues(messageWindow, args, 1); } X SHAR_EOF echo 'File mxgdb/windows.c is complete' && chmod 0664 mxgdb/windows.c || echo 'restore of mxgdb/windows.c failed' Wc_c="`wc -c < 'mxgdb/windows.c'`" test 21420 -eq "$Wc_c" || echo 'mxgdb/windows.c: original size 21420, 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.3 1991/07/16 16:33:20 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 */ SHAR_EOF true || echo 'restore of mxgdb/gdb_parser.c failed' fi echo 'End of part 4' echo 'File mxgdb/gdb_parser.c is continued in part 5' echo 5 > _shar_seq_.tmp exit 0