home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 4 / 4007 < prev    next >
Encoding:
Text File  |  1991-09-09  |  39.9 KB  |  1,138 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 5/10)
  5. Organization: Bull HN, Worldwide Information Systems, Billerica, Mass., USA
  6. Distribution: alt
  7. Date: 6 Sep 91 14:25:36
  8. Message-ID: <JTSILLAS.91Sep6142536@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.05 (part 5 of a multipart archive)
  14. # do not concatenate these parts, unpack them in order with /bin/sh
  15. # file mxgdb/gdb_parser.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" != 5; 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/gdb_parser.c'
  31. else
  32. echo 'x - continuing file mxgdb/gdb_parser.c'
  33. sed 's/^X//' << 'SHAR_EOF' >> 'mxgdb/gdb_parser.c' &&
  34. X        
  35. X        while (1)
  36. X            if (fgets(s, LINESIZ, dbxfp))
  37. X                {
  38. X                if (debug)
  39. X                    fprintf(stderr, "=>%s", s);
  40. X                
  41. X                if (strstr(s," is built-in."))    /* error for document of built-in command */
  42. X                    {
  43. X                    AppendDialogText(s);
  44. X                    error_cmd = TRUE;
  45. X                    bell(0);
  46. X                    break;
  47. X                    }
  48. X            
  49. X                while (strstr(s,"Redefine command ")
  50. X                 || strstr(s,"Really redefine built-in command ")) {
  51. X                    write_dbx ("y\n");     /* answer to question if any */
  52. X                    fgets(s, LINESIZ, dbxfp);
  53. X                }
  54. X                if (!strcmp(s,"End with a line saying just \"end\".\n"))
  55. X                        break;
  56. X                }
  57. X        
  58. X        /* write command definition */
  59. X        
  60. X        end_found = FALSE;
  61. X        
  62. X        while (fgets (s, LINESIZ, fp))
  63. X            {
  64. X            if (!error_cmd)
  65. X                {
  66. X                AppendDialogText(s);
  67. X                write_dbx (s);
  68. X                }
  69. X            
  70. X            if (match(command_pattern, s, C_END) != -1)
  71. X                {
  72. X                end_found = TRUE;
  73. X                break;
  74. X                }
  75. X            }
  76. X            
  77. X        if ((!error_cmd) && (!end_found))
  78. X            {
  79. X            AppendDialogText("Error : missing \"end\" in file.\n");
  80. X            bell(0);
  81. X            write_dbx ("end\n");
  82. X            }
  83. X            
  84. X        return TRUE;
  85. X        }
  86. X        
  87. X    return FALSE;
  88. }
  89. X
  90. X
  91. SHAR_EOF
  92. echo 'File mxgdb/gdb_parser.c is complete' &&
  93. chmod 0644 mxgdb/gdb_parser.c ||
  94. echo 'restore of mxgdb/gdb_parser.c failed'
  95. Wc_c="`wc -c < 'mxgdb/gdb_parser.c'`"
  96. test 18249 -eq "$Wc_c" ||
  97.     echo 'mxgdb/gdb_parser.c: original size 18249, current size' "$Wc_c"
  98. rm -f _shar_wnt_.tmp
  99. fi
  100. # ============= mxgdb/gdb_regex.h ==============
  101. if test -f 'mxgdb/gdb_regex.h' -a X"$1" != X"-c"; then
  102.     echo 'x - skipping mxgdb/gdb_regex.h (File already exists)'
  103.     rm -f _shar_wnt_.tmp
  104. else
  105. > _shar_wnt_.tmp
  106. echo 'x - extracting mxgdb/gdb_regex.h (Text)'
  107. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/gdb_regex.h' &&
  108. /* $Id: gdb_regex.h,v 1.2 1991/06/28 20:32:32 jtsillas Exp $ */
  109. X
  110. /*****************************************************************************
  111. X *
  112. X *  xdbx - X Window System interface to the dbx debugger
  113. X *
  114. X *  Copyright 1989 The University of Texas at Austin
  115. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  116. X *
  117. X *  Permission to use, copy, modify, and distribute this software and its
  118. X *  documentation for any purpose and without fee is hereby granted,
  119. X *  provided that the above copyright notice appear in all copies and that
  120. X *  both that copyright notice and this permission notice appear in
  121. X *  supporting documentation, and that the name of The University of Texas
  122. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  123. X *  used in advertising or publicity pertaining to distribution of
  124. X *  the software without specific, written prior permission.  The
  125. X *  University of Texas and MCC makes no representations about the 
  126. X *  suitability of this software for any purpose.  It is provided "as is" 
  127. X *  without express or implied warranty.
  128. X *
  129. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  130. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  131. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  132. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  133. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  134. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  135. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  136. X *
  137. X *  Author:      Po Cheung
  138. X *  Created:       March 10, 1989
  139. X *
  140. X *****************************************************************************
  141. X * 
  142. X *  xxgdb - X Window System interface to the gdb debugger
  143. X *  
  144. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  145. X *  
  146. X *  Permission to use, copy, modify, and distribute this software and its
  147. X *  documentation for any purpose and without fee is hereby granted,
  148. X *  provided that the above copyright notice appear in all copies and that
  149. X *  both that copyright notice and this permission notice appear in
  150. X *  supporting documentation, and that the name of Thomson Consumer
  151. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  152. X *  to distribution of the software without specific, written prior
  153. X *  permission.  TCE makes no representations about the suitability of
  154. X *  this software for any purpose.  It is provided "as is" without express
  155. X *  or implied warranty.
  156. X *
  157. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  158. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  159. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  160. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  161. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  162. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  163. X *  SOFTWARE.
  164. X *
  165. X *  Adaptation to GDB:  Pierre Willard
  166. X *  XXGDB Created:       December, 1990
  167. X *
  168. X *****************************************************************************/
  169. X
  170. /*  
  171. X *  gdb_regex.h:
  172. X *
  173. X *  Regular expression pattern matching for GNU gdb.
  174. X *  
  175. X *  The reg_token array indicates the register no. for each token type.
  176. X *      reg_token[0] : message
  177. X *      reg_token[1] : stop number
  178. X *      reg_token[2] : function name
  179. X *      reg_token[3] : line number
  180. X *      reg_token[4] : file name
  181. X *      reg_token[5] : display command output
  182. X */
  183. X
  184. #define    TK_MESG     0
  185. #define TK_STOP        1
  186. #define TK_FUNC     2
  187. #define TK_LINE     3
  188. #define TK_FILE     4
  189. #define TK_DISP     5
  190. X
  191. #define    O_EXEC_MESS_AFTER    0
  192. #define    O_EXEC_MESS_BEFORE    1
  193. #define    O_EXEC                2
  194. #define O_DONE                3
  195. #define O_BREAK             4 /* Instead of O_STOPAT & O_STOPIN */
  196. #define O_INFO_DIR                  5 /* NEW for GDB */
  197. #define O_FRAME_CURR        6      /* O_FRAME_CURR = O_UPDOWN */
  198. #define O_UPDOWN             6
  199. #define O_BELL                7
  200. #define O_SEARCH            8
  201. #define O_INFO_LINE            9    /* Instead of O_FILE */
  202. #define O_PRINT                10
  203. #define O_DEBUG                11
  204. #define O_DIRECTORY            12            
  205. #define O_LIST                13 /* for dbx, O_LIST = O_SEARCH */
  206. #define O_DISPLAY            14
  207. #define O_DISPLAY_INFO        15
  208. #define O_PWD                16
  209. #define O_CD                16    /* O_PWD = O_CD */
  210. #define O_RECEIVED_SIGNAL    17    /* test program received signal */
  211. #define O_EXEC_DISPLAY        18    /* special for filter_display_info  */
  212. #define O_READING_SYMBOLS    19  /* special for filter_reading_symbols */
  213. #define O_HELP                  20
  214. X
  215. #define    C_ANY            -1
  216. #define C_EXEC            0
  217. #define C_BREAK            1    /* Instead of C_STOPAT & C_STOPIN */
  218. #define C_INFO_DIR        2    /* NEW for GDB */
  219. #define C_FRAME_CURR            3
  220. #define C_UPDOWN        4
  221. #define C_CLEAR         5
  222. #define C_FINISH        6            /* Instead of C_FUNC */
  223. #define C_INFO_LINE        7            /* Instead of C_FILE */
  224. #define C_SYMBOL_FILE            8
  225. #define C_CD            9
  226. #define C_DIRECTORY        10            /* Instead of C_USE */
  227. #define C_PWD            11
  228. #define C_LIST            12
  229. #define C_SEARCH        13
  230. #define C_DISPLAY_INFO            14    /* must be BEFORE C_DISPLAY ! */
  231. #define C_DISPLAY        15
  232. #define C_UNDISPLAY        16
  233. #define C_PRINT            17
  234. #define C_INFO_BREAK            18
  235. #define C_SOURCE        19
  236. #define C_EXEC_FILE        20
  237. #define C_CORE_FILE             21
  238. #define C_DEFINE                22
  239. #define C_DOCUMENT              23
  240. #define C_END                   24
  241. #define C_HELP                  25
  242. X
  243. /*--------------------------------------------------------------------------+
  244. |                                    |
  245. |                                DBX    |
  246. |                                                                            |
  247. | Reading symbolic information...                                            |
  248. | Read 46 symbols                                                            |
  249. | (dbx)                                                                        |
  250. | (dbx)                                                                        |
  251. | stopped in main at line 5 in file "pw.c"                                    |
  252. |     5             for (i=0; i<100; i++)                                        |
  253. | (dbx) use                                                                    |
  254. | /usr1/gnu_sun4/xdbx/                                                        |
  255. | (dbx) file                                                                |
  256. | pw.c                                                                        |
  257. | (dbx) file                                                                |
  258. | No current source file                                                    |
  259. |                                                                            |
  260. +--------------------------------------------------------------------------*/
  261. /*--------------------------------------------------------------------------+
  262. |                                                                            |
  263. |                                GDB                                            |
  264. |                                                                            |
  265. | Reading symbol data from /usr1/gnu_sun4/xdbx/pw...done.                    |
  266. | Type "help" for a list of commands.                                        |
  267. | (gdb)                                                                        |
  268. | (gdb)                                                                        |
  269. | Bpt 1, main () (pw.c line 5)                                                |
  270. | 5                  for (i=0; i<100; i++)                                        |
  271. | (gdb) info directories                                                    |
  272. | Source directories searched: /usr1/gnu_sun4/xdbx:/usr1/toto                |
  273. | (gdb) info line                                                            |
  274. | Line 10 of "pw.c" starts at pc 0x22dc and ends at 0x22e4.                    |
  275. | (gdb) info line                                                            |
  276. | No source file specified.                                                    |
  277. |                                                                            |
  278. +--------------------------------------------------------------------------*/
  279. /*--------------------------------------------------------------------------+
  280. |                                                                            |
  281. |                                GDB -fullname                                |
  282. |                                                                            |
  283. |                                                                            |
  284. |    We use option -fullname (see dbxoptions() in xdbx.c).                    |
  285. |                                                                            |
  286. | GDB prints (see source.c of gdb):                                            |
  287. |                                                                            |
  288. |        "\032\032%s:%d:%d:%s:0x%x\n", s->fullname,                            |
  289. |        line, s->line_charpos[line - 1],                                    |
  290. |        mid_statement ? "middle" : "beg",                                    |
  291. |        get_frame_pc (get_current_frame()));                                |
  292. |                                                                            |
  293. | (gdb) break main                                                            |
  294. | Reading in symbols for pw.c...done.                                        |
  295. | Breakpoint 1 at 0x229c: file pw.c, line 5.                                |
  296. | (gdb) run                                                                    |
  297. | Starting program: /usr1/gnu_sun4/xdbx/pw                                    |
  298. |                                                                            |
  299. | Bpt 1, main () (pw.c line 5)                                                |
  300. | /usr1/gnu_sun4/xdbx/pw.c:5:17:beg:0x229c                                    |
  301. | (gdb) step                                                                |
  302. | /usr1/gnu_sun4/xdbx/pw.c:6:40:beg:0x22b0                                    |
  303. | (gdb)                                                                        |
  304. |                                                                            |
  305. | (gdb) info directories                                                    |
  306. | Source directories searched: /usr1/gnu_sun4/xdbx                            |
  307. | (gdb) info line                                                            |
  308. | Line 10 of "pw.c" starts at pc 0x22dc and ends at 0x22e4.                    |
  309. | (gdb) info line                                                            |
  310. | No source file specified.                                                    |
  311. | (gdb) info line                                                            |
  312. | Line number 34 is out of range for "bug1.c".                                |
  313. |                                                                            |
  314. | (gdb) display i                                                            |
  315. | 3: i = 0                                                                    |
  316. | (gdb) display                                                                |
  317. | 4: i + 1 = 1                                                                |
  318. | 3: i = 0                                                                    |
  319. | (gdb) undisplay 2                                                            |
  320. | (gdb) display                                                                |
  321. | (gdb)                                                                     |
  322. |                                                                            |
  323. | (gdb) up                                                                    |
  324. | #2  0x2314 in main () (pw.c line 35)                                        |
  325. | /usr1/gnu_sun4/xdbx/pw.c:35:158:beg:0x2360                                |
  326. | (gdb) up                                                                    |
  327. | Initial frame selected; you cannot go up.                                    |
  328. | (gdb)                                                                        |
  329. |                                                                            |
  330. | (gdb) down                                                                |
  331. | #0  glop (number=1) (pw2.c line 5)                                        |
  332. | /usr1/gnu_sun4/xdbx/pw2.c:5:33:beg:0x2360                                    |
  333. | (gdb) down                                                                |
  334. | Bottom (i.e., innermost) frame selected; you cannot go down.                |
  335. | (gdb)                                                                        |
  336. |                                                                            |
  337. | (gdb) pwd                                                                    |
  338. | Working directory /usr1/gnu_sun4/xdbx.                                    |
  339. | (gdb) cd ..                                                                |
  340. | Working directory /usr1/gnu_sun4.                                            |
  341. | (gdb) cd xdbx                                                                |
  342. | Working directory /usr1/gnu_sun4/xdbx.                                    |
  343. | (gdb) cd toto                                                                |
  344. | toto: No such file or directory.                                            |
  345. | (gdb)                                                                        |
  346. |                                                                            |
  347. | Program exited with code 01.                                                |
  348. | (gdb)                                                                        |
  349. |                                                                            |
  350. +--------------------------------------------------------------------------*/
  351. /*
  352. X
  353. X        .        --> any character but '\n'
  354. X        *        --> any character 0 to n times
  355. X        +        --> any character 1 to n times
  356. X        ?        --> any character 0 or 1 time
  357. X        ^        --> begin of line or NOT following character
  358. X        $        --> end of line or '$'
  359. X        \\w        --> character '0..9a..zA...Z'
  360. X        \\W        --> character NOT '0..9a..zA...Z'
  361. X        \\<        --> word begin (word is composed of 0..9a..zA...Z)
  362. X        \\>        --> word end (word is composed of 0..9a..zA...Z)
  363. X        \\b        --> word bound
  364. X        \\B        --> not word bound
  365. X        \\|        --> means OR
  366. X        \\`        --> begin buffer
  367. X        \\\'    --> end buffer
  368. X        
  369. X        
  370. >>    WARNING : be carefull with \\| (OR) : the re_match() function
  371. >>    will NOT correctly update the string for a pattern which is
  372. >>    optional !
  373. >>    --> The number SHOULD NOT point to a patterm which is optional ! 
  374. X
  375. */
  376. X
  377. X    /* (PW)5DEC90: I have a problem if we say \\(Bpt.*\n\\)? in exec pattern.
  378. X        That is why I have two cases : with or without Bpt...
  379. X        Note that 'exec without Message' includes 'exec with Message'.
  380. X        We display 'Bpt...' in the message window. */
  381. X        
  382. X    /* (PW)14JAN91 (v1.01) : use 
  383. X           \\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)
  384. X    instead of
  385. X        \\(\\([0-9]+:.*\n\\)*\\)
  386. X    for display pattern.
  387. X    */
  388. X    
  389. X
  390. static PatternRec output_pattern[] = {
  391. X    /* exec with Message after */
  392. X    {"\\(.*\n\\)*\032\032\\([^ ]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ ]+\\):0x.+\n\\([ ]*[^0-9].*\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
  393. X     NULL,
  394. X     {6, -1, -1, 3, 2, 7}
  395. X    },
  396. X    /* exec with Message before */
  397. X    {"\\(.*\n\\)*\\([ ]*[^ ].*\n\\)\032\032\\([^ ]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ ]+\\):0x.+\n\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
  398. X     NULL,
  399. X     {2, -1, -1, 4, 3, 7}    
  400. X    },
  401. X    /* exec without Message */
  402. X    {"\\(.*\n\\)*\032\032\\(\\([^ ]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ ]+\\):0x.+\n\\)\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
  403. X     NULL,
  404. X     {2, -1, -1, 4, 3, 7}
  405. X    },
  406. X    /* done */
  407. X    {"\\(.*\n\\)*\n\\(Program terminated with signal \\|Program exited with code 0\\|Program exited normally\\).*\n\\(.*\n\\)*",
  408. X     NULL,
  409. X     {-1, -1, -1, -1, -1, -1}
  410. X    },
  411. X    /* break */
  412. X    {"\\(.*\n\\)*Breakpoint \\([0-9]+\\) at [^ ]+: file \\([^ ]+\\), line \\([0-9]+\\).\n",
  413. X     NULL,
  414. X     {-1, 2, -1, 4, 3, -1}
  415. X    },
  416. X    /* info directories */
  417. X    {"Source directories searched:[ ]*\\([^ ]+\\)[ ]*\n",
  418. X     NULL,
  419. X     { -1, -1, -1, -1, 1, -1}
  420. X    },
  421. X    /* up, down */
  422. X    {"\\(.*\n\\)*\\(#[0-9]+[ ]+\\(0x[^ ]+[ ]+in[ ]+\\)?\\([^ ]+\\).*\n\\)\\(Source file is more recent than executable.\n\\)?\032\032\\([^ ]+\\):\\([0-9]+\\):\\([0-9]+\\):\\([^ ]+\\):0x.+\n",
  423. X     NULL,
  424. X     {2, -1, 4, 7, 6, -1}    
  425. X    },
  426. X    /* bell */
  427. X    {"\\(Undefined command: .*\n\\|Already at the \\(top\\|bottom\\) call level\n\\|\
  428. No active stack frames\n\\|no program to run\n\\|no process to run\n\\|\
  429. program is not active\n\\|can't continue execution\n\\|\
  430. ..*\ncan't write to process.*\n\\|\
  431. \\(Top\\|End\\)-of-file; did not find search string:.*\n\\)",
  432. X     NULL,
  433. X     {-1, -1, -1, -1, -1}
  434. X    },
  435. X    /* search */
  436. X    {"\\([0-9]+\\).*\n",
  437. X     NULL,
  438. X     {-1, -1, -1, 1, -1, -1}
  439. X    },
  440. X    /* info line */
  441. X    {"\\(Line \\(number \\)?[0-9]+ \\(of\\|is out of range for\\) \"\\([^ ]+\\)\".*\\)\n",
  442. X     NULL,
  443. X     {-1, -1, -1, -1, 4, -1}
  444. X    },
  445. X    /* print */
  446. X    {"\\(warning: .*\n\\)?\\(\\(.*\\) = .*\n\\(.*\n\\)*\\)",
  447. X     NULL,
  448. X     { 3, -1, -1, -1, -1, 2}
  449. X    },
  450. X    /* start gdb (debug)  */
  451. X    {"\\(.*\n\\)*Type \"help\" for a list of commands.\n",
  452. X     NULL,
  453. X     { -1, -1, -1, -1, -1, -1}
  454. X    },
  455. X    /* directory */
  456. X    {"\\([^ ]+ is already in the source path.[ ]*\n\\)*Source directories searched:[ ]*\\([^ ]+\\)[ ]*\n",
  457. X     NULL,
  458. X     { -1, -1, -1, -1, 1, -1}
  459. X    },
  460. X    /* list */
  461. X    {"\\(.*\n\\)*\\(\\([0-9]+\\).*\n\\)",
  462. X     NULL,
  463. X     { -1, -1, -1, 3, -1, -1}
  464. X    },
  465. X    /* display */
  466. X    {"\\([0-9]+:.*\n\\)",
  467. X     NULL,
  468. X     { -1, -1, -1, -1, -1, 1}
  469. X    },
  470. X    /* info display */
  471. X    {"\\(\\([0-9]+:.*\n\\(\\( .*\n\\)*}\n\\)?\\)*\\)",
  472. X     NULL,
  473. X     { -1, -1, -1, -1, -1, 1}
  474. X    },
  475. X    /* pwd or cd */
  476. X    {"Working directory[ ]+\\([^ ]+\\).[ ]*\n\\([ ]*(canonically[ ]+\\([^ ]+\\)).\n\\)?",
  477. X     NULL,
  478. X     { 1, -1, -1, -1, -1, 3}
  479. X    },
  480. X    /* program received signal */
  481. X    {"\\(.*\n\\)*\n\\(Program received signal \\([-]?[0-9]+\\), [^ ]+.*\n\\)\\(.*\n\\)*",
  482. X    NULL,
  483. X     {  2, 3, -1, -1, -1, -1}
  484. X    },
  485. X    /* special for test in filter_display_info() */
  486. X    {"\\([^0-9].*\n\\)*\\([0-9]+:.*\n\\)\\(.*\n\\)*",
  487. X     NULL,
  488. X     { -1, -1, -1, -1, -1, 2}
  489. X    },
  490. X    /* special for test in filter_reading_symbols() */
  491. X    {"\\(.*\n\\)*\\(Reading in symbols for .*done.\n\\)\\(.*\n\\)*",
  492. X     NULL,
  493. X     { 2, -1, -1, -1, -1, -1}
  494. X    }, 
  495. X    {"\\(.*\n\\)*", NULL, {-1, -1, -1, -1, -1, -1}
  496. X    },
  497. X    NULL 
  498. };
  499. X
  500. /*
  501. X
  502. X    To simplify the patterns, I used for example :
  503. X    
  504. X        "fr[ame]*" instead of "frame\\|fram\\|fra||fr".
  505. X        
  506. X    This will cause 'frmeame' to be accepted. But this is
  507. X    no problem because 'Undefined command' output is parsed
  508. X    before parsing the command line (see parse() in parser.c).
  509. */
  510. X
  511. static PatternRec command_pattern[] = {
  512. X    /* run -r - cont - c - next - n - step - s - nexti - ni - stepi - si - return
  513. X    jump - until - u */
  514. X    {"[ ]*\\(run\\|r\\|cont\\|c\\|next\\|n\\|step\\|s\\|nexti\\|stepi\\|ni\\|si\\|ret[urn]*\\|j[ump]*\\|unt[il]*\\|u\\)\\( .*\\)?\n",
  515. X                                            NULL, {-1, -1, -1, -1, -1, -1}},
  516. X    /* break - tbreak */
  517. X    {"[ ]*\\(t\\)?\\(b\\|br\\|bre\\|brea\\|break\\)\\( .*\\)?\n",
  518. X                                            NULL, {-1, -1, -1, -1, -1, -1}},
  519. X    {"[ ]*info[ ]+directories[ ]*\n",        NULL, {-1, -1, -1, -1, -1, -1}},
  520. X    
  521. X    /* 'frame' is special case of 'frame n' since it does not change the
  522. X    current frame. Else 'frame n' is like up or down. */
  523. X    {"[ ]*fr[ame]*[ ]*\n",                    NULL, {-1, -1, -1, -1, -1, -1}},
  524. X    {"[ ]*\\(up\\|down\\|dow\\|do\\|fr[ame]*\\)\\( .*\\)?\n", 
  525. X                                            NULL, {-1, -1, -1, -1, -1, -1}},
  526. X                                            
  527. X    /* delete - d - clear - enable - disable - dis - disa */
  528. X    /* gdb commands 'delete display' 'enable display' and 'delete environment'
  529. X    are also found here. This is superfluous, but no problem */
  530. X    
  531. X    {"[ ]*\\(del[ete]*\\|d\\|cl[ear]*\\|en[able]*\\|disab[le]*\\|dis\\|disa\\)\\( .*\\)?\n",
  532. X                                            NULL, {-1, -1, -1, -1, -1, -1}},
  533. X                                            
  534. X    {"[ ]*fi[nish]*[ ]*\n",                    NULL, {-1, -1, -1, -1, -1, -1}},
  535. X    {"[ ]*info[ ]+line[ ]*\n",                NULL, {-1, -1, -1, -1, -1, -1}},
  536. X    
  537. X    /* symbol-file */
  538. X    {"[ ]*sy.*\n",                             NULL, {-1, -1, -1, -1, -1, -1}},
  539. X    {"[ ]*cd[ ]*[^ ]+[ ]*\n",                 NULL, {-1, -1, -1, -1, -1, -1}},
  540. X    
  541. X    /* directory */
  542. X    {"[ ]*dir.*\n",                            NULL, {-1, -1, -1, -1, -1, -1}},
  543. X    
  544. X    {"[ ]*pwd[ ]*\n",                        NULL, {-1, -1, -1, -1, -1, -1}},
  545. X    /* list */
  546. X    {"[ ]*l.*\n",                             NULL, {-1, -1, -1, -1, -1, -1}},
  547. X    
  548. X    /* forward-search or reverse-search or search */
  549. X    
  550. X    {"[ ]*\\(fo[rward-search]*\\|rev[erse-search]*\\|sea[rch]*\\)[ ]*",
  551. X                                            NULL, {-1, -1, -1, -1, -1, -1}},
  552. X    
  553. X    /* 'display' is a special case of 'display exp' since it does not
  554. X    add any expression to be displayed */
  555. X    {"[ ]*disp[lay]*[ ]*\n",                            NULL, {-1, -1, -1, -1, -1, -1}},
  556. X    {"[ ]*disp[lay]\\(/[^ ]+\\)?*[ ]*[^ ]+[ ]*.*\n",    NULL, {-1, -1, -1, -1, -1, -1}},
  557. X    
  558. X    /* undisplay */
  559. X    {"[ ]*und.*\n",                            NULL, {-1, -1, -1, -1, -1, -1}},
  560. X    
  561. X    /* Note that Token.mesg (if any) is updated with print command (see 1) */
  562. X    
  563. X    {"[ ]*print[ ]*\\([^ ]?\\([ ]+[^ ]+\\)*\\)[ ]*\n",    NULL, { 1, -1, -1, -1, -1, -1}},
  564. X    {"[ ]*info[ ]+break[ ]*\n",                NULL, {-1, -1, -1, -1, -1, -1}},
  565. X    
  566. X    /* source (note that Token.TK_FILE is updated here) */
  567. X    {"[ ]*so[urce]*[ ]*\\(.*\\)\n",         NULL, {-1, -1, -1, -1,  1, -1}},
  568. X    
  569. X    /* exec-file (just used internally) */
  570. X    {"[ ]*exec-file .*\n",                     NULL, {-1, -1, -1, -1, -1, -1}},
  571. X
  572. X    /* core-file */
  573. X    {"[ ]*cor[e-file]*.*\n", NULL,
  574. X       {-1, -1, -1, -1, -1, -1}},
  575. X
  576. X    /* define */
  577. X    {"[ ]*def[ine]*[ ]+[^ ]+\n", NULL,
  578. X       {-1, -1, -1, -1, -1, -1}},
  579. X
  580. X    /* document */
  581. X    {"[ ]*doc[ument]*[ ]+[^ ]+\n", NULL,
  582. X       {-1, -1, -1, -1, -1, -1}},
  583. X
  584. X    /* end of define or document */
  585. X    {"[ ]*end[].*", NULL,
  586. X       {-1, -1, -1, -1, -1, -1}},
  587. X
  588. X    {"[ ]*help.*\n", NULL,
  589. X       {-1, -1, -1, -1, -1, -1}},
  590. X
  591. X    NULL
  592. };
  593. SHAR_EOF
  594. chmod 0644 mxgdb/gdb_regex.h ||
  595. echo 'restore of mxgdb/gdb_regex.h failed'
  596. Wc_c="`wc -c < 'mxgdb/gdb_regex.h'`"
  597. test 17655 -eq "$Wc_c" ||
  598.     echo 'mxgdb/gdb_regex.h: original size 17655, current size' "$Wc_c"
  599. rm -f _shar_wnt_.tmp
  600. fi
  601. # ============= mxgdb/global.h ==============
  602. if test -f 'mxgdb/global.h' -a X"$1" != X"-c"; then
  603.     echo 'x - skipping mxgdb/global.h (File already exists)'
  604.     rm -f _shar_wnt_.tmp
  605. else
  606. > _shar_wnt_.tmp
  607. echo 'x - extracting mxgdb/global.h (Text)'
  608. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/global.h' &&
  609. /* $Id: global.h,v 1.13 1991/08/23 16:34:37 jtsillas Exp $ */
  610. X
  611. /*****************************************************************************
  612. X *
  613. X *  xdbx - X Window System interface to the dbx debugger
  614. X *
  615. X *  Copyright 1989 The University of Texas at Austin
  616. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  617. X *
  618. X *  Permission to use, copy, modify, and distribute this software and its
  619. X *  documentation for any purpose and without fee is hereby granted,
  620. X *  provided that the above copyright notice appear in all copies and that
  621. X *  both that copyright notice and this permission notice appear in
  622. X *  supporting documentation, and that the name of The University of Texas
  623. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  624. X *  used in advertising or publicity pertaining to distribution of
  625. X *  the software without specific, written prior permission.  The
  626. X *  University of Texas and MCC makes no representations about the 
  627. X *  suitability of this software for any purpose.  It is provided "as is" 
  628. X *  without express or implied warranty.
  629. X *
  630. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  631. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  632. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  633. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  634. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  635. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  636. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  637. X *
  638. X *  Author:      Po Cheung
  639. X *  Created:       March 10, 1989
  640. X *
  641. X *****************************************************************************
  642. X * 
  643. X *  xxgdb - X Window System interface to the gdb debugger
  644. X *  
  645. X *     Copyright 1990 Thomson Consumer Electronics, Inc.
  646. X *  
  647. X *  Permission to use, copy, modify, and distribute this software and its
  648. X *  documentation for any purpose and without fee is hereby granted,
  649. X *  provided that the above copyright notice appear in all copies and that
  650. X *  both that copyright notice and this permission notice appear in
  651. X *  supporting documentation, and that the name of Thomson Consumer
  652. X *  Electronics (TCE) not be used in advertising or publicity pertaining
  653. X *  to distribution of the software without specific, written prior
  654. X *  permission.  TCE makes no representations about the suitability of
  655. X *  this software for any purpose.  It is provided "as is" without express
  656. X *  or implied warranty.
  657. X *
  658. X *  TCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  659. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  660. X *  SHALL TCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  661. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  662. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  663. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  664. X *  SOFTWARE.
  665. X *
  666. X *  Adaptation to GDB:  Pierre Willard
  667. X *  XXGDB Created:       December, 1990
  668. X *
  669. X *****************************************************************************
  670. X *  Modifications for use under System V
  671. X *
  672. X *      Copyright 1990 Bull Worldwide Information Systems, Inc.
  673. X *
  674. X *  Permission to use, copy, modify, and distribute this software and its
  675. X *  documentation for any purpose and without fee is hereby granted,
  676. X *  provided that the above copyright notice appear in all copies and that
  677. X *  both that copyright notice and this permission notice appear in
  678. X *  supporting documentation, and that the name of Bull Worldwide
  679. X *  Information Systems not be used in advertising or publicity pertaining
  680. X *  to distribution of the software without specific, written prior
  681. X *  permission.  Bull makes no representations about the suitability of
  682. X *  this software for any purpose.  It is provided "as is" without express
  683. X *  or implied warranty.
  684. X *
  685. X *  BULL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  686. X *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
  687. X *  SHALL BULL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
  688. X *  OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  689. X *  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  690. X *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  691. X *  SOFTWARE.
  692. X *
  693. X *  Adaptation to SYSV: James Tsillas
  694. X *  XXGDB Created:      March, 1991
  695. X *
  696. X *****************************************************************************/
  697. X
  698. /*  global.h:
  699. X *
  700. X *    Contain extern declarations of variables and functions.
  701. X */
  702. X
  703. #ifdef __GNUC__
  704. #   define alloca __builtin_alloca
  705. #endif
  706. X
  707. #if !defined(MAXPATHLEN) && !defined(Mips)
  708. #define MAXPATHLEN 1024
  709. #endif
  710. X
  711. X
  712. X
  713. #ifdef SYSV 
  714. #    define MAX(a,b)    ((a)>(b)?(a):(b))
  715. #    define MIN(a,b)    ((a)>(b)?(b):(a))
  716. #ifdef SCO
  717. #    include <unistd.h>
  718. #endif
  719. #else
  720. #       define sigset signal
  721. #endif
  722. X
  723. #include "defs.h"
  724. X
  725. /* callgdb.c */
  726. X
  727. extern void        callgdb();        /* fork child, exec dbx */
  728. X
  729. /* command.c */
  730. X
  731. extern void             Break();
  732. extern void             DoIt();
  733. extern void             Print();
  734. extern void             Display_();
  735. extern void             Undisplay();
  736. extern void             Clear();
  737. extern void             Quit();
  738. extern void             Help();
  739. extern void             PopupSearch();
  740. extern void        CreateCommandPanel();
  741. extern void        send_command();
  742. extern char        *get_command();
  743. extern void        insert_command();
  744. extern void        delete_command();
  745. X
  746. /* dbx.c */
  747. extern void        debug_init();        /* initial source display */
  748. extern void         read_dbx();        /* get data from dbx */
  749. extern void         write_dbx();        /* send data to dbx */
  750. extern void        query_dbx();        /* ask dbx for info */
  751. X
  752. /* dialog.c */
  753. X
  754. extern void        CreateDialogWindow();
  755. extern void         AppendDialogText();    /* append text to buffer */
  756. X
  757. /* filemenu.c */
  758. X
  759. extern void        File();            /* file button callback */
  760. extern void             OKCallBack();
  761. extern void             CancelCallBack();
  762. X
  763. /* handler.c */
  764. X
  765. extern void        TextSetTopPosition();    /* sets topDisplayPosition */
  766. extern void         AdjustText();        /* adjust display position */
  767. extern void         exec_handler();        /* run, cont, next, step */
  768. extern void         done_handler();        /* run, cont, next, step */
  769. extern void         stop_at_handler();    /* stop at line */
  770. extern void         stop_in_handler();    /* stop in function */
  771. extern void         updown_handler();    /* move up/down the stack */
  772. extern void         clear_handler();    /* clear stop signs */
  773. extern void         func_handler();        /* display function */
  774. extern void         file_handler();        /* display file */
  775. extern void         debug_handler();    /* debug program */
  776. extern void         cd_handler();        /* change directory */
  777. extern void         pwd_handler();        /* print working directory */
  778. extern void         use_handler();        /* update use directory list */
  779. extern void         search_handler();    /* display searched string */
  780. extern void         list_handler();        /* list source code */
  781. extern void         display_handler();    /* show display variables */
  782. extern void             help_handler();
  783. X
  784. extern Widget        helplabels[];
  785. extern Widget        helpbuttons[];
  786. X
  787. /* parser.c */
  788. X
  789. extern void        parser_init();        /* initialization */
  790. extern void        parse();        /* parse dbx output */
  791. extern void        filter();        /* modify dbx output */
  792. X
  793. /* signals.c */
  794. extern void        trap_signals();        /* signal handling for xdbx */
  795. X
  796. /* signs.c */
  797. X
  798. extern void        signs_init();        /* initilalize routine */
  799. extern void         DisplayStop();        /* show stop sign */
  800. extern void         UpdateStops();        /* update position of stops */
  801. extern void         ClearStops();        /* mark all stops invalid */
  802. extern void         RemoveStop();        /* undisplay stop sign */
  803. extern void         UpdateArrow();        /* update position of arrow */
  804. extern void         UpdateUpdown();        /* update position of updown */
  805. extern void         UpdateBomb();        /* update position of bomb */
  806. X
  807. /* source.c */
  808. X
  809. extern void        SelectStart();        /* modified select-start */
  810. extern void        SelectEnd();        /* modified select-end */
  811. extern void        SelectWord();        /* my select word */
  812. extern void        PrintSelection();    /* select variable and print */
  813. extern void        Update();        /* update line label */
  814. extern void        source_init();        /* init routine */
  815. extern void         CreateSourceWindow();
  816. extern int         LoadFile();        /* display source file */
  817. extern int         LoadCurrentFile();    /* display source file */
  818. extern char        *GetPathname();        /* get full path name of file */
  819. extern void             PopupCommands();        /* Manage the commandDialog */
  820. extern void        MakeDirList();        /* maintain list of dirs */
  821. X
  822. /* utils.c */
  823. X
  824. extern XmTextPosition    TextGetLastPos();    /* get last pos of text */
  825. extern int         TextPositionToLine();    /* convert line # to text pos */
  826. extern int        LineToStop_no();    /* convert line # to stop # */
  827. extern void         bell();            /* sound bell */
  828. extern char         *concat();        /* substring search */
  829. X
  830. /* windows.c */
  831. X
  832. extern void         CreateSubWindows();    /* all subwindows of xdbx */
  833. extern void         UpdateFileLabel();    /* update current file name */
  834. extern void         UpdateLineLabel();    /* update current line num */
  835. extern void         UpdateMessageWindow();    /* update xdbx message */
  836. extern void             CreateSearchPopup();
  837. X
  838. /* extern variables */
  839. X
  840. extern Display    *display;
  841. extern XtAppContext     app_context;
  842. extern Widget    toplevel, fileWindow, commandDialog, 
  843. X            sourceForm, sourceScroll, sourceWindow, messageWindow,  
  844. X        commandWindow, dialogWindow, searchWindow, separator,
  845. X        displayWindow, fileSel, displayFD, scrollV, scrollH,
  846. X        searchText, pageRbutton, pageLbutton, breakbutton,
  847. X                stepbutton, nextbutton, printbutton, downbutton, upbutton,
  848. X                stackbutton, contbutton, finishbutton, runbutton,
  849. X                dispbutton, undispbutton, clearbutton, printsbutton, 
  850. X                argsbutton, localsbutton, helpFD, helpselectscroll,
  851. X                helpupbutton, helpupbuttonlabel;
  852. X
  853. X
  854. X
  855. extern MxgdbResources app_resources;    /* application resources */
  856. extern char    xdbxinit[];        /* initialization filename */
  857. extern char    *dbxprompt;        /* dbx prompt string */
  858. extern char    *xdbxprompt;        /* xdbx prompt string */
  859. extern Boolean    Tstartup;
  860. extern Boolean    debug;
  861. X
  862. extern FileRec       *displayedFile;    /* pointer to current file info */
  863. extern Tokens        Token;        /* token structure */
  864. extern PatternRec       dataPattern[];     /* data display pattern */
  865. X
  866. extern Boolean     Echo;            /* echo dbx output onto window ? */
  867. extern Boolean    Prompt;            /* command or program input ? */
  868. extern Boolean    Parse;            /* flag for parser */
  869. extern Boolean    FalseSignal;        /* real/false signal ? */
  870. extern int    dbxpid;            /* dbx process id */
  871. extern FILE    *dbxfp;            /* file pointer to dbx process */
  872. X
  873. extern char     CurrentFile[];        /* string for dbx output */
  874. extern char     cwd[];            /* current working directory of dbx */
  875. X
  876. extern Arrow    arrow;            /* arrow widget and mapped info */
  877. extern Updown   updown;            /* updown widget and mapped info */
  878. extern Stops    stops[];        /* stop widget and mapped info */
  879. extern Bomb    bomb;            /* bomb widget and mapped info */
  880. extern Cardinal nstops;            /* number of stops */
  881. extern ArrowSign     arrowsign[];
  882. extern UpdownSign     updownsign[];
  883. extern StopSign        stopsign[];
  884. extern BombSign     bombsign[];
  885. X
  886. extern void         display_info_handler();
  887. extern void         break_handler();
  888. extern void         info_dir_handler();
  889. extern void         directory_handler();
  890. extern void         info_line_handler();
  891. extern void         info_break_handler();
  892. X
  893. SHAR_EOF
  894. chmod 0664 mxgdb/global.h ||
  895. echo 'restore of mxgdb/global.h failed'
  896. Wc_c="`wc -c < 'mxgdb/global.h'`"
  897. test 11294 -eq "$Wc_c" ||
  898.     echo 'mxgdb/global.h: original size 11294, current size' "$Wc_c"
  899. rm -f _shar_wnt_.tmp
  900. fi
  901. # ============= mxgdb/getpagesize.h ==============
  902. if test -f 'mxgdb/getpagesize.h' -a X"$1" != X"-c"; then
  903.     echo 'x - skipping mxgdb/getpagesize.h (File already exists)'
  904.     rm -f _shar_wnt_.tmp
  905. else
  906. > _shar_wnt_.tmp
  907. echo 'x - extracting mxgdb/getpagesize.h (Text)'
  908. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/getpagesize.h' &&
  909. /* $Id: getpagesize.h,v 1.1.1.1 1991/05/16 21:42:20 jtsillas Exp $ */
  910. X
  911. #ifdef BSD
  912. #ifndef BSD4_1
  913. #define HAVE_GETPAGESIZE
  914. #endif
  915. #endif
  916. X
  917. #ifndef HAVE_GETPAGESIZE
  918. X
  919. #include <sys/param.h>
  920. X
  921. #ifdef EXEC_PAGESIZE
  922. #define getpagesize() EXEC_PAGESIZE
  923. #else
  924. #ifdef NBPG
  925. #define getpagesize() NBPG * CLSIZE
  926. #ifndef CLSIZE
  927. #define CLSIZE 1
  928. #endif /* no CLSIZE */
  929. #else /* no NBPG */
  930. #ifdef NBPC
  931. #define getpagesize() NBPC
  932. #else
  933. #define getpagesize() NBPP
  934. #endif
  935. #endif /* no NBPG */
  936. #endif /* no EXEC_PAGESIZE */
  937. X
  938. #endif /* not HAVE_GETPAGESIZE */
  939. X
  940. SHAR_EOF
  941. chmod 0644 mxgdb/getpagesize.h ||
  942. echo 'restore of mxgdb/getpagesize.h failed'
  943. Wc_c="`wc -c < 'mxgdb/getpagesize.h'`"
  944. test 539 -eq "$Wc_c" ||
  945.     echo 'mxgdb/getpagesize.h: original size 539, current size' "$Wc_c"
  946. rm -f _shar_wnt_.tmp
  947. fi
  948. # ============= mxgdb/signals.c ==============
  949. if test -f 'mxgdb/signals.c' -a X"$1" != X"-c"; then
  950.     echo 'x - skipping mxgdb/signals.c (File already exists)'
  951.     rm -f _shar_wnt_.tmp
  952. else
  953. > _shar_wnt_.tmp
  954. echo 'x - extracting mxgdb/signals.c (Text)'
  955. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/signals.c' &&
  956. static char rcsid[] = "$Id: signals.c,v 1.4 1991/08/23 16:34:42 jtsillas Exp $";
  957. X
  958. /*****************************************************************************
  959. X *
  960. X *  xdbx - X Window System interface to the dbx debugger
  961. X *
  962. X *  Copyright 1989 The University of Texas at Austin
  963. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  964. X *
  965. X *  Permission to use, copy, modify, and distribute this software and its
  966. X *  documentation for any purpose and without fee is hereby granted,
  967. X *  provided that the above copyright notice appear in all copies and that
  968. X *  both that copyright notice and this permission notice appear in
  969. X *  supporting documentation, and that the name of The University of Texas
  970. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  971. X *  used in advertising or publicity pertaining to distribution of
  972. X *  the software without specific, written prior permission.  The
  973. X *  University of Texas and MCC makes no representations about the 
  974. X *  suitability of this software for any purpose.  It is provided "as is" 
  975. X *  without express or implied warranty.
  976. X *
  977. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  978. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  979. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  980. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  981. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  982. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  983. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  984. X *
  985. X *  Author:      Po Cheung
  986. X *  Created:       March 10, 1989
  987. X *
  988. X *****************************************************************************
  989. X
  990. /* signals.c
  991. X *
  992. X *   Signal handling for xdbx and dbx.
  993. X *
  994. X *   kill_hanlder():    For SIGINT, SIGQUIT, SIGILL, SIGBUS, SIGTERM
  995. X *            print error message and exit with signal status.
  996. X *   quit_handler():    SIGCHLD, wait for dbx to die and exit gracefully.
  997. X *   stop_handler():    SIGTSTP, stop dbx process, then stop own process.
  998. X *   cont_handler():    SIGCONT, continue dbx process.
  999. X *   trap_signals():    Install signal handlers.
  1000. X */
  1001. X
  1002. #include <sys/types.h>
  1003. #include <signal.h>
  1004. #include <sys/wait.h>
  1005. #include "global.h"
  1006. X
  1007. /*  Kill the dbx child process and then exits. */
  1008. /*  ARGSUSED */
  1009. static void kill_handler(sig, code, scp, addr)
  1010. X    int sig, code;
  1011. X    struct sigcontext *scp;
  1012. X    char *addr;
  1013. {
  1014. X    if (FalseSignal) {
  1015. X    FalseSignal = FALSE;
  1016. X    return;
  1017. X    }
  1018. X    kill(dbxpid, SIGKILL);
  1019. X    switch (sig) {
  1020. X      case SIGINT  : fprintf(stderr, "Interrupt\n"); break;
  1021. X      case SIGQUIT : fprintf(stderr, "Quit\n"); break;
  1022. X      case SIGILL  : fprintf(stderr, "Illegal instruction\n"); break;
  1023. X      case SIGBUS  : fprintf(stderr, "Bus error\n"); break;
  1024. X      case SIGSEGV : fprintf(stderr, "Segmentation violation\n"); break;
  1025. X      case SIGTERM : fprintf(stderr, "Soft kill\n"); break;
  1026. X    }
  1027. X    exit(sig);
  1028. }
  1029. X
  1030. X
  1031. static void quit_handler()
  1032. {
  1033. X
  1034. X  int status;
  1035. X  int pid;
  1036. X    /*  wait for the child to report its status; if the child has died, 
  1037. X     *  exit gracefully.
  1038. X     */
  1039. X  if(dbxpid)
  1040. X    {
  1041. #if defined(SYSV) && !defined(SUNOS4)
  1042. X      pid = waitpid(dbxpid, &status , WNOHANG|WUNTRACED);
  1043. #else
  1044. X      pid = wait3(&status, WNOHANG|WUNTRACED, NULL);
  1045. #endif
  1046. X      if (dbxpid == pid && (WIFEXITED(status) || WIFSIGNALED(status)) && 
  1047. X      !WIFSTOPPED(status)) 
  1048. X    {
  1049. X      exit(1);
  1050. X    }
  1051. X    }
  1052. }
  1053. X
  1054. X
  1055. static void stop_handler()
  1056. {
  1057. X    if (dbxpid)
  1058. X    kill(dbxpid, SIGSTOP);    /* stop dbx process */
  1059. X    kill(0, SIGSTOP);        /* stop own process */
  1060. }
  1061. X
  1062. X
  1063. static void cont_handler()
  1064. {
  1065. X    if (dbxpid) {
  1066. X    sleep(1);        /* we need this */
  1067. X    kill(dbxpid, SIGCONT);    /* continue dbx after stop */
  1068. X    }
  1069. }
  1070. X
  1071. X
  1072. /*
  1073. X *  Trap signals to xdbx so that the child process can be handled properly.
  1074. X */
  1075. void trap_signals()
  1076. {
  1077. X    sigset(SIGINT,  kill_handler);
  1078. X    sigset(SIGQUIT, kill_handler);
  1079. X    sigset(SIGILL,  kill_handler);
  1080. X    sigset(SIGBUS,  kill_handler);
  1081. X    sigset(SIGSEGV, kill_handler);
  1082. X    sigset(SIGTERM, kill_handler);
  1083. X
  1084. X    sigset(SIGTSTP, stop_handler);    /* stop signal from keyboard */
  1085. X    sigset(SIGCONT, cont_handler);    /* continue after stop */
  1086. X    sigset(SIGCHLD, quit_handler);    /* child status has changed */
  1087. }
  1088. SHAR_EOF
  1089. chmod 0664 mxgdb/signals.c ||
  1090. echo 'restore of mxgdb/signals.c failed'
  1091. Wc_c="`wc -c < 'mxgdb/signals.c'`"
  1092. test 4220 -eq "$Wc_c" ||
  1093.     echo 'mxgdb/signals.c: original size 4220, current size' "$Wc_c"
  1094. rm -f _shar_wnt_.tmp
  1095. fi
  1096. # ============= mxgdb/handler.c ==============
  1097. if test -f 'mxgdb/handler.c' -a X"$1" != X"-c"; then
  1098.     echo 'x - skipping mxgdb/handler.c (File already exists)'
  1099.     rm -f _shar_wnt_.tmp
  1100. else
  1101. > _shar_wnt_.tmp
  1102. echo 'x - extracting mxgdb/handler.c (Text)'
  1103. sed 's/^X//' << 'SHAR_EOF' > 'mxgdb/handler.c' &&
  1104. static char rcsid[] = "$Id: handler.c,v 1.2 1991/08/23 16:34:38 jtsillas Exp $";
  1105. X
  1106. /*****************************************************************************
  1107. X *
  1108. X *  xdbx - X Window System interface to the dbx debugger
  1109. X *
  1110. X *  Copyright 1989 The University of Texas at Austin
  1111. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  1112. X *
  1113. X *  Permission to use, copy, modify, and distribute this software and its
  1114. X *  documentation for any purpose and without fee is hereby granted,
  1115. X *  provided that the above copyright notice appear in all copies and that
  1116. X *  both that copyright notice and this permission notice appear in
  1117. X *  supporting documentation, and that the name of The University of Texas
  1118. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  1119. X *  used in advertising or publicity pertaining to distribution of
  1120. X *  the software without specific, written prior permission.  The
  1121. X *  University of Texas and MCC makes no representations about the 
  1122. X *  suitability of this software for any purpose.  It is provided "as is" 
  1123. X *  without express or implied warranty.
  1124. X *
  1125. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1126. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1127. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  1128. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  1129. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  1130. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  1131. SHAR_EOF
  1132. true || echo 'restore of mxgdb/handler.c failed'
  1133. fi
  1134. echo 'End of  part 5'
  1135. echo 'File mxgdb/handler.c is continued in part 6'
  1136. echo 6 > _shar_seq_.tmp
  1137. exit 0
  1138.