home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3643 < prev    next >
Encoding:
Text File  |  1991-07-17  |  40.1 KB  |  1,328 lines

  1. Newsgroups: alt.sources
  2. From: jtsillas@sprite.ma30.bull.com (James Tsillas)
  3. Subject: mxgdb Part 5/9
  4. Date: 16 Jul 91 13:08:33
  5. Message-ID: <JTSILLAS.91Jul16130833@sprite.ma30.bull.com>
  6.  
  7.  
  8.  
  9. ---- Cut Here and feed the following to sh ----
  10. #!/bin/sh
  11. # this is mxgdb.05 (part 5 of a multipart archive)
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file mxgdb/source.c continued
  14. #
  15. if test ! -r _shar_seq_.tmp; then
  16.     echo 'Please unpack part 1 first!'
  17.     exit 1
  18. fi
  19. (read Scheck
  20.  if test "$Scheck" != 5; then
  21.     echo Please unpack part "$Scheck" next!
  22.     exit 1
  23.  else
  24.     exit 0
  25.  fi
  26. ) < _shar_seq_.tmp || exit 1
  27. if test ! -f _shar_wnt_.tmp; then
  28.     echo 'x - still skipping mxgdb/source.c'
  29. else
  30. echo 'x - continuing file mxgdb/source.c'
  31. sed 's/^X//' << 'SHAR_EOF' >> 'mxgdb/source.c' &&
  32. X
  33. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  34. X    topdisplay, DefaultRootWindow(topdisplay), next_bits, next_width, 
  35. X    next_height, app_resources.stop_color, bg, 
  36. X    DefaultDepth(topdisplay, screen)));
  37. X    nextbutton = XtCreateManagedWidget("nextbutton",
  38. X                    xmPushButtonWidgetClass, sourceForm,
  39. X                    args, 7);
  40. X    XtAddCallback(nextbutton, XmNactivateCallback, DoIt, "next\n");
  41. X
  42. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  43. X    topdisplay, DefaultRootWindow(topdisplay), print_bits, print_width, 
  44. X    print_height, app_resources.stop_color, bg, 
  45. X    DefaultDepth(topdisplay, screen)));
  46. X    printbutton = XtCreateManagedWidget("printbutton",
  47. X                    xmPushButtonWidgetClass, sourceForm,
  48. X                    args, 7);
  49. X    XtAddCallback(printbutton, XmNactivateCallback, Print, (XtPointer)0);
  50. X
  51. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  52. X    topdisplay, DefaultRootWindow(topdisplay), down_bits, down_width, 
  53. X    down_height, app_resources.stop_color, bg, 
  54. X    DefaultDepth(topdisplay, screen)));
  55. X    downbutton = XtCreateManagedWidget("downbutton",
  56. X                    xmPushButtonWidgetClass, sourceForm,
  57. X                    args, 7);
  58. X    XtAddCallback(downbutton, XmNactivateCallback, DoIt, "down\n");
  59. X
  60. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  61. X    topdisplay, DefaultRootWindow(topdisplay), up_bits, up_width, 
  62. X    up_height, app_resources.stop_color, bg, 
  63. X    DefaultDepth(topdisplay, screen)));
  64. X    upbutton = XtCreateManagedWidget("upbutton",
  65. X                    xmPushButtonWidgetClass, sourceForm,
  66. X                    args, 7);
  67. X    XtAddCallback(upbutton, XmNactivateCallback, DoIt, "up\n");
  68. X
  69. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  70. X    topdisplay, DefaultRootWindow(topdisplay), stack_bits, stack_width, 
  71. X    stack_height, app_resources.stop_color, bg, 
  72. X    DefaultDepth(topdisplay, screen)));
  73. X    stackbutton = XtCreateManagedWidget("stackbutton",
  74. X                    xmPushButtonWidgetClass, sourceForm,
  75. X                    args, 7);
  76. X    XtAddCallback(stackbutton, XmNactivateCallback, DoIt, "info stack\n");
  77. X
  78. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  79. X    topdisplay, DefaultRootWindow(topdisplay), cont_bits, cont_width, 
  80. X    cont_height, app_resources.stop_color, bg, 
  81. X    DefaultDepth(topdisplay, screen)));
  82. X    contbutton = XtCreateManagedWidget("contbutton",
  83. X                    xmPushButtonWidgetClass, sourceForm,
  84. X                    args, 7);
  85. X    XtAddCallback(contbutton, XmNactivateCallback, DoIt, "cont\n");
  86. X
  87. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  88. X    topdisplay, DefaultRootWindow(topdisplay), finish_bits, finish_width, 
  89. X    finish_height, app_resources.stop_color, bg, 
  90. X    DefaultDepth(topdisplay, screen)));
  91. X    finishbutton = XtCreateManagedWidget("finishbutton",
  92. X                    xmPushButtonWidgetClass, sourceForm,
  93. X                    args, 7);
  94. X    XtAddCallback(finishbutton, XmNactivateCallback, DoIt, "finish\n");
  95. X
  96. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  97. X    topdisplay, DefaultRootWindow(topdisplay), run_bits, run_width, 
  98. X    run_height, app_resources.stop_color, bg, 
  99. X    DefaultDepth(topdisplay, screen)));
  100. X    runbutton = XtCreateManagedWidget("runbutton",
  101. X                    xmPushButtonWidgetClass, sourceForm,
  102. X                    args,7);
  103. X    XtAddCallback(runbutton, XmNactivateCallback, DoIt, "run\n");
  104. X
  105. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  106. X    topdisplay, DefaultRootWindow(topdisplay), disp_bits, disp_width, 
  107. X    disp_height, app_resources.stop_color, bg, 
  108. X    DefaultDepth(topdisplay, screen)));
  109. X    dispbutton = XtCreateManagedWidget("dispbutton",
  110. X                    xmPushButtonWidgetClass, sourceForm,
  111. X                    args, 7);
  112. X    XtAddCallback(dispbutton, XmNactivateCallback, Display_, NULL);
  113. X
  114. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  115. X    topdisplay, DefaultRootWindow(topdisplay), undisp_bits, undisp_width, 
  116. X    undisp_height, app_resources.stop_color, bg, 
  117. X    DefaultDepth(topdisplay, screen)));
  118. X    undispbutton = XtCreateManagedWidget("undispbutton",
  119. X                    xmPushButtonWidgetClass, sourceForm,
  120. X                    args, 7);
  121. X    XtAddCallback(undispbutton, XmNactivateCallback, Undisplay, NULL);
  122. X
  123. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  124. X    topdisplay, DefaultRootWindow(topdisplay), clear_bits, clear_width, 
  125. X    clear_height, app_resources.stop_color, bg, 
  126. X    DefaultDepth(topdisplay, screen)));
  127. X    clearbutton = XtCreateManagedWidget("clearbutton",
  128. X                    xmPushButtonWidgetClass, sourceForm,
  129. X                    args, 7);
  130. X    XtAddCallback(clearbutton, XmNactivateCallback, Clear, NULL);
  131. X
  132. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  133. X    topdisplay, DefaultRootWindow(topdisplay), prints_bits, prints_width, 
  134. X    prints_height, app_resources.stop_color, bg, 
  135. X    DefaultDepth(topdisplay, screen)));
  136. X    printsbutton = XtCreateManagedWidget("printsbutton",
  137. X                    xmPushButtonWidgetClass, sourceForm,
  138. X                    args, 7);
  139. X    XtAddCallback(printsbutton, XmNactivateCallback, Print, (XtPointer)1);
  140. X
  141. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  142. X    topdisplay, DefaultRootWindow(topdisplay), args_bits, args_width, 
  143. X    args_height, app_resources.stop_color, bg, 
  144. X    DefaultDepth(topdisplay, screen)));
  145. X    argsbutton = XtCreateManagedWidget("argsbutton",
  146. X                    xmPushButtonWidgetClass, sourceForm,
  147. X                    args, 7);
  148. X    XtAddCallback(argsbutton, XmNactivateCallback, DoIt, "info args\n");
  149. X
  150. X    XtSetArg(args[6], XmNlabelPixmap, XCreatePixmapFromBitmapData (
  151. X    topdisplay, DefaultRootWindow(topdisplay), locals_bits, locals_width, 
  152. X    locals_height, app_resources.stop_color, bg, 
  153. X    DefaultDepth(topdisplay, screen)));
  154. X    localsbutton = XtCreateManagedWidget("localsbutton",
  155. X                    xmPushButtonWidgetClass, sourceForm,
  156. X                    args, 7);
  157. X    XtAddCallback(localsbutton, XmNactivateCallback, DoIt, "info locals\n");
  158. X
  159. X
  160. X    XtAppAddActions(app_context, command_actions, XtNumber(command_actions));
  161. }
  162. X
  163. X
  164. /*
  165. X *  Build the array which gives the starting text position of each line.
  166. X *  > Estimate the number of lines in the file and allocate memory buffer.
  167. X *  > Starting position of line #1 is 0, and is stored in linepos[1].
  168. X *  > Search for '\n' till end of buffer.
  169. X */
  170. static void BuildLinePos(file)
  171. FileRec *file;
  172. {
  173. X    char *p;
  174. X    int     line, nlines;
  175. X
  176. X    nlines = MAX(1, file->filesize/CHARS_PER_LINE);
  177. X    file->linepos = (XmTextPosition *)
  178. X            XtMalloc ((nlines+2) * sizeof(XmTextPosition));
  179. X    p = file->buf;
  180. X    line = 0;
  181. X    file->linepos[line++] = 0;
  182. X    file->linepos[line++] = 0;
  183. X    while (*p) {
  184. X    if (*p++ == '\n') {
  185. X        if (line == nlines) {     /* buffer full, need more memory */
  186. X                file->linepos = (XmTextPosition *) XtRealloc (file->linepos, 
  187. X              (nlines + ADD_LINES) * sizeof(XmTextPosition));
  188. X        nlines += ADD_LINES;
  189. X            }
  190. X            file->linepos[line++] = p - file->buf;
  191. X    }
  192. X    }
  193. X    file->lastline = line - 2;
  194. X    file->linepos = (XmTextPosition *) XtRealloc       /* shrink to min size */
  195. X            (file->linepos, line * sizeof(XmTextPosition));
  196. }
  197. X
  198. X
  199. /*
  200. X * Look up the file table for an entry with "filename"
  201. X * If not found, create an entry and initialize proper fields,
  202. X * else, return pointer to entry found.
  203. X */
  204. static LookUpFileTable(pathname, filename, file)
  205. char *pathname, *filename;
  206. FileRec **file;
  207. {
  208. X    struct stat fileinfo;
  209. X    int      fd;
  210. X    int     i, j, n;
  211. X
  212. X    for (i=0; fileTable && fileTable[i] && i<fileTableSize; i++) {
  213. X    if (!strcmp(fileTable[i]->pathname, pathname)) { /* file found */
  214. X        if (stat(pathname, &fileinfo) == -1) {
  215. X        UpdateMessageWindow("Error: cannot stat file %s", pathname);
  216. X            *file = fileTable[i];
  217. X        return 0;
  218. X        }
  219. X        if (fileinfo.st_mtime > fileTable[i]->mtime) { /* file modified */
  220. X        XtFree((char *)fileTable[i]->buf);
  221. X        XtFree((char *)fileTable[i]->linepos);
  222. X        XtFree((char *)fileTable[i]);
  223. X        displayedFile = NULL;
  224. X        break;
  225. X        }
  226. X        else if (displayedFile &&         /* same as displayed file */
  227. X             strcmp(pathname, displayedFile->pathname) == 0) {
  228. X        *file = NULL;
  229. X        return 0;
  230. X        }
  231. X        else {
  232. X            *file = fileTable[i];
  233. X        return 0;
  234. X        }
  235. X    }
  236. X    }
  237. X
  238. X    /* Record file into file table */
  239. X
  240. X    if (i == fileTableSize) {        /* file table full, enlarge it */
  241. X    fileTableSize += ADD_SIZE;
  242. X    fileTable = (FileRec **) 
  243. X             XtRealloc (fileTable, fileTableSize * sizeof(FileRec *));
  244. X    for (j=i; j<fileTableSize; j++)
  245. X        fileTable[j] = NULL;
  246. X    }
  247. X    if ((fd = open(pathname, O_RDONLY)) == -1) {
  248. X    UpdateMessageWindow("Error: cannot open file %s", pathname);
  249. X    return -1;
  250. X    }
  251. X    if (fstat(fd, &fileinfo) == -1) {
  252. X    UpdateMessageWindow("Error: cannot fstat file %s", pathname);
  253. X    close(fd);
  254. X    return -1;
  255. X    }
  256. X    fileTable[i] = (FileRec *) XtMalloc (sizeof(FileRec));
  257. X    fileTable[i]->filesize = fileinfo.st_size + 1;
  258. X    fileTable[i]->mtime = fileinfo.st_mtime;
  259. X    fileTable[i]->buf = XtMalloc((int)fileTable[i]->filesize);
  260. X    if ((n = read(fd, fileTable[i]->buf, (int) fileTable[i]->filesize)) == -1) {
  261. X    UpdateMessageWindow("Error: cannot read file %s", pathname);
  262. X    XtFree(fileTable[i]->buf);
  263. X    XtFree(fileTable[i]);
  264. X    fileTable[i] = NULL;
  265. X    close(fd);
  266. X    return -1;
  267. X    }
  268. X    fileTable[i]->buf[n] = '\0';
  269. X    fileTable[i]->pathname = XtNewString(pathname);
  270. X    fileTable[i]->filename = XtNewString(filename);
  271. X    fileTable[i]->currentline = 1;
  272. X    fileTable[i]->topline = 1;
  273. X    fileTable[i]->bottomline = 0;
  274. X    fileTable[i]->topPosition = 0;
  275. X    BuildLinePos(fileTable[i]);
  276. X    close(fd);
  277. X    *file = fileTable[i];
  278. X    return 0;
  279. }
  280. X
  281. /*  
  282. X *  Remember file position and current line before closing.
  283. X */
  284. static void SaveDisplayedFileInfo()
  285. {
  286. X    XmTextPosition pos;
  287. X    Arg args[MAXARGS];
  288. X
  289. X    if (displayedFile) {
  290. X      XtSetArg(args[0], XmNtopPosition, &(displayedFile->topPosition));
  291. X      XtGetValues(sourceWindow, args, 1);
  292. X      XtSetArg(args[0], XmNcursorPosition, &pos);
  293. X      XtGetValues(sourceWindow, args, 1);
  294. X      displayedFile->currentline = TextPositionToLine(pos);
  295. X    }
  296. }
  297. X
  298. X
  299. /*   DisplayFile() displays the file onto the source window.  It
  300. X *     uses topPosition to remember where it was last opened.  But it
  301. X *     must recalculate bottomline because the window size might be
  302. X *     different.
  303. X */
  304. static void DisplayFile(file)
  305. FileRec *file;
  306. {
  307. X    Arg     args[MAXARGS];
  308. X    short       columns, rows, rowcount;
  309. X    int         slidersize;
  310. X    Dimension   height, width;
  311. X
  312. X    XtSetArg(args[0], XmNeditable, False);
  313. X    XtSetArg(args[1], XmNvalue, file->buf);
  314. X    XtSetValues(sourceWindow, args, 2);
  315. X
  316. X    XtSetArg(args[0], XmNrows, &rows);
  317. X    XtSetArg(args[1], XmNcolumns, &columns);
  318. X    XtGetValues(sourceWindow, args, 2);
  319. X
  320. X    file->lines = rows;
  321. X    file->bottomline = MIN (file->topline + file->lines - 1, file->lastline);
  322. X
  323. X    if(file->lastline < rows)
  324. X      {
  325. X    if(XtIsManaged(scrollV))
  326. X        XtUnmanageChild(scrollV);
  327. X      }
  328. X    else
  329. X      {
  330. X    XtManageChild(scrollV);
  331. X    XtSetArg(args[0], XmNheight, &height);
  332. X    XtGetValues(scrollV, args, 1);
  333. X    slidersize = ((int)rows * (int)height)/(int)file->lastline;
  334. X    XmScrollBarSetValues(scrollV, 1, slidersize, 1, 0, True);
  335. X    XtSetArg(args[0], XmNmaximum, file->lastline+slidersize);
  336. X    XtSetArg(args[1], XmNminimum, 0);
  337. X    XtSetValues(scrollV, args, 2);
  338. X
  339. X      }
  340. }
  341. X
  342. X
  343. /*  Given a filename starting with a tilde (`~'), it expands ~[user] to
  344. X *  the home directory of that user, or to the login home directory if user
  345. X *  is not specified.
  346. X */
  347. static char *expand(filename)
  348. char *filename;
  349. {
  350. X    struct passwd *pwd;
  351. X    char       *string, *name, newfile[MAXNAME];
  352. X
  353. X    string = XtNewString(filename+1);
  354. X    if (*string == '\0' || *string == '/')
  355. X    name = (char *) getlogin();
  356. X    else
  357. X        name = (char *) strtok(string, "/");
  358. X    if (name == NULL)
  359. X    return filename;
  360. X    pwd = (struct passwd *) getpwnam(name);
  361. X    if (pwd && pwd->pw_dir) {
  362. X        sprintf(newfile, "%s%s", pwd->pw_dir, filename+strlen(name)+1);
  363. X        return XtNewString(newfile);
  364. X    }
  365. X    else
  366. X    return filename;
  367. }
  368. X
  369. X
  370. /*  Create a list of directories for searching source files.
  371. X *  It reads the list of directories specified by the user, adding
  372. X *  the current directory into the list if it is not already there.
  373. X *
  374. X *  With fix from Dave Gagne (daveg@fs1.ee.ubc.ca) 7/30/90
  375. X */
  376. void MakeDirList(output)
  377. char *output;
  378. {
  379. X    char *s, list[BUFSIZ], command[LINESIZ];
  380. X    int  i, use_cwd;
  381. X
  382. X    for (i=0; dirList[i]; i++)            /* remove old list */
  383. X    XtFree(dirList[i]);
  384. X    i = 0;
  385. X    use_cwd = TRUE;
  386. X    if (output) {                                        /* create list */
  387. X        s = (char *) strtok(output, ": \n");
  388. X        while (s) {
  389. X            dirList[i] = XtNewString(s);
  390. X
  391. X            if (dirList[i][0] == '~')                   /* expand '~' */
  392. X                dirList[i] = expand(dirList[i]);
  393. X            if (LASTCH(dirList[i]) == '/')              /* remove last '/' */
  394. X                LASTCH(dirList[i]) = '\0';
  395. X            if (!strcmp(dirList[i], "."))        /* watch for "." */
  396. X                use_cwd = FALSE;
  397. X
  398. X            ++i;
  399. X            s = (char *) strtok(NULL, " \n");
  400. X        }
  401. X        dirList[i] = NULL;
  402. X    }
  403. X
  404. X    if (use_cwd) {                /* include current dir */
  405. X    dirList[i++] = XtNewString(".");        
  406. X        dirList[i] = NULL;
  407. X    }
  408. X    strcpy(list, "");                /* tell dbx our new list */
  409. X    for (i=0; dirList[i]; i++) {
  410. X    strcat(list, dirList[i]);
  411. X    strcat(list, " ");
  412. X    }
  413. X    sprintf(command, "directory %s\n", list);
  414. X    Parse = False;
  415. X    query_dbx(command);
  416. }
  417. X
  418. X
  419. /*  Returns the full pathname of a given file.
  420. X *  It searches for the file from a list of directories.
  421. X */
  422. char *GetPathname(filename)
  423. char *filename;
  424. {
  425. X    char    pathname[LINESIZ];
  426. X    int     i;
  427. X
  428. X    if (filename == NULL || !strcmp(filename, ""))
  429. X    return NULL;
  430. X    for (i=0; dirList[i]; i++) {
  431. X    if (*filename == '/' && access(filename, R_OK) == -1) { 
  432. X        /* this handles the exceptional case of sun4 dbx output */
  433. X        strcpy(filename, &filename[1]);
  434. X    }
  435. X    if (*filename == '/' || *filename == '~')
  436. X         strcpy(pathname, filename);
  437. X    else if (!strcmp(dirList[i], "."))
  438. X         sprintf(pathname, "%s/%s", cwd, filename);
  439. X    else if (*dirList[i] == '/' || *dirList[i] == '~')
  440. X         sprintf(pathname, "%s/%s", dirList[i], filename);
  441. X    else
  442. X         sprintf(pathname, "%s/%s/%s", cwd, dirList[i], filename);
  443. X    if (access(pathname, R_OK) == 0)
  444. X        return XtNewString(pathname);
  445. X    }
  446. X    UpdateMessageWindow("File not found: %s", filename);
  447. X    return NULL;
  448. }
  449. X
  450. /*
  451. X * Given a file name, LoadFile attempts to open it and displays it onto
  452. X * the source window:
  453. X *   1. get the full pathname of the file
  454. X *   2. LookUpFileTable() returns a pointer to the file's entry if it's
  455. X *      already in the table; else, creates an entry and return a pointer.
  456. X *   3. save the current displayedFile info
  457. X *   4. display the file
  458. X *   5. update the file label and the various signs on the source window.
  459. X *  LoadFile returns 0 upon successful completion, -1 otherwise.
  460. X */
  461. int LoadFile(filename)
  462. char *filename;
  463. {
  464. X    FileRec     *file;
  465. X    char    *pathname;
  466. X    Arg         args[5];
  467. X    Position    Py;
  468. X    
  469. X
  470. X    pathname = GetPathname(filename);
  471. X    if (pathname == NULL) { 
  472. X    return -1;
  473. X    }
  474. X    if (LookUpFileTable(pathname, filename, &file) != -1) {
  475. X    if (file) {    /* load new file */
  476. X        SaveDisplayedFileInfo();
  477. X        DisplayFile(file);
  478. X        UpdateFileLabel(pathname);
  479. X        XmTextClearSelection(sourceWindow,0);
  480. X        XmTextSetInsertionPosition(sourceWindow, 
  481. X                       file->linepos[file->currentline]);
  482. X        UpdateLineLabel(file->currentline);
  483. X        UpdateStops(file, -1);
  484. X        UpdateArrow(file);
  485. X        UpdateUpdown(file);
  486. X        UpdateBomb(file);
  487. X        displayedFile = file;
  488. X    }
  489. X        return 0;
  490. X    }
  491. X    else {        /* LookUpFileTable() fails */
  492. X        return -1;
  493. X    }
  494. }
  495. X
  496. int LoadCurrentFile()
  497. {
  498. X    query_dbx("info line\n");
  499. X    return LoadFile(CurrentFile);
  500. }
  501. X
  502. X
  503. SHAR_EOF
  504. echo 'File mxgdb/source.c is complete' &&
  505. chmod 0664 mxgdb/source.c ||
  506. echo 'restore of mxgdb/source.c failed'
  507. Wc_c="`wc -c < 'mxgdb/source.c'`"
  508. test 29383 -eq "$Wc_c" ||
  509.     echo 'mxgdb/source.c: original size 29383, current size' "$Wc_c"
  510. rm -f _shar_wnt_.tmp
  511. fi
  512. # ============= mxgdb/gdb_parser.c ==============
  513. if test -f 'mxgdb/gdb_parser.c' -a X"$1" != X"-c"; then
  514.     echo 'x - skipping mxgdb/gdb_parser.c (File already exists)'
  515.     rm -f _shar_wnt_.tmp
  516. else
  517. > _shar_wnt_.tmp
  518. echo 'x - extracting mxgdb/gdb_parser.c (Text)'
  519. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/gdb_parser.c' &&
  520. /* $Id: gdb_parser.c,v 1.2 1991/06/28 20:35:00 jtsillas Exp $ */
  521. X
  522. /*****************************************************************************
  523. X *
  524. X *  xdbx - X Window System interface to the dbx debugger
  525. X *
  526. X *  Copyright 1989 The University of Texas at Austin
  527. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  528. X *
  529. X *  Permission to use, copy, modify, and distribute this software and its
  530. X *  documentation for any purpose and without fee is hereby granted,
  531. X *  provided that the above copyright notice appear in all copies and that
  532. X *  both that copyright notice and this permission notice appear in
  533. X *  supporting documentation, and that the name of The University of Texas
  534. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  535. X *  used in advertising or publicity pertaining to distribution of
  536. X *  the software without specific, written prior permission.  The
  537. X *  University of Texas and MCC makes no representations about the 
  538. X *  suitability of this software for any purpose.  It is provided "as is" 
  539. X *  without express or implied warranty.
  540. X *
  541. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  542. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  543. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  544. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  545. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  546. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  547. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  548. X *
  549. X *  Author:      Po Cheung
  550. X *  Created:       March 10, 1989
  551. X * 
  552. X *****************************************************************************
  553. X * 
  554. X *  xxgdb - X Window System interface to the gdb debugger
  555. X *  
  556. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  557. X *  
  558. X *  Permission to use, copy, modify, and distribute this software and its
  559. X *  documentation for any purpose and without fee is hereby granted,
  560. X *  provided that the above copyright notice appear in all copies and that
  561. X *  both that copyright notice and this permission notice appear in
  562. X *  supporting documentation, and that the name of Thomson Consumer
  563. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  564. X *  to distribution of the software without specific, written prior
  565. X *  permission.  TCE makes no representations about the suitability of
  566. X *  this software for any purpose.  It is provided "as is" without express
  567. X *  or implied warranty.
  568. X *
  569. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  570. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  571. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  572. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  573. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  574. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  575. X *  SOFTWARE.
  576. X *
  577. X *  Adaptation to GDB:  Pierre Willard
  578. X *  XXGDB Created:       December, 1990
  579. X *
  580. X *****************************************************************************
  581. X
  582. /*  gdb_parser.c:
  583. X *
  584. X *    WARNING : gdb_parser.c is included by parser.c for GDB.
  585. X *
  586. X *    Parse output messages from dbx using regular expression pattern matching,
  587. X *    and take appropriate action.
  588. X *
  589. X *    parse():        Parse the dbx output and invoke the appropriate action
  590. X *            handler.
  591. X *    filter():        Modify the dbx output before it gets displayed on the
  592. X *            dialog window.
  593. X *    gdb_source_command():    Test for source command.
  594. X */
  595. X
  596. #include     <string.h>
  597. X
  598. /*--------------------------------------------------------------------------+
  599. |                                                                            |
  600. |    Function to remove all 'Reading in symbols' message                        |
  601. |    from a string.                                                            |
  602. |                                                                            |
  603. |    This function is used in parser() before matching the output            |
  604. |    because this message can happen any time.                                |
  605. |                                                                            |
  606. +--------------------------------------------------------------------------*/
  607. void filter_reading_symbols(output)
  608. char *output;
  609. {
  610. struct re_registers regs;
  611. int    r;
  612. char *p1;
  613. char *p2;
  614. X
  615. X        /* test for reading symbols message */
  616. X    
  617. X    while (re_match(output_pattern[O_READING_SYMBOLS].buf,output,strlen(output),0,®s) > 0)
  618. X        {
  619. X        /* we found a "Reading in symbols for     ...done." pattern */
  620. X        
  621. X        r = output_pattern[O_READING_SYMBOLS].reg_token[TK_MESG];
  622. X        p1=  output+regs.start[r];
  623. X        p2 = output+regs.end[r];
  624. X        
  625. X        /* remove "Reading in symbols for     ...done." */
  626. X        
  627. X        while(*(p1++) = *(p2++));
  628. X        }
  629. }
  630. X
  631. /*--------------------------------------------------------------------------+
  632. |                                                                            |
  633. | *     This routine first parses the command string.                            |
  634. | *     If the command is one of run, cont, next, step, stop at, stop in,        |
  635. | *     where, up, or down, it parses the dbx output to decide what action        |
  636. | *     to take and dispatch it to one of the handlers.                        |
  637. | *     For other commands, the appropriate handler is called.                    |
  638. | *                                                                            |
  639. | *     !!! This routine has to be re-entrant.                                    |
  640. | *                                                                            |
  641. +--------------------------------------------------------------------------*/
  642. void parse(output, command)
  643. char *output;
  644. char *command;
  645. {
  646. X    int  command_type;
  647. X    char *output_string;
  648. X
  649. X    if (debug) {
  650. X      char *temp;
  651. X      if(!command)temp="";else temp=command;
  652. X    fprintf(stderr, "parse(output = %s, command = %s)\n", output, temp);
  653. X    }
  654. X
  655. X    /* Make a local copy of `output' and use that instead */
  656. X    output_string = XtNewString(output);
  657. X    if (output) strcpy(output, "");
  658. X
  659. X    if (!command) {
  660. X    if (match(output_pattern, output_string, O_DEBUG) != -1)
  661. X        debug_handler(); 
  662. X    debug_init();
  663. X    XtFree(output_string);
  664. X    return;
  665. X    }
  666. X    
  667. X    if (!Parse)
  668. X        {
  669. X        XtFree(output_string);
  670. X        return;
  671. X        }
  672. X
  673. X    if (match(output_pattern, output_string, O_BELL) != -1)
  674. X        {
  675. X        bell(0);
  676. X        XtFree(output_string);
  677. X        return;
  678. X        }
  679. X    
  680. X    command_type = match(command_pattern, command, C_ANY);
  681. X    
  682. X    
  683. X    /* remove all "Reading in symbols for pw.c...done."  */
  684. X
  685. X    filter_reading_symbols(output_string);
  686. X            
  687. X    switch (command_type) {
  688. X          case C_EXEC: 
  689. X        case C_FINISH:
  690. X        {
  691. X        char * message;
  692. X        int signal;
  693. X        message = 0;
  694. X        if (match(output_pattern, output_string, O_RECEIVED_SIGNAL) != -1)
  695. X            {
  696. X            message = XtNewString(Token.mesg);
  697. X            signal = Token.stop;    /* signal number received */
  698. X            }
  699. X            
  700. X        /* warning : the order of the matching tests is important */
  701. X        
  702. X        if ((match(output_pattern, output_string, O_EXEC_MESS_AFTER) != -1)
  703. X            || (match(output_pattern, output_string, O_EXEC_MESS_BEFORE) != -1)
  704. X            || (match(output_pattern, output_string, O_EXEC) != -1))
  705. X            {
  706. X            exec_handler(message,signal);
  707. X            }
  708. X        else 
  709. X            {
  710. X            if (match(output_pattern, output_string, O_DONE) != -1)
  711. X                done_handler(message,signal);
  712. X            else
  713. X                bell(0);
  714. X            }
  715. X            
  716. X        if (message)
  717. X            {
  718. X            bell(0);
  719. X            XtFree(message);
  720. X            }
  721. X        }
  722. X        break;
  723. X        
  724. X    case C_UPDOWN:
  725. X        if (match(output_pattern, output_string, O_UPDOWN) != -1)
  726. X        updown_handler();
  727. X        else
  728. X        bell(0);
  729. X        break;
  730. X    case C_SEARCH:
  731. X        if (match(output_pattern, output_string, O_SEARCH) != -1)
  732. X        search_handler();
  733. X        else
  734. X        bell(0);
  735. X        break;
  736. X    case C_CLEAR:
  737. X        clear_handler(); 
  738. X        break;
  739. X    case C_LIST:
  740. X        if (match(output_pattern, output_string, O_LIST) != -1)
  741. X            list_handler();
  742. X        else
  743. X        bell(0);
  744. X        break;
  745. X        
  746. X    case C_BREAK: 
  747. X        if (match(output_pattern, output_string, O_BREAK) != -1)
  748. X            break_handler();
  749. X        else
  750. X        bell(0);
  751. X        break;
  752. X        
  753. X    case C_INFO_DIR:
  754. X        if (match(output_pattern, output_string, O_INFO_DIR) != -1)
  755. X            info_dir_handler();
  756. X        else
  757. X        bell(0);    
  758. X        break;
  759. X        
  760. X    case C_DIRECTORY:
  761. X        directory_handler(); 
  762. X        break;
  763. X        
  764. X    case C_INFO_LINE:
  765. X        if (match(output_pattern, output_string, O_INFO_LINE) != -1)
  766. X            info_line_handler();        /* command was 'info line' */
  767. X        else
  768. X        bell(0);
  769. X        break;
  770. X        
  771. X    case C_INFO_BREAK:
  772. X        info_break_handler(output_string);
  773. X        break;
  774. X
  775. X    case C_DISPLAY:
  776. X        {
  777. X        if ((!strcmp(output_string, "")) ||
  778. X            (match(output_pattern, output_string, O_DISPLAY) != -1))
  779. X            display_handler();
  780. X        else
  781. X        bell(0);
  782. X        }
  783. X        break;
  784. X        
  785. X    case C_UNDISPLAY:
  786. X        if (!strcmp(output_string, ""))
  787. X            display_handler();
  788. X        else
  789. X        bell(0);
  790. X        break;
  791. X
  792. X    case C_DISPLAY_INFO:
  793. X        {
  794. X        if ((!strcmp(output_string, "")) ||
  795. X            (match(output_pattern, output_string, O_DISPLAY_INFO) != -1))
  796. X            display_info_handler();
  797. X        else
  798. X        bell(0);
  799. X        }
  800. X        break;
  801. X        
  802. X    case C_CD:
  803. X        if (match(output_pattern, output_string, O_CD) != -1)
  804. X            cd_handler(Token.mesg); 
  805. X        else
  806. X        bell(0);
  807. X        break;
  808. X        
  809. X    case C_PWD:
  810. X        if (match(output_pattern, output_string, O_PWD) != -1)
  811. X            pwd_handler(Token.mesg);
  812. X        else
  813. X        bell(0);
  814. X        break;
  815. X
  816. X    case C_FRAME_CURR:
  817. X        if (match(output_pattern, output_string, O_FRAME_CURR) != -1)
  818. X        frame_curr_handler();
  819. X        else
  820. X        bell(0);
  821. X        break;
  822. X
  823. X    case C_PRINT:
  824. X        match(output_pattern, output_string, O_PRINT);
  825. X        break;
  826. X    case C_HELP:
  827. X        if(match(output_pattern, output_string, O_HELP) != -1)
  828. X          help_handler(command, output_string);
  829. X        break;
  830. X    case C_SYMBOL_FILE:
  831. X        debug_handler(); 
  832. X        break;
  833. X
  834. X    case C_SOURCE:    /* WE SHOULD NEVER ARRIVE HERE */
  835. X        break;
  836. X
  837. X    case C_EXEC_FILE:
  838. X        break;
  839. X        
  840. X    default:
  841. X        break;
  842. X    }
  843. X    XtFree(output_string);
  844. }
  845. X
  846. /*--------------------------------------------------------------------------+
  847. |                                                                            |
  848. |    Function to filter all the display information in a string                |
  849. |                                                                            |
  850. |    input : string pointer.                                                    |
  851. |                                                                            |
  852. |    output : none.                                                            |
  853. |                                                                            |
  854. |    See O_EXEC_DISPLAY in gdb_regex.h for the display pattern.                |
  855. |                                                                            |
  856. |    Take care when GDB send some message after '\032\032...\n'                |
  857. |    which is not a display line.                                            |
  858. |                                                                            |
  859. | (gdb) finish                                                                |
  860. | Run till exit from #0     foo (n=1) (pw.c line 9)                            |
  861. | main () (pw.c line 41)                                                    |
  862. | /usr1/gnu_sun4/xxgdb/pw.c:41:590:beg:0x232c                                |
  863. | 1: i = 1                                                                    |
  864. | Value returned is $1 = 1                                                    |
  865. | (gdb)                                                                        |
  866. |                                                                            |
  867. +--------------------------------------------------------------------------*/
  868. void filter_display_info(output)
  869. char *output;
  870. {
  871. struct re_registers regs;
  872. int    r;
  873. char *p;
  874. char *p1;
  875. char *p2;
  876. char *cp_output;
  877. int begin_struct;
  878. X
  879. X    p = cp_output = XtNewString(output);
  880. X
  881. X    p1 = strstr(p,"\032\032");        /* find beginning of special gdb line */
  882. X    
  883. X    if ((p1 == 0) || ((p2 = strchr(p1+1,'\n')) == 0))
  884. X        {
  885. X        AppendDialogText(p);        /* something wrong here */
  886. X        XtFree(cp_output);
  887. X        return;
  888. X        }
  889. X        
  890. X    *p1 = 0;
  891. X    AppendDialogText(p);            /* print everything before that line */
  892. X    p = p2 + 1;                        /* end of that line + skip \n */
  893. X
  894. X    /* test for beginning of a display */
  895. X    
  896. X    while (re_match(output_pattern[O_EXEC_DISPLAY].buf,p,strlen(p),0,®s) > 0)
  897. X        {
  898. X        /* we found a "X:....\n" pattern */
  899. X        
  900. X        r = output_pattern[O_EXEC_DISPLAY].reg_token[TK_DISP];
  901. X        p1=  p+regs.start[r];
  902. X        p2 = p+regs.end[r];
  903. X                    
  904. X        /* count number of { and } : if not equal, the next lines are part of this display */
  905. X        begin_struct = 0;
  906. X        while (p1 < p2)
  907. X            {
  908. X            switch(*(p1++))
  909. X                {
  910. X                case '{':
  911. X                    begin_struct++;
  912. X                    break;
  913. X                case '}':
  914. X                    begin_struct--;
  915. X                    break;
  916. X                }
  917. X            }
  918. X            
  919. X        p1=p+regs.start[r];
  920. X        *p1 = 0;
  921. X        if (p != p1)
  922. X            AppendDialogText(p);    /* print what is before display */
  923. X        p = p2;                        /* skip display text */
  924. X                    
  925. X        if (begin_struct)
  926. X            {
  927. X            /* try to find end of display structure */
  928. X            
  929. X            if (p1 = strstr(p,"\n}\n"))
  930. X                p = p1 + strlen("\n}\n");
  931. X            }
  932. X        }
  933. X        
  934. X    AppendDialogText(p);        /* print what is after display */
  935. X    XtFree(cp_output);
  936. }
  937. X
  938. /*--------------------------------------------------------------------------+
  939. |                                                                            |
  940. | *     This function edits the dbx output so that unnecessary information is    |
  941. | *     not displayed on the dialog window.                                    |
  942. | *     It filters away the some output returned by the execution commands;    |
  943. | *     output from the search commands, and the display command.                |
  944. | *     On Sun dbx, it also filters away part of the output returned by the    |
  945. | *     up and down commands.                                                    |
  946. | *                                                                            |
  947. +--------------------------------------------------------------------------*/
  948. void filter(string, output, command)
  949. char *string, *output, *command;
  950. {
  951. X    struct re_registers regs;
  952. X    char         *p;
  953. X    char         *p2;
  954. X    char         *p3;
  955. X    int            r;
  956. X    static Boolean    deleteRest = False;
  957. X    int            command_type = -1;
  958. X    static unsigned int already_taken_care;    
  959. X
  960. X    if (output == NULL || !strcmp(output, "")) 
  961. X    return;
  962. X
  963. /* for GDB, the only things we want to filter are:
  964. X
  965. X    - the line displayed because of the -fullname  option :
  966. X    "\032\032/usr1/gnu_sun4/xdbx/pw.c:6:40:beg:0x22b0\n",
  967. X    
  968. X    - the displayed info which goes into the display window,
  969. X    
  970. X    - list and search outputs
  971. X
  972. */
  973. X    if (!string)
  974. X        string = "";
  975. X        
  976. X    if (command)
  977. X        command_type = match(command_pattern, command, C_ANY);
  978. X        
  979. X    if ((command_type == C_EXEC)||(command_type == C_FINISH))
  980. X        {
  981. X        if ((re_match(output_pattern[O_EXEC_MESS_AFTER].buf,string,strlen(string),0,®s) > 0)
  982. X            || (re_match(output_pattern[O_EXEC_MESS_BEFORE].buf,string,strlen(string),0,®s) > 0)
  983. X            || (re_match(output_pattern[O_EXEC].buf,string,strlen(string),0,®s) > 0))
  984. X            {
  985. X            /* remember what was the output length was output was matched */
  986. X            already_taken_care = strlen(output) - strlen(string);
  987. X            
  988. X            /* Remove display messages from output and print what is no a display */
  989. X            
  990. X            if (Prompt)
  991. X                filter_display_info(output + already_taken_care);    
  992. X            else
  993. X                deleteRest = True;
  994. X                
  995. X            return;
  996. X            }
  997. X        else
  998. X            {
  999. X            if (deleteRest)        
  1000. X                {
  1001. X                /* Remove display messages from output and print what is no a display */
  1002. X                if (Prompt)
  1003. X                    {
  1004. X                    filter_display_info(output + already_taken_care);    
  1005. X                    deleteRest = False;
  1006. X                    }
  1007. X                return;
  1008. X                }
  1009. X            }
  1010. X        }
  1011. X        
  1012. X    /* filter any line starting with \032\032 */
  1013. X    
  1014. X    p = strchr(string,'\032');
  1015. X    if (p && (*(p+1) == '\032') && (p == string || *(p-1) == '\n') && (p2 = strchr(p,'\n')))
  1016. X        {
  1017. X        while (*(p++) = *(++p2));
  1018. X        }
  1019. X        
  1020. X    if ((command_type == C_EXEC)||(command_type == C_FINISH))
  1021. X        {
  1022. X        AppendDialogText(string);
  1023. X        return;
  1024. X        }
  1025. X        
  1026. X    if (Prompt)
  1027. X        {
  1028. X        char *s;
  1029. X
  1030. X        s = XtNewString(output);
  1031. X        switch (command_type)
  1032. X            {
  1033. X            case C_DISPLAY:
  1034. X                if (match(output_pattern, s, O_DISPLAY) != -1)
  1035. X                strcpy(s, "");
  1036. X                break;
  1037. X            case C_SEARCH:
  1038. X                if (match(output_pattern, s, O_SEARCH) != -1)
  1039. X                strcpy(s, "");
  1040. X                break;
  1041. X            case C_LIST:
  1042. X                if (match(output_pattern, s, O_LIST) != -1)
  1043. X                strcpy(s, "");
  1044. X                break;
  1045. X            case C_PRINT:
  1046. X                if(match(output_pattern, s, O_PRINT) == -1)
  1047. X                strcpy(s, "");
  1048. X                break;
  1049. X                
  1050. X            default:
  1051. X                XtFree(s);
  1052. X                s = XtNewString(string);        /* append 'string' only */
  1053. X                break;
  1054. X            }
  1055. X        AppendDialogText(s);
  1056. X        XtFree(s);
  1057. X        }
  1058. X    else
  1059. X        {
  1060. X        switch (command_type)
  1061. X            {
  1062. X            case C_DISPLAY:
  1063. X            case C_SEARCH:
  1064. X            case C_LIST:
  1065. X            case C_PRINT:
  1066. X                break;
  1067. X            default:
  1068. X                AppendDialogText(string);
  1069. X                break;
  1070. X            }
  1071. X        }
  1072. }
  1073. X
  1074. X
  1075. /*--------------------------------------------------------------------------+
  1076. |                                                                            |
  1077. |    Function to filter 'source' command                                        |
  1078. |                                                                            |
  1079. |    input : command (from .gdbinit or source command or keyboard),            |
  1080. |            echo is TRUE if source command must be echoed.                    |
  1081. |                                                                            |
  1082. |    output : TRUE if source command was recognized                            |
  1083. |                                                                            |
  1084. |    In case source command is recognized, it is executed here.                |
  1085. |                                                                            |
  1086. +--------------------------------------------------------------------------*/
  1087. int gdb_source_command(command,echo)
  1088. char *command;
  1089. int echo;
  1090. {
  1091. X    if (command && (match(command_pattern, command, C_SOURCE) != -1))
  1092. X        {
  1093. X        if (echo)
  1094. X            AppendDialogText(command);
  1095. X        source_handler();    
  1096. X        send_command(" \n");    /* ask GDB to redisplay its prompt */
  1097. X        return TRUE;
  1098. X        }
  1099. X        
  1100. X    return FALSE;
  1101. }
  1102. X
  1103. X
  1104. /*--------------------------------------------------------------------------+
  1105. |                                                                            |
  1106. |    Function to filter 'define' & 'document' commands                        |
  1107. |                                                                            |
  1108. |    input : command (from .gdbinit or source command),                        |
  1109. |            fp = file pointer.                                                |
  1110. |                                                                            |
  1111. |    output : TRUE if define or document command was recognized                |
  1112. |                                                                            |
  1113. |    In case the command is recognized, it is executed here.                    |
  1114. |                                                                            |
  1115. +--------------------------------------------------------------------------*/
  1116. int gdb_define_command(command,fp)
  1117. char *command;
  1118. FILE *fp;
  1119. {
  1120. char s[LINESIZ];
  1121. int error_cmd;
  1122. int end_found;
  1123. X
  1124. X    if ((command && (match(command_pattern, command, C_DEFINE) != -1))
  1125. X        || (command && (match(command_pattern, command, C_DOCUMENT) != -1)))
  1126. X        {
  1127. X        AppendDialogText(command);
  1128. X        send_command(command);
  1129. X        
  1130. /*
  1131. X                gdb could ask :
  1132. X            
  1133. X                    "Redefine command \"%s\"? "
  1134. X                    "Really redefine built-in command \"%s\"? "
  1135. X                    
  1136. X                gdb could display 
  1137. X                
  1138. X                    "Type commands for definition of \"%s\".\n"
  1139. X                    "End with a line saying just \"end\"
  1140. X                
  1141. X                or
  1142. X                    "Type documentation for \"%s\".\n"
  1143. X                    "End with a line saying just \"end\".\n"
  1144. X                    
  1145. X                or
  1146. X                     "Command \"%s\" is built-in."
  1147. */
  1148. X    
  1149. X        error_cmd = FALSE;
  1150. X                
  1151. X        /* read message from gdb */
  1152. X        
  1153. X        while (1)
  1154. X            if (fgets(s, LINESIZ, dbxfp))
  1155. X                {
  1156. X                if (debug)
  1157. X                    fprintf(stderr, "=>%s", s);
  1158. X                
  1159. X                if (strstr(s," is built-in."))    /* error for document of built-in command */
  1160. X                    {
  1161. X                    AppendDialogText(s);
  1162. X                    error_cmd = TRUE;
  1163. X                    bell(0);
  1164. X                    break;
  1165. X                    }
  1166. X            
  1167. X                while (strstr(s,"Redefine command ")
  1168. X                 || strstr(s,"Really redefine built-in command ")) {
  1169. X                    write_dbx ("y\n");     /* answer to question if any */
  1170. X                    fgets(s, LINESIZ, dbxfp);
  1171. X                }
  1172. X                if (!strcmp(s,"End with a line saying just \"end\".\n"))
  1173. X                        break;
  1174. X                }
  1175. X        
  1176. X        /* write command definition */
  1177. X        
  1178. X        end_found = FALSE;
  1179. X        
  1180. X        while (fgets (s, LINESIZ, fp))
  1181. X            {
  1182. X            if (!error_cmd)
  1183. X                {
  1184. X                AppendDialogText(s);
  1185. X                write_dbx (s);
  1186. X                }
  1187. X            
  1188. X            if (match(command_pattern, s, C_END) != -1)
  1189. X                {
  1190. X                end_found = TRUE;
  1191. X                break;
  1192. X                }
  1193. X            }
  1194. X            
  1195. X        if ((!error_cmd) && (!end_found))
  1196. X            {
  1197. X            AppendDialogText("Error : missing \"end\" in file.\n");
  1198. X            bell(0);
  1199. X            write_dbx ("end\n");
  1200. X            }
  1201. X            
  1202. X        return TRUE;
  1203. X        }
  1204. X        
  1205. X    return FALSE;
  1206. }
  1207. X
  1208. X
  1209. SHAR_EOF
  1210. chmod 0664 mxgdb/gdb_parser.c ||
  1211. echo 'restore of mxgdb/gdb_parser.c failed'
  1212. Wc_c="`wc -c < 'mxgdb/gdb_parser.c'`"
  1213. test 18249 -eq "$Wc_c" ||
  1214.     echo 'mxgdb/gdb_parser.c: original size 18249, current size' "$Wc_c"
  1215. rm -f _shar_wnt_.tmp
  1216. fi
  1217. # ============= mxgdb/gdb_regex.h ==============
  1218. if test -f 'mxgdb/gdb_regex.h' -a X"$1" != X"-c"; then
  1219.     echo 'x - skipping mxgdb/gdb_regex.h (File already exists)'
  1220.     rm -f _shar_wnt_.tmp
  1221. else
  1222. > _shar_wnt_.tmp
  1223. echo 'x - extracting mxgdb/gdb_regex.h (Text)'
  1224. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/gdb_regex.h' &&
  1225. /* $Id: gdb_regex.h,v 1.2 1991/06/28 20:32:32 jtsillas Exp $ */
  1226. X
  1227. /*****************************************************************************
  1228. X *
  1229. X *  xdbx - X Window System interface to the dbx debugger
  1230. X *
  1231. X *  Copyright 1989 The University of Texas at Austin
  1232. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  1233. X *
  1234. X *  Permission to use, copy, modify, and distribute this software and its
  1235. X *  documentation for any purpose and without fee is hereby granted,
  1236. X *  provided that the above copyright notice appear in all copies and that
  1237. X *  both that copyright notice and this permission notice appear in
  1238. X *  supporting documentation, and that the name of The University of Texas
  1239. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  1240. X *  used in advertising or publicity pertaining to distribution of
  1241. X *  the software without specific, written prior permission.  The
  1242. X *  University of Texas and MCC makes no representations about the 
  1243. X *  suitability of this software for any purpose.  It is provided "as is" 
  1244. X *  without express or implied warranty.
  1245. X *
  1246. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1247. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1248. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  1249. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  1250. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  1251. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  1252. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1253. X *
  1254. X *  Author:      Po Cheung
  1255. X *  Created:       March 10, 1989
  1256. X *
  1257. X *****************************************************************************
  1258. X * 
  1259. X *  xxgdb - X Window System interface to the gdb debugger
  1260. X *  
  1261. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  1262. X *  
  1263. X *  Permission to use, copy, modify, and distribute this software and its
  1264. X *  documentation for any purpose and without fee is hereby granted,
  1265. X *  provided that the above copyright notice appear in all copies and that
  1266. X *  both that copyright notice and this permission notice appear in
  1267. X *  supporting documentation, and that the name of Thomson Consumer
  1268. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  1269. X *  to distribution of the software without specific, written prior
  1270. X *  permission.  TCE makes no representations about the suitability of
  1271. X *  this software for any purpose.  It is provided "as is" without express
  1272. X *  or implied warranty.
  1273. X *
  1274. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1275. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  1276. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  1277. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1278. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1279. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1280. X *  SOFTWARE.
  1281. X *
  1282. X *  Adaptation to GDB:  Pierre Willard
  1283. X *  XXGDB Created:       December, 1990
  1284. X *
  1285. X *****************************************************************************/
  1286. X
  1287. /*  
  1288. X *  gdb_regex.h:
  1289. X *
  1290. X *  Regular expression pattern matching for GNU gdb.
  1291. X *  
  1292. X *  The reg_token array indicates the register no. for each token type.
  1293. X *      reg_token[0] : message
  1294. X *      reg_token[1] : stop number
  1295. X *      reg_token[2] : function name
  1296. X *      reg_token[3] : line number
  1297. X *      reg_token[4] : file name
  1298. X *      reg_token[5] : display command output
  1299. X */
  1300. X
  1301. #define    TK_MESG     0
  1302. #define TK_STOP        1
  1303. #define TK_FUNC     2
  1304. #define TK_LINE     3
  1305. #define TK_FILE     4
  1306. #define TK_DISP     5
  1307. X
  1308. #define    O_EXEC_MESS_AFTER    0
  1309. #define    O_EXEC_MESS_BEFORE    1
  1310. #define    O_EXEC                2
  1311. #define O_DONE                3
  1312. #define O_BREAK             4 /* Instead of O_STOPAT & O_STOPIN */
  1313. SHAR_EOF
  1314. true || echo 'restore of mxgdb/gdb_regex.h failed'
  1315. fi
  1316. echo 'End of  part 5'
  1317. echo 'File mxgdb/gdb_regex.h is continued in part 6'
  1318. echo 6 > _shar_seq_.tmp
  1319. exit 0
  1320. --
  1321.  == James Tsillas                    Bull HN Information Systems Inc. ==
  1322.  == (508) 294-2937                   300 Concord Road   826A          ==
  1323.  == jtsillas@bubba.ma30.bull.com     Billerica, MA 01821              ==
  1324.  ==                                                                   ==
  1325.  == The opinions expressed above are solely my own and do not reflect ==
  1326.  == those of my employer.                                             ==
  1327.             -== no solicitations please ==-
  1328.