kdump.c revision 1.11 1 1.1 cgd /*-
2 1.1 cgd * Copyright (c) 1988, 1993
3 1.1 cgd * The Regents of the University of California. All rights reserved.
4 1.1 cgd *
5 1.1 cgd * Redistribution and use in source and binary forms, with or without
6 1.1 cgd * modification, are permitted provided that the following conditions
7 1.1 cgd * are met:
8 1.1 cgd * 1. Redistributions of source code must retain the above copyright
9 1.1 cgd * notice, this list of conditions and the following disclaimer.
10 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer in the
12 1.1 cgd * documentation and/or other materials provided with the distribution.
13 1.1 cgd * 3. All advertising materials mentioning features or use of this software
14 1.1 cgd * must display the following acknowledgement:
15 1.1 cgd * This product includes software developed by the University of
16 1.1 cgd * California, Berkeley and its contributors.
17 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
18 1.1 cgd * may be used to endorse or promote products derived from this software
19 1.1 cgd * without specific prior written permission.
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 cgd * SUCH DAMAGE.
32 1.1 cgd */
33 1.1 cgd
34 1.1 cgd #ifndef lint
35 1.1 cgd static char copyright[] =
36 1.1 cgd "@(#) Copyright (c) 1988, 1993\n\
37 1.1 cgd The Regents of the University of California. All rights reserved.\n";
38 1.1 cgd #endif /* not lint */
39 1.1 cgd
40 1.1 cgd #ifndef lint
41 1.3 mycroft /*static char sccsid[] = "from: @(#)kdump.c 8.1 (Berkeley) 6/6/93";*/
42 1.11 christos static char *rcsid = "$Id: kdump.c,v 1.11 1995/07/19 15:11:28 christos Exp $";
43 1.1 cgd #endif /* not lint */
44 1.1 cgd
45 1.1 cgd #include <sys/param.h>
46 1.1 cgd #include <sys/errno.h>
47 1.1 cgd #include <sys/time.h>
48 1.1 cgd #include <sys/uio.h>
49 1.1 cgd #include <sys/ktrace.h>
50 1.1 cgd #include <sys/ioctl.h>
51 1.1 cgd #include <sys/ptrace.h>
52 1.8 jtc #define _KERNEL
53 1.1 cgd #include <sys/errno.h>
54 1.8 jtc #undef _KERNEL
55 1.4 mycroft
56 1.4 mycroft #include <err.h>
57 1.4 mycroft #include <signal.h>
58 1.1 cgd #include <stdio.h>
59 1.1 cgd #include <stdlib.h>
60 1.1 cgd #include <string.h>
61 1.4 mycroft #include <unistd.h>
62 1.4 mycroft #include <vis.h>
63 1.4 mycroft
64 1.1 cgd #include "ktrace.h"
65 1.1 cgd
66 1.1 cgd int timestamp, decimal, fancy = 1, tail, maxdata;
67 1.1 cgd char *tracefile = DEF_TRACEFILE;
68 1.1 cgd struct ktr_header ktr_header;
69 1.1 cgd
70 1.1 cgd #define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
71 1.1 cgd
72 1.11 christos #include <sys/syscall.h>
73 1.11 christos
74 1.11 christos #include "../../sys/compat/hpux/hpux_syscall.h"
75 1.11 christos #include "../../sys/compat/ibcs2/ibcs2_syscall.h"
76 1.11 christos #include "../../sys/compat/linux/linux_syscall.h"
77 1.11 christos #include "../../sys/compat/osf1/osf1_syscall.h"
78 1.11 christos #include "../../sys/compat/sunos/sunos_syscall.h"
79 1.11 christos #include "../../sys/compat/svr4/svr4_syscall.h"
80 1.11 christos #include "../../sys/compat/ultrix/ultrix_syscall.h"
81 1.11 christos
82 1.11 christos #define KTRACE
83 1.11 christos #include "../../sys/kern/syscalls.c"
84 1.11 christos
85 1.11 christos #include "../../sys/compat/hpux/hpux_syscalls.c"
86 1.11 christos #include "../../sys/compat/ibcs2/ibcs2_syscalls.c"
87 1.11 christos #include "../../sys/compat/linux/linux_syscalls.c"
88 1.11 christos #include "../../sys/compat/osf1/osf1_syscalls.c"
89 1.11 christos #include "../../sys/compat/sunos/sunos_syscalls.c"
90 1.11 christos #include "../../sys/compat/svr4/svr4_syscalls.c"
91 1.11 christos #include "../../sys/compat/ultrix/ultrix_syscalls.c"
92 1.11 christos #undef KTRACE
93 1.11 christos
94 1.11 christos struct emulation {
95 1.11 christos char *name; /* Emulation name */
96 1.11 christos char **sysnames; /* Array of system call names */
97 1.11 christos int nsysnames; /* Number of */
98 1.11 christos };
99 1.11 christos
100 1.11 christos static struct emulation emulations[] = {
101 1.11 christos { "netbsd", syscallnames, SYS_MAXSYSCALL },
102 1.11 christos { "hpux", hpux_syscallnames, HPUX_SYS_MAXSYSCALL },
103 1.11 christos { "ibcs2", ibcs2_syscallnames, IBCS2_SYS_MAXSYSCALL },
104 1.11 christos { "linux", linux_syscallnames, LINUX_SYS_MAXSYSCALL },
105 1.11 christos { "osf1", osf1_syscallnames, OSF1_SYS_MAXSYSCALL },
106 1.11 christos { "sunos", sunos_syscallnames, SUNOS_SYS_MAXSYSCALL },
107 1.11 christos { "svr4", svr4_syscallnames, SVR4_SYS_MAXSYSCALL },
108 1.11 christos { "ultrix", ultrix_syscallnames, ULTRIX_SYS_MAXSYSCALL },
109 1.11 christos { NULL, NULL, NULL }
110 1.11 christos };
111 1.11 christos
112 1.11 christos struct emulation *current;
113 1.11 christos
114 1.11 christos
115 1.11 christos static char *ptrace_ops[] = {
116 1.11 christos "PT_TRACE_ME", "PT_READ_I", "PT_READ_D", "PT_READ_U",
117 1.11 christos "PT_WRITE_I", "PT_WRITE_D", "PT_WRITE_U", "PT_CONTINUE",
118 1.11 christos "PT_KILL", "PT_ATTACH", "PT_DETACH",
119 1.11 christos };
120 1.11 christos
121 1.4 mycroft int
122 1.1 cgd main(argc, argv)
123 1.1 cgd int argc;
124 1.1 cgd char *argv[];
125 1.1 cgd {
126 1.1 cgd int ch, ktrlen, size;
127 1.1 cgd register void *m;
128 1.1 cgd int trpoints = ALL_POINTS;
129 1.1 cgd
130 1.11 christos current = &emulations[0]; /* NetBSD */
131 1.11 christos
132 1.11 christos while ((ch = getopt(argc, argv, "e:f:dlm:nRTt:")) != -1)
133 1.4 mycroft switch (ch) {
134 1.11 christos case 'e':
135 1.11 christos setemul(optarg);
136 1.11 christos break;
137 1.1 cgd case 'f':
138 1.1 cgd tracefile = optarg;
139 1.1 cgd break;
140 1.1 cgd case 'd':
141 1.1 cgd decimal = 1;
142 1.1 cgd break;
143 1.1 cgd case 'l':
144 1.1 cgd tail = 1;
145 1.1 cgd break;
146 1.1 cgd case 'm':
147 1.1 cgd maxdata = atoi(optarg);
148 1.1 cgd break;
149 1.1 cgd case 'n':
150 1.1 cgd fancy = 0;
151 1.1 cgd break;
152 1.1 cgd case 'R':
153 1.1 cgd timestamp = 2; /* relative timestamp */
154 1.1 cgd break;
155 1.1 cgd case 'T':
156 1.1 cgd timestamp = 1;
157 1.1 cgd break;
158 1.1 cgd case 't':
159 1.1 cgd trpoints = getpoints(optarg);
160 1.4 mycroft if (trpoints < 0)
161 1.4 mycroft errx(1, "unknown trace point in %s", optarg);
162 1.1 cgd break;
163 1.1 cgd default:
164 1.1 cgd usage();
165 1.1 cgd }
166 1.1 cgd argv += optind;
167 1.1 cgd argc -= optind;
168 1.1 cgd
169 1.1 cgd if (argc > 1)
170 1.1 cgd usage();
171 1.1 cgd
172 1.1 cgd m = (void *)malloc(size = 1025);
173 1.4 mycroft if (m == NULL)
174 1.4 mycroft errx(1, "%s", strerror(ENOMEM));
175 1.4 mycroft if (!freopen(tracefile, "r", stdin))
176 1.4 mycroft err(1, "%s", tracefile);
177 1.1 cgd while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) {
178 1.1 cgd if (trpoints & (1<<ktr_header.ktr_type))
179 1.1 cgd dumpheader(&ktr_header);
180 1.4 mycroft if ((ktrlen = ktr_header.ktr_len) < 0)
181 1.4 mycroft errx(1, "bogus length 0x%x", ktrlen);
182 1.1 cgd if (ktrlen > size) {
183 1.1 cgd m = (void *)realloc(m, ktrlen+1);
184 1.4 mycroft if (m == NULL)
185 1.4 mycroft errx(1, "%s", strerror(ENOMEM));
186 1.1 cgd size = ktrlen;
187 1.1 cgd }
188 1.4 mycroft if (ktrlen && fread_tail(m, ktrlen, 1) == 0)
189 1.4 mycroft errx(1, "data too short");
190 1.1 cgd if ((trpoints & (1<<ktr_header.ktr_type)) == 0)
191 1.1 cgd continue;
192 1.1 cgd switch (ktr_header.ktr_type) {
193 1.1 cgd case KTR_SYSCALL:
194 1.1 cgd ktrsyscall((struct ktr_syscall *)m);
195 1.1 cgd break;
196 1.1 cgd case KTR_SYSRET:
197 1.1 cgd ktrsysret((struct ktr_sysret *)m);
198 1.1 cgd break;
199 1.1 cgd case KTR_NAMEI:
200 1.1 cgd ktrnamei(m, ktrlen);
201 1.1 cgd break;
202 1.1 cgd case KTR_GENIO:
203 1.1 cgd ktrgenio((struct ktr_genio *)m, ktrlen);
204 1.1 cgd break;
205 1.1 cgd case KTR_PSIG:
206 1.1 cgd ktrpsig((struct ktr_psig *)m);
207 1.1 cgd break;
208 1.1 cgd case KTR_CSW:
209 1.1 cgd ktrcsw((struct ktr_csw *)m);
210 1.1 cgd break;
211 1.11 christos case KTR_EMUL:
212 1.11 christos ktremul(m, ktrlen);
213 1.11 christos break;
214 1.1 cgd }
215 1.1 cgd if (tail)
216 1.1 cgd (void)fflush(stdout);
217 1.1 cgd }
218 1.1 cgd }
219 1.1 cgd
220 1.1 cgd fread_tail(buf, size, num)
221 1.1 cgd char *buf;
222 1.1 cgd int num, size;
223 1.1 cgd {
224 1.1 cgd int i;
225 1.1 cgd
226 1.1 cgd while ((i = fread(buf, size, num, stdin)) == 0 && tail) {
227 1.1 cgd (void)sleep(1);
228 1.1 cgd clearerr(stdin);
229 1.1 cgd }
230 1.1 cgd return (i);
231 1.1 cgd }
232 1.1 cgd
233 1.1 cgd dumpheader(kth)
234 1.1 cgd struct ktr_header *kth;
235 1.1 cgd {
236 1.6 mycroft char unknown[64], *type;
237 1.6 mycroft static struct timeval prevtime;
238 1.6 mycroft struct timeval temp;
239 1.1 cgd
240 1.1 cgd switch (kth->ktr_type) {
241 1.1 cgd case KTR_SYSCALL:
242 1.1 cgd type = "CALL";
243 1.1 cgd break;
244 1.1 cgd case KTR_SYSRET:
245 1.1 cgd type = "RET ";
246 1.1 cgd break;
247 1.1 cgd case KTR_NAMEI:
248 1.1 cgd type = "NAMI";
249 1.1 cgd break;
250 1.1 cgd case KTR_GENIO:
251 1.1 cgd type = "GIO ";
252 1.1 cgd break;
253 1.1 cgd case KTR_PSIG:
254 1.1 cgd type = "PSIG";
255 1.1 cgd break;
256 1.1 cgd case KTR_CSW:
257 1.1 cgd type = "CSW";
258 1.1 cgd break;
259 1.11 christos case KTR_EMUL:
260 1.11 christos type = "EMUL";
261 1.11 christos break;
262 1.1 cgd default:
263 1.1 cgd (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type);
264 1.1 cgd type = unknown;
265 1.1 cgd }
266 1.1 cgd
267 1.10 cgd (void)printf("%6d %-8.*s ", kth->ktr_pid, MAXCOMLEN, kth->ktr_comm);
268 1.1 cgd if (timestamp) {
269 1.1 cgd if (timestamp == 2) {
270 1.5 mycroft timersub(&kth->ktr_time, &prevtime, &temp);
271 1.5 mycroft prevtime = kth->ktr_time;
272 1.5 mycroft } else
273 1.1 cgd temp = kth->ktr_time;
274 1.5 mycroft (void)printf("%ld.%06ld ", temp.tv_sec, temp.tv_usec);
275 1.1 cgd }
276 1.1 cgd (void)printf("%s ", type);
277 1.1 cgd }
278 1.1 cgd
279 1.1 cgd
280 1.1 cgd ktrsyscall(ktr)
281 1.1 cgd register struct ktr_syscall *ktr;
282 1.1 cgd {
283 1.7 cgd register argsize = ktr->ktr_argsize;
284 1.7 cgd register register_t *ap;
285 1.1 cgd char *ioctlname();
286 1.1 cgd
287 1.11 christos if (ktr->ktr_code >= current->nsysnames || ktr->ktr_code < 0)
288 1.1 cgd (void)printf("[%d]", ktr->ktr_code);
289 1.1 cgd else
290 1.11 christos (void)printf("%s", current->sysnames[ktr->ktr_code]);
291 1.7 cgd ap = (register_t *)((char *)ktr + sizeof(struct ktr_syscall));
292 1.7 cgd if (argsize) {
293 1.1 cgd char c = '(';
294 1.1 cgd if (fancy) {
295 1.1 cgd if (ktr->ktr_code == SYS_ioctl) {
296 1.1 cgd char *cp;
297 1.1 cgd if (decimal)
298 1.7 cgd (void)printf("(%ld", (long)*ap);
299 1.1 cgd else
300 1.7 cgd (void)printf("(%#lx", (long)*ap);
301 1.7 cgd ap++;
302 1.7 cgd argsize -= sizeof(register_t);
303 1.7 cgd if ((cp = ioctlname(*ap)) != NULL)
304 1.1 cgd (void)printf(",%s", cp);
305 1.1 cgd else {
306 1.1 cgd if (decimal)
307 1.7 cgd (void)printf(",%ld",
308 1.7 cgd (long)*ap);
309 1.1 cgd else
310 1.7 cgd (void)printf(",%#lx ",
311 1.7 cgd (long)*ap);
312 1.1 cgd }
313 1.1 cgd c = ',';
314 1.7 cgd ap++;
315 1.7 cgd argsize -= sizeof(register_t);
316 1.1 cgd } else if (ktr->ktr_code == SYS_ptrace) {
317 1.7 cgd if (*ap <=sizeof(ptrace_ops)/sizeof(ptrace_ops[0]) && *ap >= 0)
318 1.7 cgd (void)printf("(%s", ptrace_ops[*ap]);
319 1.1 cgd else
320 1.7 cgd (void)printf("(%ld", (long)*ap);
321 1.1 cgd c = ',';
322 1.7 cgd ap++;
323 1.7 cgd argsize -= sizeof(register_t);
324 1.1 cgd }
325 1.1 cgd }
326 1.7 cgd while (argsize) {
327 1.1 cgd if (decimal)
328 1.7 cgd (void)printf("%c%ld", c, (long)*ap);
329 1.1 cgd else
330 1.7 cgd (void)printf("%c%#lx", c, (long)*ap);
331 1.1 cgd c = ',';
332 1.7 cgd ap++;
333 1.7 cgd argsize -= sizeof(register_t);
334 1.1 cgd }
335 1.1 cgd (void)putchar(')');
336 1.1 cgd }
337 1.1 cgd (void)putchar('\n');
338 1.1 cgd }
339 1.1 cgd
340 1.1 cgd ktrsysret(ktr)
341 1.1 cgd struct ktr_sysret *ktr;
342 1.1 cgd {
343 1.1 cgd register int ret = ktr->ktr_retval;
344 1.1 cgd register int error = ktr->ktr_error;
345 1.1 cgd register int code = ktr->ktr_code;
346 1.1 cgd
347 1.11 christos if (code >= current->nsysnames || code < 0)
348 1.1 cgd (void)printf("[%d] ", code);
349 1.1 cgd else
350 1.11 christos (void)printf("%s ", current->sysnames[code]);
351 1.1 cgd
352 1.1 cgd if (error == 0) {
353 1.1 cgd if (fancy) {
354 1.1 cgd (void)printf("%d", ret);
355 1.1 cgd if (ret < 0 || ret > 9)
356 1.1 cgd (void)printf("/%#x", ret);
357 1.1 cgd } else {
358 1.1 cgd if (decimal)
359 1.1 cgd (void)printf("%d", ret);
360 1.1 cgd else
361 1.1 cgd (void)printf("%#x", ret);
362 1.1 cgd }
363 1.1 cgd } else if (error == ERESTART)
364 1.1 cgd (void)printf("RESTART");
365 1.1 cgd else if (error == EJUSTRETURN)
366 1.1 cgd (void)printf("JUSTRETURN");
367 1.1 cgd else {
368 1.1 cgd (void)printf("-1 errno %d", ktr->ktr_error);
369 1.1 cgd if (fancy)
370 1.1 cgd (void)printf(" %s", strerror(ktr->ktr_error));
371 1.1 cgd }
372 1.1 cgd (void)putchar('\n');
373 1.1 cgd }
374 1.1 cgd
375 1.1 cgd ktrnamei(cp, len)
376 1.1 cgd char *cp;
377 1.1 cgd {
378 1.1 cgd (void)printf("\"%.*s\"\n", len, cp);
379 1.1 cgd }
380 1.1 cgd
381 1.11 christos ktremul(cp, len)
382 1.11 christos char *cp;
383 1.11 christos {
384 1.11 christos char name[1024];
385 1.11 christos
386 1.11 christos if (len >= sizeof(name))
387 1.11 christos errx(1, "Emulation name too long");
388 1.11 christos
389 1.11 christos strncpy(name, cp, len);
390 1.11 christos name[len] = '\0';
391 1.11 christos (void)printf("\"%s\"\n", name);
392 1.11 christos
393 1.11 christos setemul(name);
394 1.11 christos }
395 1.11 christos
396 1.1 cgd ktrgenio(ktr, len)
397 1.1 cgd struct ktr_genio *ktr;
398 1.1 cgd {
399 1.1 cgd register int datalen = len - sizeof (struct ktr_genio);
400 1.1 cgd register char *dp = (char *)ktr + sizeof (struct ktr_genio);
401 1.1 cgd register char *cp;
402 1.1 cgd register int col = 0;
403 1.1 cgd register width;
404 1.1 cgd char visbuf[5];
405 1.1 cgd static screenwidth = 0;
406 1.1 cgd
407 1.1 cgd if (screenwidth == 0) {
408 1.1 cgd struct winsize ws;
409 1.1 cgd
410 1.1 cgd if (fancy && ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 &&
411 1.1 cgd ws.ws_col > 8)
412 1.1 cgd screenwidth = ws.ws_col;
413 1.1 cgd else
414 1.1 cgd screenwidth = 80;
415 1.1 cgd }
416 1.1 cgd printf("fd %d %s %d bytes\n", ktr->ktr_fd,
417 1.1 cgd ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen);
418 1.1 cgd if (maxdata && datalen > maxdata)
419 1.1 cgd datalen = maxdata;
420 1.1 cgd (void)printf(" \"");
421 1.1 cgd col = 8;
422 1.4 mycroft for (; datalen > 0; datalen--, dp++) {
423 1.1 cgd (void) vis(visbuf, *dp, VIS_CSTYLE, *(dp+1));
424 1.1 cgd cp = visbuf;
425 1.1 cgd /*
426 1.1 cgd * Keep track of printables and
427 1.1 cgd * space chars (like fold(1)).
428 1.1 cgd */
429 1.1 cgd if (col == 0) {
430 1.1 cgd (void)putchar('\t');
431 1.1 cgd col = 8;
432 1.1 cgd }
433 1.1 cgd switch(*cp) {
434 1.1 cgd case '\n':
435 1.1 cgd col = 0;
436 1.1 cgd (void)putchar('\n');
437 1.1 cgd continue;
438 1.1 cgd case '\t':
439 1.1 cgd width = 8 - (col&07);
440 1.1 cgd break;
441 1.1 cgd default:
442 1.1 cgd width = strlen(cp);
443 1.1 cgd }
444 1.1 cgd if (col + width > (screenwidth-2)) {
445 1.1 cgd (void)printf("\\\n\t");
446 1.1 cgd col = 8;
447 1.1 cgd }
448 1.1 cgd col += width;
449 1.1 cgd do {
450 1.1 cgd (void)putchar(*cp++);
451 1.1 cgd } while (*cp);
452 1.1 cgd }
453 1.1 cgd if (col == 0)
454 1.1 cgd (void)printf(" ");
455 1.1 cgd (void)printf("\"\n");
456 1.1 cgd }
457 1.1 cgd
458 1.1 cgd ktrpsig(psig)
459 1.1 cgd struct ktr_psig *psig;
460 1.1 cgd {
461 1.4 mycroft (void)printf("SIG%s ", sys_signame[psig->signo]);
462 1.1 cgd if (psig->action == SIG_DFL)
463 1.1 cgd (void)printf("SIG_DFL\n");
464 1.1 cgd else
465 1.7 cgd (void)printf("caught handler=0x%lx mask=0x%x code=0x%x\n",
466 1.7 cgd (u_long)psig->action, psig->mask, psig->code);
467 1.1 cgd }
468 1.1 cgd
469 1.1 cgd ktrcsw(cs)
470 1.1 cgd struct ktr_csw *cs;
471 1.1 cgd {
472 1.1 cgd (void)printf("%s %s\n", cs->out ? "stop" : "resume",
473 1.4 mycroft cs->user ? "user" : "kernel");
474 1.1 cgd }
475 1.1 cgd
476 1.1 cgd usage()
477 1.1 cgd {
478 1.4 mycroft
479 1.1 cgd (void)fprintf(stderr,
480 1.11 christos "usage: kdump [-dnlRT] [-e emulation] [-f trfile] [-m maxdata] [-t [cnis]]\n");
481 1.1 cgd exit(1);
482 1.11 christos }
483 1.11 christos
484 1.11 christos setemul(name)
485 1.11 christos char *name;
486 1.11 christos {
487 1.11 christos int i;
488 1.11 christos for (i = 0; emulations[i].name != NULL; i++)
489 1.11 christos if (strcmp(emulations[i].name, name) == 0) {
490 1.11 christos current = &emulations[i];
491 1.11 christos return;
492 1.11 christos }
493 1.11 christos warnx("Emulation `%s' unknown", name);
494 1.1 cgd }
495