home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 4 / 4006 < prev    next >
Encoding:
Text File  |  1991-09-09  |  39.9 KB  |  1,343 lines

  1. Newsgroups: alt.sources
  2. Path: wupost!zaphod.mps.ohio-state.edu!think.com!news.bbn.com!mips2!bubba!jtsillas
  3. From: jtsillas@bubba.ma30.bull.com (James Tsillas)
  4. Subject: mxgdb 1.0.3 (part 4/10)
  5. Organization: Bull HN, Worldwide Information Systems, Billerica, Mass., USA
  6. Distribution: alt
  7. Date: 6 Sep 91 14:24:48
  8. Message-ID: <JTSILLAS.91Sep6142448@bubba.ma30.bull.com>
  9. Sender: news@mips2.ma30.bull.com (Usenet News Manager)
  10.  
  11. ---- Cut Here and feed the following to sh ----
  12. #!/bin/sh
  13. # this is mxgdb.04 (part 4 of a multipart archive)
  14. # do not concatenate these parts, unpack them in order with /bin/sh
  15. # file mxgdb/windows.c continued
  16. #
  17. if test ! -r _shar_seq_.tmp; then
  18.     echo 'Please unpack part 1 first!'
  19.     exit 1
  20. fi
  21. (read Scheck
  22.  if test "$Scheck" != 4; then
  23.     echo Please unpack part "$Scheck" next!
  24.     exit 1
  25.  else
  26.     exit 0
  27.  fi
  28. ) < _shar_seq_.tmp || exit 1
  29. if test ! -f _shar_wnt_.tmp; then
  30.     echo 'x - still skipping mxgdb/windows.c'
  31. else
  32. echo 'x - continuing file mxgdb/windows.c'
  33. sed 's/^X//' << 'SHAR_EOF' >> 'mxgdb/windows.c' &&
  34. X *  not be used in advertising or publicity pertaining to distribution of
  35. X *  the software without specific, written prior permission.  The
  36. X *  University of Texas makes no representations about the suitability of
  37. X *  this software for any purpose.  It is provided "as is" without express
  38. X *  or implied warranty.
  39. X *
  40. X *  THE UNIVERSITY OF TEXAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  41. X *  SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  42. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS BE LIABLE FOR ANY
  43. X *  SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  44. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  45. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  46. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  47. X *
  48. X *  Author:      Po Cheung, The University of Texas at Austin
  49. X *  Created:       March 10, 1989
  50. X *
  51. X *****************************************************************************/
  52. X
  53. /*  windows.c:
  54. X *
  55. X *    CreateTitleBar() :    Create title bar.
  56. X *    CreateFileLabel() :    Create file label in file window.
  57. X *    CreateLineLabel() :    Create line label in file window.
  58. X *    CreateFileWindow() :    Create file window.
  59. X *    CreateMessageWindow() :    Create message window.
  60. X *    CreateDisplayWindow() :    Create display window.
  61. X *    CreateSubWindows() :    Create the subwindows.
  62. X *    UpdateFileLabel() :    Update file label.
  63. X *    UpdateLineLabel() :    Update line label.
  64. X *    UpdateMessageWindow() :    Update message window.
  65. X */
  66. X
  67. #include "global.h"
  68. #include "bitmaps.h"
  69. X
  70. #include <Xm/Xm.h>
  71. #include <Xm/PanedW.h>
  72. #include <Xm/RowColumn.h>
  73. #include <Xm/Form.h>
  74. #include <Xm/Label.h>
  75. #include <Xm/CascadeB.h>
  76. #include <Xm/ScrolledW.h>
  77. #include <Xm/PushB.h>
  78. #include <Xm/MessageB.h>
  79. #include <Xm/Separator.h>
  80. X
  81. Widget    fileWindow,            /* parent of fileLabel and lineLabel */
  82. X    messageWindow,            /* window for displaying messages */
  83. X    separator,            /* separator in vpane */
  84. X    displayWindow,            /* area for displaying variables */
  85. X        fileSel,
  86. X        displayFD,
  87. X        topMenuBar,
  88. X        topForm,
  89. X        fileCButton, commandsCButton,
  90. X        filePMenu, commandPMenu, infoFD,
  91. X        filePbutton, searchPbutton, quitPbutton,
  92. X        runningCbutton, helpPMenu, helpCButton,
  93. X        helpFD;
  94. X
  95. Widget vpane, exitWarning;
  96. X
  97. static Widget     fileLabel,        /* filename of displayed text */
  98. X        lineLabel;        /* line number of caret position */
  99. X
  100. /*
  101. X *  Private routines for creating various subwindows for xdbx.
  102. X */
  103. X
  104. static void CreateFileLabel(parent)
  105. Widget parent;
  106. {
  107. X    Arg     args[MAXARGS];
  108. X
  109. X    XtSetArg(args[0], XmNlabelString, 
  110. X         XmStringCreateLtoR("No Source File", XmSTRING_DEFAULT_CHARSET));
  111. X    XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
  112. X    XtSetArg(args[2], XmNrightAttachment, XmATTACH_WIDGET);
  113. X    XtSetArg(args[3], XmNrightWidget, lineLabel);
  114. X    fileLabel = XtCreateManagedWidget("fileLabel", xmLabelWidgetClass, 
  115. X                      parent, args, 4);
  116. }
  117. X
  118. static void CreateLineLabel(parent)
  119. Widget parent;
  120. {
  121. X    Arg     args[MAXARGS];
  122. X
  123. X    XtSetArg(args[0], XmNlabelString, 
  124. X         XmStringCreateLtoR("0     ", XmSTRING_DEFAULT_CHARSET));
  125. X    XtSetArg(args[1], XmNrightAttachment, XmATTACH_FORM);
  126. X    lineLabel = XtCreateManagedWidget("lineLabel", xmLabelWidgetClass, 
  127. X                      parent, args, 2);
  128. X   
  129. }
  130. X
  131. static void CreateFileWindow(parent)
  132. Widget parent;
  133. {
  134. X    Arg     args[MAXARGS];
  135. X    Dimension   height;
  136. X
  137. X    fileWindow = XtCreateManagedWidget("fileWindow", xmFormWidgetClass,
  138. X                      parent, args, 0);
  139. X
  140. X
  141. X    XtSetArg(args[0], XmNheight, &height);
  142. X    XtGetValues(fileWindow, args, 1);
  143. X    XtSetArg(args[0], XmNpaneMinimum, height);
  144. X    XtSetArg(args[1], XmNpaneMaximum, height); 
  145. X    XtSetValues(fileWindow, args, 2);
  146. X    CreateLineLabel(fileWindow);
  147. X    CreateFileLabel(fileWindow);
  148. X
  149. }
  150. X
  151. static void CreateMessageWindow(parent)
  152. Widget parent;
  153. {
  154. X    Arg     args[MAXARGS];
  155. X    Cardinal     n;
  156. X    Dimension   height;
  157. X
  158. X    n = 0;
  159. X    XtSetArg(args[0], XmNalignment, XmALIGNMENT_BEGINNING);
  160. X    XtSetArg(args[1], XmNlabelString, 
  161. X         XmStringCreateLtoR("", 
  162. X                XmSTRING_DEFAULT_CHARSET));
  163. X
  164. X    messageWindow = XtCreateManagedWidget("messageWindow", xmLabelWidgetClass,
  165. X                      parent, args, 2);
  166. X
  167. X    XtSetArg(args[0], XmNheight, &height);
  168. X    XtGetValues(messageWindow, args, 1);
  169. X    XtSetArg(args[0], XmNpaneMinimum, height);
  170. X    XtSetArg(args[1], XmNpaneMaximum, height); 
  171. X    XtSetValues(messageWindow, args, 2);
  172. X    
  173. }
  174. X
  175. static void SelectVar(w, event, params, num_params)
  176. X    Widget w;
  177. X    XEvent *event;
  178. X    String *params;
  179. X    Cardinal *num_params;
  180. {
  181. X  char *displayString, *term1, *term2;
  182. X  XmTextPosition pos, bottom, left, right;
  183. X  
  184. X  displayString = (char *) XmTextGetString(w);
  185. X  pos = XmTextGetInsertionPosition(w);
  186. X  bottom = XmTextGetLastPosition(w);
  187. X
  188. X  if(displayString && *displayString)
  189. X    {
  190. X      left = pos;
  191. X      right = pos;
  192. X      while(left > 0 && displayString[left-1] != '\n') left--;
  193. X      while(right <=  bottom && displayString[right] != '\n') right++;
  194. X      
  195. X      XmTextSetSelection(w, left, right, 0);
  196. X    }
  197. X  if(displayString) XtFree(displayString);
  198. }
  199. X
  200. /*  Create a window for displaying variables as specified by the display
  201. X *  command in dbx.
  202. X */
  203. static void CreateDisplayWindow(parent)
  204. Widget parent;
  205. {
  206. X    Arg     args[MAXARGS];
  207. X    Widget      displaySW;
  208. X
  209. X    static Arg displaywindowargs[] = {
  210. X      { XmNeditable, False },
  211. X      { XmNeditMode, XmMULTI_LINE_EDIT },
  212. X      { XmNscrollLeftSide, True },
  213. X      { XmNcursorPositionVisible, False },
  214. X      { XmNscrollBarDisplayPolicy, XmSTATIC },
  215. X      { XmNscrollHorizontal, True },
  216. X      { XmNscrollVertical, True },
  217. X    };
  218. X
  219. X    static Arg displaySWargs[] = {
  220. X      { XmNleftAttachment, XmATTACH_FORM },
  221. X      { XmNrightAttachment, XmATTACH_FORM },
  222. X      { XmNbottomAttachment, XmATTACH_FORM },
  223. X      { XmNtopAttachment, XmATTACH_FORM },
  224. X    };
  225. X
  226. X    static XtActionsRec display_actions[] = {
  227. X    {"SelectVar",     (XtActionProc) SelectVar},
  228. X        {NULL, NULL}
  229. X    };
  230. X
  231. X    displayFD = XmCreateFormDialog(parent, "displayWindowFD", 
  232. X                   NULL, 0);
  233. X    displayWindow = (Widget) XmCreateScrolledText(displayFD, "displayWindow",
  234. X                                          displaywindowargs, 7);
  235. X    XtManageChild(displayWindow);
  236. X    XtAppAddActions(app_context, display_actions, XtNumber(display_actions));
  237. X    displaySW = XtParent(displayWindow);
  238. X    XtSetValues(displaySW, displaySWargs, 4);
  239. }
  240. X
  241. void CreateInfoDialog(parent)
  242. Widget parent;
  243. {
  244. X  Arg args[MAXARGS];
  245. X  Pixel bg;
  246. X
  247. X  infoFD = XmCreateInformationDialog(parent, "MXGDB Info", args, 0);
  248. X
  249. X  XtSetArg(args[0], XmNbackground, &bg);
  250. X  XtGetValues(sourceForm, args, 1);
  251. X
  252. X  XtSetArg(args[0], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  253. X    XtDisplay(toplevel), DefaultRootWindow(XtDisplay(toplevel)), 
  254. X    triton_bits, triton_width, 
  255. X    triton_height, app_resources.stop_color, bg, 
  256. X    DefaultDepth(XtDisplay(toplevel), 
  257. X             DefaultScreen(XtDisplay(toplevel)))));
  258. X  XtSetValues(XmMessageBoxGetChild(infoFD, XmDIALOG_SYMBOL_LABEL), args, 1);
  259. X
  260. X  XtSetArg(args[0], XmNlabelString,
  261. 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)); 
  262. X  XtSetValues(XmMessageBoxGetChild(infoFD, XmDIALOG_MESSAGE_LABEL), args, 1);
  263. X  XtUnmanageChild(XmMessageBoxGetChild(infoFD, XmDIALOG_HELP_BUTTON));
  264. }
  265. X
  266. /*  Create a window for displaying variables as specified by the display
  267. X *  command in dbx.
  268. X */
  269. X
  270. /* Callback for the Help*Info menu selection */
  271. void Info(w, client_data, call_data)
  272. X     Widget w;
  273. X     XtPointer client_data;
  274. X     XmPushButtonCallbackStruct *call_data;
  275. {
  276. X  XtManageChild(infoFD);
  277. }
  278. X
  279. void HelpQuitActivate(w, client_data, call_data)
  280. X     Widget w;
  281. X     XtPointer client_data;
  282. X     XmPushButtonCallbackStruct *call_data;
  283. {
  284. X  XtUnmanageChild(helpFD);
  285. }
  286. X
  287. X                /* ActivationCallback for the up button in  */
  288. X                /* the help popup dialog */
  289. void HelpUpActivate(w, client_data, call_data)
  290. X     Widget w;
  291. X     XtPointer client_data;
  292. X     XmArrowButtonCallbackStruct *call_data;
  293. {
  294. X  char command[LINESIZ];
  295. X  extern int helpstackidx;
  296. X  extern char helpstack[HELP_LEVELS][HELP_SIZE];
  297. X  extern char help_buttons_use_flag;
  298. X
  299. X  --helpstackidx;        /* decrement the help stack pointer */
  300. X  sprintf(command, "help %s\n", helpstack[helpstackidx-1]);
  301. X  help_buttons_use_flag=1;    /* Ugly: set this flag to tell the handler */
  302. X  query_dbx(command);        /* that this is a request from the up button */
  303. X  help_buttons_use_flag=0;
  304. }
  305. X
  306. void ManageQuit(w, client_data, call_data)
  307. X     Widget w;
  308. X     XtPointer client_data;
  309. X     XmPushButtonCallbackStruct *call_data;
  310. {
  311. X  XtManageChild(exitWarning);
  312. }
  313. X
  314. /* These are used in gdb_handler help_hanlder */
  315. Widget helpselectscroll, helpupbutton, helpupbuttonlabel;
  316. X
  317. static void CreateHelpWindow(parent)
  318. Widget parent;
  319. {
  320. X  Widget helpquitbutton, scrollW;
  321. X  static Arg helpFDargs[] = {
  322. X    { XmNwidth, 300 },
  323. X    { XmNheight, 200 },
  324. X  };
  325. X  static Arg scrollWargs[] = {
  326. X    { XmNscrollingPolicy, XmAUTOMATIC },
  327. X    { XmNscrollBarPlacement, XmBOTTOM_LEFT },
  328. X    { XmNleftAttachment, XmATTACH_FORM },
  329. X    { XmNrightAttachment, XmATTACH_FORM },
  330. X    { XmNtopAttachment, XmATTACH_FORM },
  331. X    { XmNbottomAttachment, XmATTACH_FORM },
  332. X    { XmNbottomOffset, 45 },
  333. X    { XmNrightOffset, 5 },
  334. X    { XmNleftOffset, 5 },
  335. X    { XmNtopOffset, 5 },
  336. X    { XmNheight, 270 },
  337. X    { XmNwidth, 400 },
  338. X  };
  339. X  static Arg helpbuttonupargs[] = { 
  340. X    { XmNarrowDirection, XmARROW_UP },
  341. X    { XmNbottomAttachment, XmATTACH_FORM },
  342. X    { XmNrightAttachment, XmATTACH_FORM },
  343. X    { XmNbottomOffset, 5 },
  344. X    { XmNrightOffset, 5 },
  345. X  };
  346. X  static Arg helplabelupargs[] = {
  347. X    { XmNbottomAttachment, XmATTACH_FORM },
  348. X    { XmNrightAttachment, XmATTACH_FORM },
  349. X    { XmNbottomOffset, 7 },
  350. X    { XmNrightOffset, 30 },
  351. X  };
  352. X  static Arg helpbuttonquitargs[] = {
  353. X    { XmNbottomAttachment, XmATTACH_FORM },
  354. X    { XmNleftAttachment, XmATTACH_FORM },
  355. X    { XmNleftOffset, 5 },
  356. X    { XmNbottomOffset, 5},
  357. X  };
  358. X  static Arg helpseparatorargs[] = {
  359. X    { XmNbottomAttachment, XmATTACH_FORM },
  360. X    { XmNleftAttachment, XmATTACH_FORM },
  361. X    { XmNrightAttachment, XmATTACH_FORM },
  362. X    { XmNbottomOffset, 35 },
  363. X  };
  364. X
  365. X  helpFD = XmCreateFormDialog(parent, "MXGDB help", helpFDargs, 2);
  366. X  scrollW = XtCreateManagedWidget("scrollW", 
  367. X                       xmScrolledWindowWidgetClass,
  368. X                       helpFD, scrollWargs, 12);
  369. X  helpselectscroll = XtCreateManagedWidget("helpselectscroll",
  370. X                       xmFormWidgetClass,
  371. X                       scrollW, NULL, 0);
  372. X  XmScrolledWindowSetAreas(scrollW, NULL, NULL, helpselectscroll);
  373. X  XtCreateManagedWidget("helpseparator", xmSeparatorWidgetClass,  
  374. X            helpFD, helpseparatorargs, 4);
  375. X  helpupbutton = (Widget) XmCreateArrowButton(helpFD, "helpupbutton", 
  376. X                           helpbuttonupargs, 5);
  377. X  XtAddCallback(helpupbutton, XmNactivateCallback, HelpUpActivate, NULL);
  378. X  helpupbuttonlabel = XtCreateWidget("Previous Menu:",
  379. X                     xmLabelWidgetClass,
  380. X                     helpFD, helplabelupargs, 4);
  381. X  helpquitbutton = XtCreateManagedWidget("Quit", xmPushButtonWidgetClass, 
  382. X                     helpFD, helpbuttonquitargs, 4);
  383. X  XtAddCallback(helpquitbutton, XmNactivateCallback, HelpQuitActivate, NULL);
  384. }
  385. X
  386. static MenuButtonStruct fileButtons[] = {
  387. X  { NULL, "File...", "", "filePbutton", File, "Ctnrl <Key> f", "!f" },
  388. X  { NULL, "Search...", "", "searchPbutton", PopupSearch, "Ctrl <Key> w", 
  389. X      "!w" },
  390. X  { NULL, "Commands...", "", "commandsPbutton", PopupCommands, "", "" },
  391. X  { NULL, "Exit...", "", "quitPbutton", ManageQuit, "Ctrl <Key> e", "!e" },
  392. };
  393. X
  394. static MenuButtonStruct helpButtons[] = {
  395. X  { NULL, "Gdb Help...", "", "helpPMB", Help, "Ctrl <Key> h", "!h" },
  396. X  { NULL, "Info...", "", "infoPMB", Info, "", "" },
  397. };
  398. X
  399. static MenuButtonStruct runningButtons[] = {
  400. X  { NULL, "Run", "run\n", "runPMB", DoIt, "Ctrl <Key> r", "!r" },
  401. X  { NULL, "Continue", "cont\n", "contPMB", DoIt, "", "" },
  402. X  { NULL, "Next", "next\n", "nextPMB", DoIt, "Ctrl <Key> n", "!n" },
  403. X  { NULL, "Step", "step\n", "stepPMB", DoIt, "Ctrl <Key> s", "!s" },
  404. X  { NULL, "Finish", "finish\n", "finishPMB", DoIt, "", "" },
  405. };
  406. X
  407. static MenuButtonStruct dataButtons[] = {
  408. X  { NULL, "Print", "", "printPMB", Print, "Ctrl <Key> p", "!p"},
  409. X  { NULL, "Display...", "", "displayPMB", Display_, "", ""},
  410. X  { NULL, "Undisplay", "", "undisplayPMB", Undisplay, "", "" },
  411. };
  412. X
  413. static MenuButtonStruct breakpointsButtons[] = {
  414. X  { NULL, "Break", "break", "breakPMB", Break, "Ctrl <Key> b", "!b" },
  415. X  { NULL, "Clear", "", "clearPMB", Clear, "", "" },
  416. X  { NULL, "Tbreak", "tbreak", "tbreakPMB", Break, "", ""},
  417. };
  418. X
  419. static MenuButtonStruct stackButtons[] = {
  420. X  { NULL, "Up", "up\n", "upPMB", DoIt, "Ctrl <Key> g", "!g" },
  421. X  { NULL, "Down", "down\n", "downPMB", DoIt, "Ctrl <Key> j", "!j" },
  422. };
  423. X
  424. static MenuButtonStruct infoButtons[] = {
  425. X  { NULL, "Locals", "info locals\n", "ilocalsPMB", DoIt, "", "" },
  426. X  { NULL, "Args", "info args\n", "iargsPMB", DoIt, "", "" },
  427. X  { NULL, "Stack", "info stack\n", "istackPMB", DoIt, "", "" },
  428. };
  429. X
  430. static PMCBStruct commandMB[] = {
  431. X  { NULL, NULL, "Running", "runningPM", "runningCB", runningButtons, 5, 'R'},
  432. X  { NULL, NULL, "Data", "dataPM", "dataCB", dataButtons, 3, 'D' },
  433. X  { NULL, NULL, "Breakpoints", "breakpointsPM", "breakpointsCB", 
  434. X      breakpointsButtons, 3, 'B' },
  435. X  { NULL, NULL, "Stack", "stackPM", "stackCB", stackButtons, 2, 'S' },
  436. X  { NULL, NULL, "Info", "infoPM", "infoCB", infoButtons, 3, 'I' },
  437. };
  438. X
  439. void CreateMenuButton(parent, Buttons, nbuttons)
  440. Widget parent;
  441. MenuButtonStruct Buttons[];
  442. int nbuttons;
  443. {
  444. X  Arg args[5];
  445. X  int widgetcount;
  446. X  Cardinal nargs;
  447. X
  448. X  for(widgetcount=0; widgetcount<nbuttons; widgetcount++)
  449. X    {
  450. X      XtSetArg(args[0], XmNlabelString, 
  451. X      XmStringCreateLtoR(Buttons[widgetcount].Label, 
  452. X                  XmSTRING_DEFAULT_CHARSET));
  453. X      nargs = 1;
  454. X      if(*Buttons[widgetcount].accel != '\0')
  455. X    {
  456. X      XtSetArg(args[1], XmNaccelerator, Buttons[widgetcount].accel);
  457. X      XtSetArg(args[2], XmNacceleratorText, 
  458. X           XmStringCreateLtoR(Buttons[widgetcount].acceltext, 
  459. X                      XmSTRING_DEFAULT_CHARSET));
  460. X      nargs = 3;
  461. X    }
  462. X      Buttons[widgetcount].Button = (Widget)
  463. X    XmCreatePushButtonGadget(parent,
  464. X                 Buttons[widgetcount].RN, 
  465. X                 args, nargs);
  466. X      XtManageChild(Buttons[widgetcount].Button);
  467. X      XtAddCallback(Buttons[widgetcount].Button, 
  468. X            XmNactivateCallback, 
  469. X            Buttons[widgetcount].CB, 
  470. X            Buttons[widgetcount].Argument);
  471. X    }
  472. }
  473. X
  474. void CreatePulldownMenu(parent, MenuPane, Npanes)
  475. Widget parent;
  476. PMCBStruct MenuPane[];
  477. int Npanes;
  478. {
  479. X  Arg args[MAXARGS];
  480. X  int widgetcount;
  481. X
  482. X
  483. X  for(widgetcount=0; widgetcount<Npanes; widgetcount++)
  484. X    {
  485. X      MenuPane[widgetcount].PM = 
  486. X    XmCreatePulldownMenu(parent, MenuPane[widgetcount].RNPM, 
  487. X                 args, 0);
  488. X      XtSetArg(args[0], XmNlabelString, 
  489. X           XmStringCreateLtoR(MenuPane[widgetcount].Label, 
  490. X                  XmSTRING_DEFAULT_CHARSET));
  491. X      XtSetArg(args[1], XmNsubMenuId, MenuPane[widgetcount].PM);
  492. X      XtSetArg(args[2], XmNmnemonic, MenuPane[widgetcount].mnemonic);
  493. X      MenuPane[widgetcount].CB = 
  494. X    XmCreateCascadeButton(parent, MenuPane[widgetcount].RNCB,
  495. X                         args, 3);
  496. X      XtManageChild(MenuPane[widgetcount].CB);
  497. X      CreateMenuButton(MenuPane[widgetcount].PM, 
  498. X               MenuPane[widgetcount].Buttons,
  499. X               MenuPane[widgetcount].Nbuttons);
  500. X    }
  501. }
  502. X
  503. void CreateMenuPane(parent)
  504. Widget parent;
  505. {
  506. X  Arg args[MAXARGS];
  507. X  
  508. X  topForm = XtCreateManagedWidget("topForm", xmFormWidgetClass, parent,
  509. X                  args, 0);
  510. X  
  511. X  XtSetArg(args[0], XmNtopAttachment, XmATTACH_FORM);
  512. X  XtSetArg(args[1], XmNleftAttachment, XmATTACH_FORM);
  513. X  XtSetArg(args[2], XmNrightAttachment, XmATTACH_FORM);
  514. X  topMenuBar = XmCreateMenuBar(topForm, "topMenuBar", args, 3);
  515. X  XtManageChild(topMenuBar);
  516. X
  517. X  XtSetArg(args[0], XmNbottomAttachment, XmATTACH_FORM);
  518. X  XtSetArg(args[3], XmNtopWidget, topMenuBar);
  519. X  XtSetArg(args[4], XmNtopAttachment, XmATTACH_WIDGET);
  520. X  vpane = XtCreateManagedWidget( "vpane", xmPanedWindowWidgetClass,
  521. X                    topForm, args, 5);
  522. X
  523. X  filePMenu = XmCreatePulldownMenu(topMenuBar, "filePMenu", args, 0);
  524. X
  525. X  XtSetArg(args[0], XmNsubMenuId, filePMenu);
  526. X  XtSetArg(args[1], XmNlabelString, 
  527. X       XmStringCreateLtoR("File", XmSTRING_DEFAULT_CHARSET));
  528. X  XtSetArg(args[2], XmNmnemonic, 'F');
  529. X  fileCButton = XmCreateCascadeButton(topMenuBar,"fileCButton", args, 3);
  530. X  XtManageChild(fileCButton);
  531. X
  532. X  CreateMenuButton(filePMenu, fileButtons, 4);
  533. X
  534. X  commandPMenu = XmCreatePulldownMenu(topMenuBar, "commandPMenu", args, 0);
  535. X
  536. X  XtSetArg(args[0], XmNsubMenuId, commandPMenu);
  537. X  XtSetArg(args[1], XmNlabelString, 
  538. X       XmStringCreateLtoR("Commands", XmSTRING_DEFAULT_CHARSET));
  539. X  XtSetArg(args[2], XmNmnemonic, 'C');
  540. X  commandsCButton = XmCreateCascadeButton(topMenuBar, "commandsCButton",
  541. X                      args, 3);
  542. X  XtManageChild(commandsCButton);
  543. X
  544. X  CreatePulldownMenu(commandPMenu, commandMB, 5);
  545. X
  546. X  helpPMenu = XmCreatePulldownMenu(topMenuBar, "helpPMenu", args, 0);
  547. X  XtSetArg(args[0], XmNsubMenuId, helpPMenu);
  548. X  XtSetArg(args[1], XmNlabelString, 
  549. X       XmStringCreateLtoR("Help", XmSTRING_DEFAULT_CHARSET));
  550. X  XtSetArg(args[2], XmNmnemonic, 'H');
  551. X  helpCButton = XmCreateCascadeButton(topMenuBar, "helpCButton",
  552. X                      args, 3);
  553. X  XtManageChild(helpCButton);
  554. X  CreateMenuButton(helpPMenu, helpButtons, 2);
  555. X
  556. }
  557. X
  558. /*
  559. X *  Top level function for creating all the mxgdb subwindows.
  560. X */
  561. void CreateSubWindows(parent)
  562. Widget parent;
  563. {
  564. X  Arg     args[MAXARGS];
  565. X  Cardinal     n;
  566. X  XmFontList labelFontList;
  567. X    
  568. X  labelFontList = XmFontListCreate(XLoadQueryFont(XtDisplay(toplevel), 
  569. X        "-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859-1"),
  570. X        XmSTRING_DEFAULT_CHARSET);
  571. X    
  572. X  CreateMenuPane(parent);
  573. X  CreateFileWindow(vpane);
  574. X  CreateSourceWindow(vpane);
  575. X  CreateMessageWindow(vpane);
  576. X  CreateDialogWindow(vpane);
  577. X
  578. X  fileSel = (Widget) XmCreateFileSelectionDialog(toplevel, 
  579. X                         "fileSelectorBox", 
  580. X                         args, 1);
  581. X  XtSetArg(args[0], XmNkeyboardFocusPolicy, XmPOINTER);
  582. X  XtSetValues(XtParent(fileSel), args, 1);
  583. X
  584. X  XtAddCallback(fileSel, XmNokCallback, OKCallBack, NULL);
  585. X  XtAddCallback(fileSel, XmNcancelCallback, CancelCallBack, NULL);
  586. X
  587. X  CreateDisplayWindow(toplevel);
  588. X  CreateHelpWindow(toplevel);
  589. X  CreateSearchPopup(toplevel);
  590. X  CreateInfoDialog(toplevel);
  591. X
  592. X  XtSetArg(args[0], XmNmessageString,
  593. X       XmStringCreateLtoR("OK to Exit Mxgdb?", 
  594. X                  XmSTRING_DEFAULT_CHARSET));
  595. X  exitWarning = XmCreateQuestionDialog(toplevel, "MXGDB exit", args, 1);
  596. X  XtAddCallback(exitWarning, XmNokCallback, Quit, NULL);
  597. X  XtUnmanageChild(XmMessageBoxGetChild(exitWarning, XmDIALOG_HELP_BUTTON));
  598. X  XtSetArg(args[0], XmNfontList, labelFontList);
  599. X  XtSetValues(XmMessageBoxGetChild(exitWarning, XmDIALOG_CANCEL_BUTTON)
  600. X          , args, 1);
  601. X  XtSetValues(XmMessageBoxGetChild(exitWarning, XmDIALOG_OK_BUTTON)
  602. X          , args, 1);
  603. X  XtSetValues(XmMessageBoxGetChild(exitWarning, XmDIALOG_CANCEL_BUTTON)
  604. X          , args, 1);
  605. X  XtSetValues(XmMessageBoxGetChild(exitWarning, XmDIALOG_MESSAGE_LABEL)
  606. X          , args, 1);
  607. X
  608. /*
  609. X *  Routines for updating fields for the filename and line number
  610. X *  in the file window, and the execution status in the message window.
  611. X */
  612. X
  613. void UpdateFileLabel(string)
  614. char *string;
  615. {
  616. X    Arg     args[MAXARGS];
  617. X
  618. X    XtSetArg(args[0], XmNlabelString, 
  619. X         XmStringCreateLtoR(string, XmSTRING_DEFAULT_CHARSET));
  620. X    XtSetValues(fileLabel, args, 1);
  621. X
  622. }
  623. X
  624. void UpdateLineLabel(line)
  625. Cardinal line;
  626. {
  627. X    Arg     args[MAXARGS];
  628. X    Cardinal     n;
  629. X    char     string[10];
  630. X
  631. X    n = 0;
  632. X    if (line > 0)
  633. X        sprintf(string, "%d", line);
  634. X    else
  635. X    strcpy(string, "");
  636. X    XtSetArg(args[0], XmNlabelString, 
  637. X         XmStringCreateLtoR(string, XmSTRING_DEFAULT_CHARSET));
  638. X    XtSetValues(lineLabel, args, 1);
  639. }
  640. X
  641. /*--------------------------------------------------------------------------+
  642. X  |                                        |
  643. X  |    Note : UpdateMessageWindow assumes that the format string        |
  644. X  |            can only contain one %s specifier.            |
  645. X  |        arg is either NULL or is a string.                |
  646. X  |        format is a string (never NULL).                |
  647. X  |                                        |
  648. X  +--------------------------------------------------------------------------*/
  649. void UpdateMessageWindow(format, arg)
  650. X     char *format, *arg;
  651. {
  652. X  char *message;
  653. X  char string[LINESIZ];
  654. X  int fulllength;
  655. X  Arg     args[MAXARGS];
  656. X  Cardinal     n;
  657. X  
  658. X  fulllength = strlen ("  ") + strlen (format) + 1
  659. X    + ((arg == NULL) ? 0 : strlen (arg));
  660. X
  661. X  if (fulllength > LINESIZ)
  662. X    message = (char*) XtMalloc (fulllength);
  663. X  else
  664. X    message = string;
  665. X  
  666. X  strcpy(message, "  ");
  667. X  sprintf(message + strlen(message), format, arg);
  668. X
  669. X  XtSetArg(args[0], XmNlabelString, 
  670. X       XmStringCreateLtoR(message, XmSTRING_DEFAULT_CHARSET));
  671. X  XtSetValues(messageWindow, args, 1);
  672. X  
  673. X  if (fulllength > LINESIZ)
  674. X    XtFree(message);
  675. }
  676. X
  677. void ClearMessageWindow()
  678. {
  679. X    Arg     args[MAXARGS];
  680. X
  681. X    XtSetArg(args[0], XmNlabelString, 
  682. X         XmStringCreateLtoR("", XmSTRING_DEFAULT_CHARSET));
  683. X    XtSetValues(messageWindow, args, 1);
  684. }
  685. X
  686. SHAR_EOF
  687. echo 'File mxgdb/windows.c is complete' &&
  688. chmod 0664 mxgdb/windows.c ||
  689. echo 'restore of mxgdb/windows.c failed'
  690. Wc_c="`wc -c < 'mxgdb/windows.c'`"
  691. test 21420 -eq "$Wc_c" ||
  692.     echo 'mxgdb/windows.c: original size 21420, current size' "$Wc_c"
  693. rm -f _shar_wnt_.tmp
  694. fi
  695. # ============= mxgdb/gdb_parser.c ==============
  696. if test -f 'mxgdb/gdb_parser.c' -a X"$1" != X"-c"; then
  697.     echo 'x - skipping mxgdb/gdb_parser.c (File already exists)'
  698.     rm -f _shar_wnt_.tmp
  699. else
  700. > _shar_wnt_.tmp
  701. echo 'x - extracting mxgdb/gdb_parser.c (Text)'
  702. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/gdb_parser.c' &&
  703. /* $Id: gdb_parser.c,v 1.3 1991/07/16 16:33:20 jtsillas Exp $ */
  704. X
  705. /*****************************************************************************
  706. X *
  707. X *  xdbx - X Window System interface to the dbx debugger
  708. X *
  709. X *  Copyright 1989 The University of Texas at Austin
  710. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  711. X *
  712. X *  Permission to use, copy, modify, and distribute this software and its
  713. X *  documentation for any purpose and without fee is hereby granted,
  714. X *  provided that the above copyright notice appear in all copies and that
  715. X *  both that copyright notice and this permission notice appear in
  716. X *  supporting documentation, and that the name of The University of Texas
  717. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  718. X *  used in advertising or publicity pertaining to distribution of
  719. X *  the software without specific, written prior permission.  The
  720. X *  University of Texas and MCC makes no representations about the 
  721. X *  suitability of this software for any purpose.  It is provided "as is" 
  722. X *  without express or implied warranty.
  723. X *
  724. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  725. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  726. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  727. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  728. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  729. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  730. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  731. X *
  732. X *  Author:      Po Cheung
  733. X *  Created:       March 10, 1989
  734. X * 
  735. X *****************************************************************************
  736. X * 
  737. X *  xxgdb - X Window System interface to the gdb debugger
  738. X *  
  739. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  740. X *  
  741. X *  Permission to use, copy, modify, and distribute this software and its
  742. X *  documentation for any purpose and without fee is hereby granted,
  743. X *  provided that the above copyright notice appear in all copies and that
  744. X *  both that copyright notice and this permission notice appear in
  745. X *  supporting documentation, and that the name of Thomson Consumer
  746. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  747. X *  to distribution of the software without specific, written prior
  748. X *  permission.  TCE makes no representations about the suitability of
  749. X *  this software for any purpose.  It is provided "as is" without express
  750. X *  or implied warranty.
  751. X *
  752. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  753. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  754. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  755. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  756. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  757. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  758. X *  SOFTWARE.
  759. X *
  760. X *  Adaptation to GDB:  Pierre Willard
  761. X *  XXGDB Created:       December, 1990
  762. X *
  763. X *****************************************************************************
  764. X
  765. /*  gdb_parser.c:
  766. X *
  767. X *    WARNING : gdb_parser.c is included by parser.c for GDB.
  768. X *
  769. X *    Parse output messages from dbx using regular expression pattern matching,
  770. X *    and take appropriate action.
  771. X *
  772. X *    parse():        Parse the dbx output and invoke the appropriate action
  773. X *            handler.
  774. X *    filter():        Modify the dbx output before it gets displayed on the
  775. X *            dialog window.
  776. X *    gdb_source_command():    Test for source command.
  777. X */
  778. X
  779. #include     <string.h>
  780. X
  781. /*--------------------------------------------------------------------------+
  782. |                                                                            |
  783. |    Function to remove all 'Reading in symbols' message                        |
  784. |    from a string.                                                            |
  785. |                                                                            |
  786. |    This function is used in parser() before matching the output            |
  787. |    because this message can happen any time.                                |
  788. |                                                                            |
  789. +--------------------------------------------------------------------------*/
  790. void filter_reading_symbols(output)
  791. char *output;
  792. {
  793. struct re_registers regs;
  794. int    r;
  795. char *p1;
  796. char *p2;
  797. X
  798. X        /* test for reading symbols message */
  799. X    
  800. X    while (re_match(output_pattern[O_READING_SYMBOLS].buf,output,strlen(output),0,®s) > 0)
  801. X        {
  802. X        /* we found a "Reading in symbols for     ...done." pattern */
  803. X        
  804. X        r = output_pattern[O_READING_SYMBOLS].reg_token[TK_MESG];
  805. X        p1=  output+regs.start[r];
  806. X        p2 = output+regs.end[r];
  807. X        
  808. X        /* remove "Reading in symbols for     ...done." */
  809. X        
  810. X        while(*(p1++) = *(p2++));
  811. X        }
  812. }
  813. X
  814. /*--------------------------------------------------------------------------+
  815. |                                                                            |
  816. | *     This routine first parses the command string.                            |
  817. | *     If the command is one of run, cont, next, step, stop at, stop in,        |
  818. | *     where, up, or down, it parses the dbx output to decide what action        |
  819. | *     to take and dispatch it to one of the handlers.                        |
  820. | *     For other commands, the appropriate handler is called.                    |
  821. | *                                                                            |
  822. | *     !!! This routine has to be re-entrant.                                    |
  823. | *                                                                            |
  824. +--------------------------------------------------------------------------*/
  825. void parse(output, command)
  826. char *output;
  827. char *command;
  828. {
  829. X    int  command_type;
  830. X    char *output_string;
  831. X
  832. X    if (debug) {
  833. X      char *temp;
  834. X      if(!command)temp="";else temp=command;
  835. X    fprintf(stderr, "parse(output = %s, command = %s)\n", output, temp);
  836. X    }
  837. X
  838. X    /* Make a local copy of `output' and use that instead */
  839. X    output_string = XtNewString(output);
  840. X    if (output) strcpy(output, "");
  841. X
  842. X    if (!command) {
  843. X    if (match(output_pattern, output_string, O_DEBUG) != -1)
  844. X        debug_handler(); 
  845. X    debug_init();
  846. X    XtFree(output_string);
  847. X    return;
  848. X    }
  849. X    
  850. X    if (!Parse)
  851. X        {
  852. X        XtFree(output_string);
  853. X        return;
  854. X        }
  855. X
  856. X    if (match(output_pattern, output_string, O_BELL) != -1)
  857. X        {
  858. X        bell(0);
  859. X        XtFree(output_string);
  860. X        return;
  861. X        }
  862. X    
  863. X    command_type = match(command_pattern, command, C_ANY);
  864. X    
  865. X    
  866. X    /* remove all "Reading in symbols for pw.c...done."  */
  867. X
  868. X    filter_reading_symbols(output_string);
  869. X            
  870. X    switch (command_type) {
  871. X          case C_EXEC: 
  872. X        case C_FINISH:
  873. X        {
  874. X        char * message;
  875. X        int signal;
  876. X        message = 0;
  877. X        if (match(output_pattern, output_string, O_RECEIVED_SIGNAL) != -1)
  878. X            {
  879. X            message = XtNewString(Token.mesg);
  880. X            signal = Token.stop;    /* signal number received */
  881. X            }
  882. X            
  883. X        /* warning : the order of the matching tests is important */
  884. X        
  885. X        if ((match(output_pattern, output_string, O_EXEC_MESS_AFTER) != -1)
  886. X            || (match(output_pattern, output_string, O_EXEC_MESS_BEFORE) != -1)
  887. X            || (match(output_pattern, output_string, O_EXEC) != -1))
  888. X            {
  889. X            exec_handler(message,signal);
  890. X            }
  891. X        else 
  892. X            {
  893. X            if (match(output_pattern, output_string, O_DONE) != -1)
  894. X                done_handler(message,signal);
  895. X            else
  896. X                bell(0);
  897. X            }
  898. X            
  899. X        if (message)
  900. X            {
  901. X            bell(0);
  902. X            XtFree(message);
  903. X            }
  904. X        }
  905. X        break;
  906. X        
  907. X    case C_UPDOWN:
  908. X        if (match(output_pattern, output_string, O_UPDOWN) != -1)
  909. X        updown_handler();
  910. X        else
  911. X        bell(0);
  912. X        break;
  913. X    case C_SEARCH:
  914. X        if (match(output_pattern, output_string, O_SEARCH) != -1)
  915. X        search_handler();
  916. X        else
  917. X        bell(0);
  918. X        break;
  919. X    case C_CLEAR:
  920. X        clear_handler(); 
  921. X        break;
  922. X    case C_LIST:
  923. X        if (match(output_pattern, output_string, O_LIST) != -1)
  924. X            list_handler();
  925. X        else
  926. X        bell(0);
  927. X        break;
  928. X        
  929. X    case C_BREAK: 
  930. X        if (match(output_pattern, output_string, O_BREAK) != -1)
  931. X            break_handler();
  932. X        else
  933. X        bell(0);
  934. X        break;
  935. X        
  936. X    case C_INFO_DIR:
  937. X        if (match(output_pattern, output_string, O_INFO_DIR) != -1)
  938. X            info_dir_handler();
  939. X        else
  940. X        bell(0);    
  941. X        break;
  942. X        
  943. X    case C_DIRECTORY:
  944. X        directory_handler(); 
  945. X        break;
  946. X        
  947. X    case C_INFO_LINE:
  948. X        if (match(output_pattern, output_string, O_INFO_LINE) != -1)
  949. X            info_line_handler();        /* command was 'info line' */
  950. X        else
  951. X        bell(0);
  952. X        break;
  953. X        
  954. X    case C_INFO_BREAK:
  955. X        info_break_handler(output_string);
  956. X        break;
  957. X
  958. X    case C_DISPLAY:
  959. X        {
  960. X        if ((!strcmp(output_string, "")) ||
  961. X            (match(output_pattern, output_string, O_DISPLAY) != -1))
  962. X            display_handler();
  963. X        else
  964. X        bell(0);
  965. X        }
  966. X        break;
  967. X        
  968. X    case C_UNDISPLAY:
  969. X        if (!strcmp(output_string, ""))
  970. X            display_handler();
  971. X        else
  972. X        bell(0);
  973. X        break;
  974. X
  975. X    case C_DISPLAY_INFO:
  976. X        {
  977. X        if ((!strcmp(output_string, "")) ||
  978. X            (match(output_pattern, output_string, O_DISPLAY_INFO) != -1))
  979. X            display_info_handler();
  980. X        else
  981. X        bell(0);
  982. X        }
  983. X        break;
  984. X        
  985. X    case C_CD:
  986. X        if (match(output_pattern, output_string, O_CD) != -1)
  987. X            cd_handler(Token.mesg); 
  988. X        else
  989. X        bell(0);
  990. X        break;
  991. X        
  992. X    case C_PWD:
  993. X        if (match(output_pattern, output_string, O_PWD) != -1)
  994. X            pwd_handler(Token.mesg);
  995. X        else
  996. X        bell(0);
  997. X        break;
  998. X
  999. X    case C_FRAME_CURR:
  1000. X        if (match(output_pattern, output_string, O_FRAME_CURR) != -1)
  1001. X        frame_curr_handler();
  1002. X        else
  1003. X        bell(0);
  1004. X        break;
  1005. X
  1006. X    case C_PRINT:
  1007. X        match(output_pattern, output_string, O_PRINT);
  1008. X        break;
  1009. X    case C_HELP:
  1010. X        if(match(output_pattern, output_string, O_HELP) != -1)
  1011. X          help_handler(command, output_string);
  1012. X        break;
  1013. X    case C_SYMBOL_FILE:
  1014. X        debug_handler(); 
  1015. X        break;
  1016. X
  1017. X    case C_SOURCE:    /* WE SHOULD NEVER ARRIVE HERE */
  1018. X        break;
  1019. X
  1020. X    case C_EXEC_FILE:
  1021. X        break;
  1022. X        
  1023. X    default:
  1024. X        break;
  1025. X    }
  1026. X    XtFree(output_string);
  1027. }
  1028. X
  1029. /*--------------------------------------------------------------------------+
  1030. |                                                                            |
  1031. |    Function to filter all the display information in a string                |
  1032. |                                                                            |
  1033. |    input : string pointer.                                                    |
  1034. |                                                                            |
  1035. |    output : none.                                                            |
  1036. |                                                                            |
  1037. |    See O_EXEC_DISPLAY in gdb_regex.h for the display pattern.                |
  1038. |                                                                            |
  1039. |    Take care when GDB send some message after '\032\032...\n'                |
  1040. |    which is not a display line.                                            |
  1041. |                                                                            |
  1042. | (gdb) finish                                                                |
  1043. | Run till exit from #0     foo (n=1) (pw.c line 9)                            |
  1044. | main () (pw.c line 41)                                                    |
  1045. | /usr1/gnu_sun4/xxgdb/pw.c:41:590:beg:0x232c                                |
  1046. | 1: i = 1                                                                    |
  1047. | Value returned is $1 = 1                                                    |
  1048. | (gdb)                                                                        |
  1049. |                                                                            |
  1050. +--------------------------------------------------------------------------*/
  1051. void filter_display_info(output)
  1052. char *output;
  1053. {
  1054. struct re_registers regs;
  1055. int    r;
  1056. char *p;
  1057. char *p1;
  1058. char *p2;
  1059. char *cp_output;
  1060. int begin_struct;
  1061. X
  1062. X    p = cp_output = XtNewString(output);
  1063. X
  1064. X    p1 = strstr(p,"\032\032");        /* find beginning of special gdb line */
  1065. X    
  1066. X    if ((p1 == 0) || ((p2 = strchr(p1+1,'\n')) == 0))
  1067. X        {
  1068. X        AppendDialogText(p);        /* something wrong here */
  1069. X        XtFree(cp_output);
  1070. X        return;
  1071. X        }
  1072. X        
  1073. X    *p1 = 0;
  1074. X    AppendDialogText(p);            /* print everything before that line */
  1075. X    p = p2 + 1;                        /* end of that line + skip \n */
  1076. X
  1077. X    /* test for beginning of a display */
  1078. X    
  1079. X    while (re_match(output_pattern[O_EXEC_DISPLAY].buf,p,strlen(p),0,®s) > 0)
  1080. X        {
  1081. X        /* we found a "X:....\n" pattern */
  1082. X        
  1083. X        r = output_pattern[O_EXEC_DISPLAY].reg_token[TK_DISP];
  1084. X        p1=  p+regs.start[r];
  1085. X        p2 = p+regs.end[r];
  1086. X                    
  1087. X        /* count number of { and } : if not equal, the next lines are part of this display */
  1088. X        begin_struct = 0;
  1089. X        while (p1 < p2)
  1090. X            {
  1091. X            switch(*(p1++))
  1092. X                {
  1093. X                case '{':
  1094. X                    begin_struct++;
  1095. X                    break;
  1096. X                case '}':
  1097. X                    begin_struct--;
  1098. X                    break;
  1099. X                }
  1100. X            }
  1101. X            
  1102. X        p1=p+regs.start[r];
  1103. X        *p1 = 0;
  1104. X        if (p != p1)
  1105. X            AppendDialogText(p);    /* print what is before display */
  1106. X        p = p2;                        /* skip display text */
  1107. X                    
  1108. X        if (begin_struct)
  1109. X            {
  1110. X            /* try to find end of display structure */
  1111. X            
  1112. X            if (p1 = strstr(p,"\n}\n"))
  1113. X                p = p1 + strlen("\n}\n");
  1114. X            }
  1115. X        }
  1116. X        
  1117. X    AppendDialogText(p);        /* print what is after display */
  1118. X    XtFree(cp_output);
  1119. }
  1120. X
  1121. /*--------------------------------------------------------------------------+
  1122. |                                                                            |
  1123. | *     This function edits the dbx output so that unnecessary information is    |
  1124. | *     not displayed on the dialog window.                                    |
  1125. | *     It filters away the some output returned by the execution commands;    |
  1126. | *     output from the search commands, and the display command.                |
  1127. | *     On Sun dbx, it also filters away part of the output returned by the    |
  1128. | *     up and down commands.                                                    |
  1129. | *                                                                            |
  1130. +--------------------------------------------------------------------------*/
  1131. void filter(string, output, command)
  1132. char *string, *output, *command;
  1133. {
  1134. X    struct re_registers regs;
  1135. X    char         *p;
  1136. X    char         *p2;
  1137. X    char         *p3;
  1138. X    int            r;
  1139. X    static Boolean    deleteRest = False;
  1140. X    int            command_type = -1;
  1141. X    static unsigned int already_taken_care;    
  1142. X
  1143. X    if (output == NULL || !strcmp(output, "")) 
  1144. X    return;
  1145. X
  1146. /* for GDB, the only things we want to filter are:
  1147. X
  1148. X    - the line displayed because of the -fullname  option :
  1149. X    "\032\032/usr1/gnu_sun4/xdbx/pw.c:6:40:beg:0x22b0\n",
  1150. X    
  1151. X    - the displayed info which goes into the display window,
  1152. X    
  1153. X    - list and search outputs
  1154. X
  1155. */
  1156. X    if (!string)
  1157. X        string = "";
  1158. X        
  1159. X    if (command)
  1160. X        command_type = match(command_pattern, command, C_ANY);
  1161. X        
  1162. X    if ((command_type == C_EXEC)||(command_type == C_FINISH))
  1163. X        {
  1164. X        if ((re_match(output_pattern[O_EXEC_MESS_AFTER].buf,string,strlen(string),0,®s) > 0)
  1165. X            || (re_match(output_pattern[O_EXEC_MESS_BEFORE].buf,string,strlen(string),0,®s) > 0)
  1166. X            || (re_match(output_pattern[O_EXEC].buf,string,strlen(string),0,®s) > 0))
  1167. X            {
  1168. X            /* remember what was the output length was output was matched */
  1169. X            already_taken_care = strlen(output) - strlen(string);
  1170. X            
  1171. X            /* Remove display messages from output and print what is no a display */
  1172. X            
  1173. X            if (Prompt)
  1174. X                filter_display_info(output + already_taken_care);    
  1175. X            else
  1176. X                deleteRest = True;
  1177. X                
  1178. X            return;
  1179. X            }
  1180. X        else
  1181. X            {
  1182. X            if (deleteRest)        
  1183. X                {
  1184. X                /* Remove display messages from output and print what is no a display */
  1185. X                if (Prompt)
  1186. X                    {
  1187. X                    filter_display_info(output + already_taken_care);    
  1188. X                    deleteRest = False;
  1189. X                    }
  1190. X                return;
  1191. X                }
  1192. X            }
  1193. X        }
  1194. X        
  1195. X    /* filter any line starting with \032\032 */
  1196. X    
  1197. X    p = strchr(string,'\032');
  1198. X    if (p && (*(p+1) == '\032') && (p == string || *(p-1) == '\n') && (p2 = strchr(p,'\n')))
  1199. X        {
  1200. X        while (*(p++) = *(++p2));
  1201. X        }
  1202. X        
  1203. X    if ((command_type == C_EXEC)||(command_type == C_FINISH))
  1204. X        {
  1205. X        AppendDialogText(string);
  1206. X        return;
  1207. X        }
  1208. X        
  1209. X    if (Prompt)
  1210. X        {
  1211. X        char *s;
  1212. X
  1213. X        s = XtNewString(output);
  1214. X        switch (command_type)
  1215. X            {
  1216. X            case C_DISPLAY:
  1217. X                if (match(output_pattern, s, O_DISPLAY) != -1)
  1218. X                strcpy(s, "");
  1219. X                break;
  1220. X            case C_SEARCH:
  1221. X                if (match(output_pattern, s, O_SEARCH) != -1)
  1222. X                strcpy(s, "");
  1223. X                break;
  1224. X            case C_LIST:
  1225. X                if (match(output_pattern, s, O_LIST) != -1)
  1226. X                strcpy(s, "");
  1227. X                break;
  1228. X            case C_PRINT:
  1229. X                if(match(output_pattern, s, O_PRINT) == -1)
  1230. X                strcpy(s, "");
  1231. X                break;
  1232. X                
  1233. X            default:
  1234. X                XtFree(s);
  1235. X                s = XtNewString(string);        /* append 'string' only */
  1236. X                break;
  1237. X            }
  1238. X        AppendDialogText(s);
  1239. X        XtFree(s);
  1240. X        }
  1241. X    else
  1242. X        {
  1243. X        switch (command_type)
  1244. X            {
  1245. X            case C_DISPLAY:
  1246. X            case C_SEARCH:
  1247. X            case C_LIST:
  1248. X            case C_PRINT:
  1249. X                break;
  1250. X            default:
  1251. X                AppendDialogText(string);
  1252. X                break;
  1253. X            }
  1254. X        }
  1255. }
  1256. X
  1257. X
  1258. /*--------------------------------------------------------------------------+
  1259. |                                                                            |
  1260. |    Function to filter 'source' command                                        |
  1261. |                                                                            |
  1262. |    input : command (from .gdbinit or source command or keyboard),            |
  1263. |            echo is TRUE if source command must be echoed.                    |
  1264. |                                                                            |
  1265. |    output : TRUE if source command was recognized                            |
  1266. |                                                                            |
  1267. |    In case source command is recognized, it is executed here.                |
  1268. |                                                                            |
  1269. +--------------------------------------------------------------------------*/
  1270. int gdb_source_command(command,echo)
  1271. char *command;
  1272. int echo;
  1273. {
  1274. X    if (command && (match(command_pattern, command, C_SOURCE) != -1))
  1275. X        {
  1276. X        if (echo)
  1277. X            AppendDialogText(command);
  1278. X        source_handler();    
  1279. X        send_command(" \n");    /* ask GDB to redisplay its prompt */
  1280. X        return TRUE;
  1281. X        }
  1282. X        
  1283. X    return FALSE;
  1284. }
  1285. X
  1286. X
  1287. /*--------------------------------------------------------------------------+
  1288. |                                                                            |
  1289. |    Function to filter 'define' & 'document' commands                        |
  1290. |                                                                            |
  1291. |    input : command (from .gdbinit or source command),                        |
  1292. |            fp = file pointer.                                                |
  1293. |                                                                            |
  1294. |    output : TRUE if define or document command was recognized                |
  1295. |                                                                            |
  1296. |    In case the command is recognized, it is executed here.                    |
  1297. |                                                                            |
  1298. +--------------------------------------------------------------------------*/
  1299. int gdb_define_command(command,fp)
  1300. char *command;
  1301. FILE *fp;
  1302. {
  1303. char s[LINESIZ];
  1304. int error_cmd;
  1305. int end_found;
  1306. X
  1307. X    if ((command && (match(command_pattern, command, C_DEFINE) != -1))
  1308. X        || (command && (match(command_pattern, command, C_DOCUMENT) != -1)))
  1309. X        {
  1310. X        AppendDialogText(command);
  1311. X        send_command(command);
  1312. X        
  1313. /*
  1314. X                gdb could ask :
  1315. X            
  1316. X                    "Redefine command \"%s\"? "
  1317. X                    "Really redefine built-in command \"%s\"? "
  1318. X                    
  1319. X                gdb could display 
  1320. X                
  1321. X                    "Type commands for definition of \"%s\".\n"
  1322. X                    "End with a line saying just \"end\"
  1323. X                
  1324. X                or
  1325. X                    "Type documentation for \"%s\".\n"
  1326. X                    "End with a line saying just \"end\".\n"
  1327. X                    
  1328. X                or
  1329. X                     "Command \"%s\" is built-in."
  1330. */
  1331. X    
  1332. X        error_cmd = FALSE;
  1333. X                
  1334. X        /* read message from gdb */
  1335. SHAR_EOF
  1336. true || echo 'restore of mxgdb/gdb_parser.c failed'
  1337. fi
  1338. echo 'End of  part 4'
  1339. echo 'File mxgdb/gdb_parser.c is continued in part 5'
  1340. echo 5 > _shar_seq_.tmp
  1341. exit 0
  1342.