Commit | Line | Data |
---|---|---|
b8ec8d4a | 1 | /* Top level stuff for GDB, the GNU debugger. |
8b564df8 | 2 | Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994 |
51b57ded | 3 | Free Software Foundation, Inc. |
bd5635a1 RP |
4 | |
5 | This file is part of GDB. | |
6 | ||
e522fb52 | 7 | This program is free software; you can redistribute it and/or modify |
bd5635a1 | 8 | it under the terms of the GNU General Public License as published by |
e522fb52 JG |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | |
bd5635a1 | 11 | |
e522fb52 | 12 | This program is distributed in the hope that it will be useful, |
bd5635a1 RP |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
e522fb52 JG |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
bd5635a1 | 20 | |
bd5635a1 | 21 | #include "defs.h" |
b8ec8d4a SS |
22 | #include <setjmp.h> |
23 | #include "top.h" | |
bd5635a1 | 24 | #include "target.h" |
bd5635a1 | 25 | |
e522fb52 JG |
26 | #include "getopt.h" |
27 | ||
bd5635a1 | 28 | #include <sys/types.h> |
b8ec8d4a SS |
29 | #include <sys/stat.h> |
30 | ||
31 | #include <string.h> | |
32 | /* R_OK lives in either unistd.h or sys/file.h. */ | |
09973223 | 33 | #ifdef USG |
bd5635a1 RP |
34 | #include <unistd.h> |
35 | #endif | |
ee0613d1 | 36 | #ifndef NO_SYS_FILE |
bd5635a1 | 37 | #include <sys/file.h> |
ee0613d1 | 38 | #endif |
bd5635a1 | 39 | |
9748446f JK |
40 | /* Temporary variable for SET_TOP_LEVEL. */ |
41 | static int top_level_val; | |
42 | ||
43 | /* Do a setjmp on error_return and quit_return. catch_errors is | |
44 | generally a cleaner way to do this, but main() would look pretty | |
45 | ugly if it had to use catch_errors each time. */ | |
46 | ||
47 | #define SET_TOP_LEVEL() \ | |
48 | (((top_level_val = setjmp (error_return)) \ | |
49 | ? (PTR) 0 : (PTR) memcpy (quit_return, error_return, sizeof (jmp_buf))) \ | |
50 | , top_level_val) | |
51 | ||
bd5635a1 RP |
52 | int |
53 | main (argc, argv) | |
54 | int argc; | |
55 | char **argv; | |
56 | { | |
57 | int count; | |
bd5635a1 RP |
58 | static int quiet = 0; |
59 | static int batch = 0; | |
60 | ||
61 | /* Pointers to various arguments from command line. */ | |
62 | char *symarg = NULL; | |
63 | char *execarg = NULL; | |
64 | char *corearg = NULL; | |
65 | char *cdarg = NULL; | |
66 | char *ttyarg = NULL; | |
67 | ||
c307bb11 JK |
68 | /* These are static so that we can take their address in an initializer. */ |
69 | static int print_help; | |
70 | static int print_version; | |
71 | ||
72 | /* Pointers to all arguments of --command option. */ | |
bd5635a1 RP |
73 | char **cmdarg; |
74 | /* Allocated size of cmdarg. */ | |
75 | int cmdsize; | |
76 | /* Number of elements of cmdarg used. */ | |
77 | int ncmd; | |
78 | ||
c307bb11 | 79 | /* Indices of all arguments of --directory option. */ |
bd5635a1 RP |
80 | char **dirarg; |
81 | /* Allocated size. */ | |
82 | int dirsize; | |
83 | /* Number of elements used. */ | |
84 | int ndir; | |
85 | ||
3a16d640 JG |
86 | struct stat homebuf, cwdbuf; |
87 | char *homedir, *homeinit; | |
88 | ||
bd5635a1 RP |
89 | register int i; |
90 | ||
a6b26c44 SS |
91 | /* start-sanitize-mpw */ |
92 | #ifdef MPW | |
93 | /* Drop into MacsBug, but only if the executable is specially named. */ | |
94 | if (strcmp(argv[0], "DEBUGGDB") == 0) | |
95 | DebugStr("\pat start of GDB main"); | |
b8ec8d4a SS |
96 | /* Do all Mac-specific setup. */ |
97 | mac_init (); | |
a6b26c44 SS |
98 | #endif /* MPW */ |
99 | /* end-sanitize-mpw */ | |
bd5635a1 | 100 | /* This needs to happen before the first use of malloc. */ |
318bf84f | 101 | init_malloc ((PTR) NULL); |
bd5635a1 RP |
102 | |
103 | #if defined (ALIGN_STACK_ON_STARTUP) | |
104 | i = (int) &count & 0x3; | |
105 | if (i != 0) | |
106 | alloca (4 - i); | |
107 | #endif | |
108 | ||
bd099407 | 109 | /* If error() is called from initialization code, just exit */ |
9748446f | 110 | if (SET_TOP_LEVEL ()) { |
bd099407 JG |
111 | exit(1); |
112 | } | |
113 | ||
bd5635a1 RP |
114 | cmdsize = 1; |
115 | cmdarg = (char **) xmalloc (cmdsize * sizeof (*cmdarg)); | |
116 | ncmd = 0; | |
117 | dirsize = 1; | |
118 | dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg)); | |
119 | ndir = 0; | |
120 | ||
121 | quit_flag = 0; | |
122 | line = (char *) xmalloc (linesize); | |
123 | line[0] = '\0'; /* Terminate saved (now empty) cmd line */ | |
124 | instream = stdin; | |
125 | ||
b7ec5b8d FF |
126 | getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); |
127 | current_directory = gdb_dirbuf; | |
bd5635a1 | 128 | |
bd5635a1 RP |
129 | /* Parse arguments and options. */ |
130 | { | |
131 | int c; | |
bd5635a1 RP |
132 | /* When var field is 0, use flag field to record the equivalent |
133 | short option (or arbitrary numbers starting at 10 for those | |
134 | with no equivalent). */ | |
135 | static struct option long_options[] = | |
136 | { | |
318bf84f FF |
137 | {"readnow", no_argument, &readnow_symbol_files, 1}, |
138 | {"r", no_argument, &readnow_symbol_files, 1}, | |
139 | {"mapped", no_argument, &mapped_symbol_files, 1}, | |
140 | {"m", no_argument, &mapped_symbol_files, 1}, | |
ee0613d1 JG |
141 | {"quiet", no_argument, &quiet, 1}, |
142 | {"q", no_argument, &quiet, 1}, | |
fb29d681 | 143 | {"silent", no_argument, &quiet, 1}, |
ee0613d1 JG |
144 | {"nx", no_argument, &inhibit_gdbinit, 1}, |
145 | {"n", no_argument, &inhibit_gdbinit, 1}, | |
146 | {"batch", no_argument, &batch, 1}, | |
147 | {"epoch", no_argument, &epoch_interface, 1}, | |
6c803036 JK |
148 | |
149 | /* This is a synonym for "--annotate=1". --annotate is now preferred, | |
150 | but keep this here for a long time because people will be running | |
151 | emacses which use --fullname. */ | |
152 | {"fullname", no_argument, 0, 'f'}, | |
153 | {"f", no_argument, 0, 'f'}, | |
154 | ||
155 | {"annotate", required_argument, 0, 12}, | |
ee0613d1 JG |
156 | {"help", no_argument, &print_help, 1}, |
157 | {"se", required_argument, 0, 10}, | |
158 | {"symbols", required_argument, 0, 's'}, | |
159 | {"s", required_argument, 0, 's'}, | |
160 | {"exec", required_argument, 0, 'e'}, | |
161 | {"e", required_argument, 0, 'e'}, | |
162 | {"core", required_argument, 0, 'c'}, | |
163 | {"c", required_argument, 0, 'c'}, | |
164 | {"command", required_argument, 0, 'x'}, | |
c307bb11 | 165 | {"version", no_argument, &print_version, 1}, |
ee0613d1 JG |
166 | {"x", required_argument, 0, 'x'}, |
167 | {"directory", required_argument, 0, 'd'}, | |
168 | {"cd", required_argument, 0, 11}, | |
169 | {"tty", required_argument, 0, 't'}, | |
170 | {"baud", required_argument, 0, 'b'}, | |
171 | {"b", required_argument, 0, 'b'}, | |
bd5635a1 RP |
172 | /* Allow machine descriptions to add more options... */ |
173 | #ifdef ADDITIONAL_OPTIONS | |
174 | ADDITIONAL_OPTIONS | |
175 | #endif | |
ee0613d1 | 176 | {0, no_argument, 0, 0}, |
bd5635a1 RP |
177 | }; |
178 | ||
179 | while (1) | |
180 | { | |
ee0613d1 JG |
181 | int option_index; |
182 | ||
bd5635a1 RP |
183 | c = getopt_long_only (argc, argv, "", |
184 | long_options, &option_index); | |
185 | if (c == EOF) | |
186 | break; | |
187 | ||
188 | /* Long option that takes an argument. */ | |
189 | if (c == 0 && long_options[option_index].flag == 0) | |
190 | c = long_options[option_index].val; | |
191 | ||
192 | switch (c) | |
193 | { | |
194 | case 0: | |
195 | /* Long option that just sets a flag. */ | |
196 | break; | |
197 | case 10: | |
198 | symarg = optarg; | |
199 | execarg = optarg; | |
200 | break; | |
201 | case 11: | |
202 | cdarg = optarg; | |
203 | break; | |
6c803036 JK |
204 | case 12: |
205 | /* FIXME: what if the syntax is wrong (e.g. not digits)? */ | |
206 | annotation_level = atoi (optarg); | |
207 | break; | |
208 | case 'f': | |
209 | annotation_level = 1; | |
210 | break; | |
bd5635a1 RP |
211 | case 's': |
212 | symarg = optarg; | |
213 | break; | |
214 | case 'e': | |
215 | execarg = optarg; | |
216 | break; | |
217 | case 'c': | |
218 | corearg = optarg; | |
219 | break; | |
220 | case 'x': | |
221 | cmdarg[ncmd++] = optarg; | |
222 | if (ncmd >= cmdsize) | |
223 | { | |
224 | cmdsize *= 2; | |
225 | cmdarg = (char **) xrealloc ((char *)cmdarg, | |
226 | cmdsize * sizeof (*cmdarg)); | |
227 | } | |
228 | break; | |
229 | case 'd': | |
230 | dirarg[ndir++] = optarg; | |
231 | if (ndir >= dirsize) | |
232 | { | |
233 | dirsize *= 2; | |
234 | dirarg = (char **) xrealloc ((char *)dirarg, | |
235 | dirsize * sizeof (*dirarg)); | |
236 | } | |
237 | break; | |
238 | case 't': | |
239 | ttyarg = optarg; | |
240 | break; | |
241 | case 'q': | |
242 | quiet = 1; | |
243 | break; | |
244 | case 'b': | |
d0d8484a SG |
245 | { |
246 | int i; | |
247 | char *p; | |
248 | ||
249 | i = strtol (optarg, &p, 0); | |
250 | if (i == 0 && p == optarg) | |
8e4c7b3e JK |
251 | |
252 | /* Don't use *_filtered or warning() (which relies on | |
253 | current_target) until after initialize_all_files(). */ | |
254 | ||
255 | fprintf_unfiltered | |
256 | (gdb_stderr, | |
257 | "warning: could not set baud rate to `%s'.\n", optarg); | |
d0d8484a SG |
258 | else |
259 | baud_rate = i; | |
260 | } | |
bd5635a1 | 261 | break; |
d0d8484a | 262 | |
bd5635a1 RP |
263 | #ifdef ADDITIONAL_OPTION_CASES |
264 | ADDITIONAL_OPTION_CASES | |
265 | #endif | |
266 | case '?': | |
199b2450 | 267 | fprintf_unfiltered (gdb_stderr, |
fb29d681 | 268 | "Use `%s --help' for a complete list of options.\n", |
bd5635a1 RP |
269 | argv[0]); |
270 | exit (1); | |
271 | } | |
bd5635a1 | 272 | } |
fb29d681 | 273 | |
bd5635a1 RP |
274 | /* OK, that's all the options. The other arguments are filenames. */ |
275 | count = 0; | |
276 | for (; optind < argc; optind++) | |
277 | switch (++count) | |
278 | { | |
279 | case 1: | |
280 | symarg = argv[optind]; | |
281 | execarg = argv[optind]; | |
282 | break; | |
283 | case 2: | |
284 | corearg = argv[optind]; | |
285 | break; | |
286 | case 3: | |
199b2450 | 287 | fprintf_unfiltered (gdb_stderr, |
bd5635a1 RP |
288 | "Excess command line arguments ignored. (%s%s)\n", |
289 | argv[optind], (optind == argc - 1) ? "" : " ..."); | |
290 | break; | |
291 | } | |
292 | if (batch) | |
293 | quiet = 1; | |
294 | } | |
295 | ||
d8fc8773 | 296 | gdb_init (); |
bd5635a1 | 297 | |
c307bb11 JK |
298 | /* Do these (and anything which might call wrap_here or *_filtered) |
299 | after initialize_all_files. */ | |
300 | if (print_version) | |
301 | { | |
199b2450 | 302 | print_gdb_version (gdb_stdout); |
c307bb11 JK |
303 | wrap_here (""); |
304 | printf_filtered ("\n"); | |
305 | exit (0); | |
306 | } | |
307 | ||
308 | if (print_help) | |
309 | { | |
310 | /* --version is intentionally not documented here, because we | |
311 | are printing the version here, and the help is long enough | |
312 | already. */ | |
313 | ||
199b2450 | 314 | print_gdb_version (gdb_stdout); |
c307bb11 JK |
315 | /* Make sure the output gets printed. */ |
316 | wrap_here (""); | |
317 | printf_filtered ("\n"); | |
318 | ||
319 | /* But don't use *_filtered here. We don't want to prompt for continue | |
320 | no matter how small the screen or how much we're going to print. */ | |
a6b26c44 SS |
321 | /* start-sanitize-mpw */ |
322 | /* For reasons too ugly to describe... */ | |
323 | #ifdef MPW_C | |
324 | fputs_unfiltered ("This is the GNU debugger.\n", gdb_stdout); | |
325 | #else | |
326 | /* end-sanitize-mpw */ | |
199b2450 | 327 | fputs_unfiltered ("\ |
c307bb11 JK |
328 | This is the GNU debugger. Usage:\n\ |
329 | gdb [options] [executable-file [core-file or process-id]]\n\ | |
330 | Options:\n\ | |
331 | --help Print this message.\n\ | |
332 | --quiet Do not print version number on startup.\n\ | |
333 | --fullname Output information used by emacs-GDB interface.\n\ | |
334 | --epoch Output information used by epoch emacs-GDB interface.\n\ | |
335 | --batch Exit after processing options.\n\ | |
336 | --nx Do not read .gdbinit file.\n\ | |
337 | --tty=TTY Use TTY for input/output by the program being debugged.\n\ | |
338 | --cd=DIR Change current directory to DIR.\n\ | |
339 | --directory=DIR Search for source files in DIR.\n\ | |
340 | --command=FILE Execute GDB commands from FILE.\n\ | |
341 | --symbols=SYMFILE Read symbols from SYMFILE.\n\ | |
342 | --exec=EXECFILE Use EXECFILE as the executable.\n\ | |
343 | --se=FILE Use FILE as symbol file and executable file.\n\ | |
344 | --core=COREFILE Analyze the core dump COREFILE.\n\ | |
345 | -b BAUDRATE Set serial port baud rate used for remote debugging.\n\ | |
346 | --mapped Use mapped symbol files if supported on this system.\n\ | |
347 | --readnow Fully read symbol files on first access.\n\ | |
199b2450 | 348 | ", gdb_stdout); |
a6b26c44 SS |
349 | /* start-sanitize-mpw */ |
350 | #endif /* MPW_C */ | |
351 | /* end-sanitize-mpw */ | |
c307bb11 | 352 | #ifdef ADDITIONAL_OPTION_HELP |
199b2450 | 353 | fputs_unfiltered (ADDITIONAL_OPTION_HELP, gdb_stdout); |
c307bb11 | 354 | #endif |
199b2450 | 355 | fputs_unfiltered ("\n\ |
c307bb11 | 356 | For more information, type \"help\" from within GDB, or consult the\n\ |
199b2450 | 357 | GDB manual (available as on-line info or a printed manual).\n", gdb_stdout); |
c307bb11 JK |
358 | exit (0); |
359 | } | |
360 | ||
bd5635a1 RP |
361 | if (!quiet) |
362 | { | |
81066208 JG |
363 | /* Print all the junk at the top, with trailing "..." if we are about |
364 | to read a symbol file (possibly slowly). */ | |
365 | print_gnu_advertisement (); | |
199b2450 | 366 | print_gdb_version (gdb_stdout); |
81066208 JG |
367 | if (symarg) |
368 | printf_filtered (".."); | |
bd099407 | 369 | wrap_here(""); |
199b2450 | 370 | gdb_flush (gdb_stdout); /* Force to screen during slow operations */ |
bd5635a1 RP |
371 | } |
372 | ||
81066208 | 373 | error_pre_print = "\n\n"; |
51b57ded FF |
374 | /* We may get more than one warning, don't double space all of them... */ |
375 | warning_pre_print = "\nwarning: "; | |
81066208 | 376 | |
3a16d640 JG |
377 | /* Read and execute $HOME/.gdbinit file, if it exists. This is done |
378 | *before* all the command line arguments are processed; it sets | |
379 | global parameters, which are independent of what file you are | |
380 | debugging or what directory you are in. */ | |
381 | homedir = getenv ("HOME"); | |
382 | if (homedir) | |
383 | { | |
384 | homeinit = (char *) alloca (strlen (getenv ("HOME")) + | |
385 | strlen (gdbinit) + 10); | |
386 | strcpy (homeinit, getenv ("HOME")); | |
387 | strcat (homeinit, "/"); | |
388 | strcat (homeinit, gdbinit); | |
389 | if (!inhibit_gdbinit && access (homeinit, R_OK) == 0) | |
390 | { | |
9748446f | 391 | if (!SET_TOP_LEVEL ()) |
3a16d640 JG |
392 | source_command (homeinit, 0); |
393 | } | |
394 | do_cleanups (ALL_CLEANUPS); | |
395 | ||
396 | /* Do stats; no need to do them elsewhere since we'll only | |
397 | need them if homedir is set. Make sure that they are | |
398 | zero in case one of them fails (this guarantees that they | |
399 | won't match if either exists). */ | |
400 | ||
401 | memset (&homebuf, 0, sizeof (struct stat)); | |
402 | memset (&cwdbuf, 0, sizeof (struct stat)); | |
403 | ||
404 | stat (homeinit, &homebuf); | |
405 | stat (gdbinit, &cwdbuf); /* We'll only need this if | |
406 | homedir was set. */ | |
407 | } | |
408 | ||
bd5635a1 RP |
409 | /* Now perform all the actions indicated by the arguments. */ |
410 | if (cdarg != NULL) | |
411 | { | |
9748446f | 412 | if (!SET_TOP_LEVEL ()) |
bd5635a1 RP |
413 | { |
414 | cd_command (cdarg, 0); | |
bd5635a1 RP |
415 | } |
416 | } | |
f266e564 JK |
417 | do_cleanups (ALL_CLEANUPS); |
418 | ||
bd5635a1 | 419 | for (i = 0; i < ndir; i++) |
9748446f | 420 | if (!SET_TOP_LEVEL ()) |
bd5635a1 | 421 | directory_command (dirarg[i], 0); |
51b57ded | 422 | free ((PTR)dirarg); |
f266e564 JK |
423 | do_cleanups (ALL_CLEANUPS); |
424 | ||
bd5635a1 RP |
425 | if (execarg != NULL |
426 | && symarg != NULL | |
2e4964ad | 427 | && STREQ (execarg, symarg)) |
bd5635a1 RP |
428 | { |
429 | /* The exec file and the symbol-file are the same. If we can't open | |
430 | it, better only print one error message. */ | |
9748446f | 431 | if (!SET_TOP_LEVEL ()) |
bd5635a1 RP |
432 | { |
433 | exec_file_command (execarg, !batch); | |
81066208 | 434 | symbol_file_command (symarg, 0); |
bd5635a1 RP |
435 | } |
436 | } | |
437 | else | |
438 | { | |
439 | if (execarg != NULL) | |
9748446f | 440 | if (!SET_TOP_LEVEL ()) |
bd5635a1 RP |
441 | exec_file_command (execarg, !batch); |
442 | if (symarg != NULL) | |
9748446f | 443 | if (!SET_TOP_LEVEL ()) |
81066208 | 444 | symbol_file_command (symarg, 0); |
bd5635a1 | 445 | } |
f266e564 JK |
446 | do_cleanups (ALL_CLEANUPS); |
447 | ||
81066208 JG |
448 | /* After the symbol file has been read, print a newline to get us |
449 | beyond the copyright line... But errors should still set off | |
450 | the error message with a (single) blank line. */ | |
afe4ca15 JG |
451 | if (!quiet) |
452 | printf_filtered ("\n"); | |
81066208 | 453 | error_pre_print = "\n"; |
318bf84f | 454 | warning_pre_print = "\nwarning: "; |
81066208 | 455 | |
bd5635a1 | 456 | if (corearg != NULL) |
9748446f | 457 | if (!SET_TOP_LEVEL ()) |
bd5635a1 | 458 | core_file_command (corearg, !batch); |
9748446f | 459 | else if (isdigit (corearg[0]) && !SET_TOP_LEVEL ()) |
bd5635a1 | 460 | attach_command (corearg, !batch); |
f266e564 | 461 | do_cleanups (ALL_CLEANUPS); |
bd5635a1 RP |
462 | |
463 | if (ttyarg != NULL) | |
9748446f | 464 | if (!SET_TOP_LEVEL ()) |
bd5635a1 | 465 | tty_command (ttyarg, !batch); |
f266e564 | 466 | do_cleanups (ALL_CLEANUPS); |
bd5635a1 RP |
467 | |
468 | #ifdef ADDITIONAL_OPTION_HANDLER | |
469 | ADDITIONAL_OPTION_HANDLER; | |
470 | #endif | |
471 | ||
81066208 JG |
472 | /* Error messages should no longer be distinguished with extra output. */ |
473 | error_pre_print = 0; | |
318bf84f | 474 | warning_pre_print = "warning: "; |
81066208 | 475 | |
3a16d640 JG |
476 | /* Read the .gdbinit file in the current directory, *if* it isn't |
477 | the same as the $HOME/.gdbinit file (it should exist, also). */ | |
478 | ||
479 | if (!homedir | |
480 | || memcmp ((char *) &homebuf, (char *) &cwdbuf, sizeof (struct stat))) | |
481 | if (!inhibit_gdbinit && access (gdbinit, R_OK) == 0) | |
bd5635a1 | 482 | { |
9748446f | 483 | if (!SET_TOP_LEVEL ()) |
d75710b0 | 484 | source_command (gdbinit, 0); |
bd5635a1 | 485 | } |
d75710b0 FF |
486 | do_cleanups (ALL_CLEANUPS); |
487 | ||
488 | for (i = 0; i < ncmd; i++) | |
489 | { | |
9748446f | 490 | if (!SET_TOP_LEVEL ()) |
d75710b0 FF |
491 | { |
492 | if (cmdarg[i][0] == '-' && cmdarg[i][1] == '\0') | |
493 | read_command_file (stdin); | |
494 | else | |
495 | source_command (cmdarg[i], !batch); | |
496 | do_cleanups (ALL_CLEANUPS); | |
497 | } | |
498 | } | |
51b57ded | 499 | free ((PTR)cmdarg); |
bd5635a1 | 500 | |
8b3c897a | 501 | /* Read in the old history after all the command files have been read. */ |
fc61e9ee | 502 | init_history(); |
8b3c897a | 503 | |
bd5635a1 RP |
504 | if (batch) |
505 | { | |
506 | /* We have hit the end of the batch file. */ | |
507 | exit (0); | |
508 | } | |
509 | ||
510 | /* Do any host- or target-specific hacks. This is used for i960 targets | |
511 | to force the user to set a nindy target and spec its parameters. */ | |
512 | ||
513 | #ifdef BEFORE_MAIN_LOOP_HOOK | |
514 | BEFORE_MAIN_LOOP_HOOK; | |
515 | #endif | |
516 | ||
517 | /* The command loop. */ | |
518 | ||
519 | while (1) | |
520 | { | |
9748446f | 521 | if (!SET_TOP_LEVEL ()) |
bd5635a1 | 522 | { |
f266e564 | 523 | do_cleanups (ALL_CLEANUPS); /* Do complete cleanup */ |
a6b26c44 SS |
524 | /* start-sanitize-mpw */ |
525 | #ifdef MPW | |
526 | /* If we're being a Mac application, go into a Mac-specific | |
527 | event-handling loop instead. We still want to be inside | |
528 | the outer loop, because that will catch longjmps resulting | |
529 | from some command executions. */ | |
530 | if (mac_app) | |
531 | mac_command_loop (); | |
532 | else | |
533 | #endif /* MPW */ | |
60b3e281 | 534 | /* end-sanitize-mpw */ |
bd5635a1 RP |
535 | command_loop (); |
536 | quit_command ((char *)0, instream == stdin); | |
537 | } | |
538 | } | |
539 | /* No exit -- exit is through quit_command. */ | |
540 | } | |
d3507982 JK |
541 | \f |
542 | void | |
543 | init_proc () | |
544 | { | |
545 | } | |
546 | ||
547 | int | |
548 | proc_wait (pid, status) | |
549 | int pid; | |
550 | int *status; | |
551 | { | |
552 | return wait (status); | |
553 | } | |
554 | ||
555 | void | |
556 | proc_remove_foreign (pid) | |
557 | int pid; | |
558 | { | |
559 | } | |
bd5635a1 RP |
560 | |
561 | void | |
b8ec8d4a SS |
562 | fputs_unfiltered (linebuffer, stream) |
563 | const char *linebuffer; | |
564 | FILE *stream; | |
bd5635a1 | 565 | { |
b8ec8d4a | 566 | fputs (linebuffer, stream); |
bd5635a1 | 567 | } |