Annotation of src/usr.bin/kdump/kdump.c, Revision 1.30
1.30 ! miod 1: /* $OpenBSD: kdump.c,v 1.29 2005/12/20 07:37:21 miod Exp $ */
1.4 deraadt 2:
1.1 deraadt 3: /*-
4: * Copyright (c) 1988, 1993
5: * The Regents of the University of California. All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
1.21 millert 15: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 16: * may be used to endorse or promote products derived from this software
17: * without specific prior written permission.
18: *
19: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29: * SUCH DAMAGE.
30: */
31:
32: #ifndef lint
33: static char copyright[] =
34: "@(#) Copyright (c) 1988, 1993\n\
35: The Regents of the University of California. All rights reserved.\n";
36: #endif /* not lint */
37:
38: #ifndef lint
39: #if 0
40: static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95";
41: #endif
1.30 ! miod 42: static char *rcsid = "$OpenBSD: kdump.c,v 1.29 2005/12/20 07:37:21 miod Exp $";
1.1 deraadt 43: #endif /* not lint */
44:
45: #include <sys/param.h>
46: #include <sys/time.h>
47: #include <sys/uio.h>
48: #include <sys/ktrace.h>
49: #include <sys/ioctl.h>
50: #include <sys/ptrace.h>
1.28 deraadt 51: #include <sys/sysctl.h>
1.1 deraadt 52: #define _KERNEL
53: #include <sys/errno.h>
54: #undef _KERNEL
55:
56: #include <err.h>
57: #include <signal.h>
58: #include <stdio.h>
59: #include <stdlib.h>
60: #include <string.h>
61: #include <unistd.h>
62: #include <vis.h>
63:
64: #include "ktrace.h"
1.22 deraadt 65: #include "kdump.h"
1.12 espie 66: #include "extern.h"
1.1 deraadt 67:
68: int timestamp, decimal, fancy = 1, tail, maxdata;
69: char *tracefile = DEF_TRACEFILE;
70: struct ktr_header ktr_header;
1.17 deraadt 71: pid_t pid = -1;
1.1 deraadt 72:
73: #define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
74:
75: #include <sys/syscall.h>
76:
1.25 mickey 77: #include <compat/bsdos/bsdos_syscall.h>
78: #include <compat/freebsd/freebsd_syscall.h>
79: #include <compat/netbsd/netbsd_syscall.h>
1.26 deraadt 80: #if defined(__hppa__) || defined(__m68k__)
1.25 mickey 81: #include <compat/hpux/hpux_syscall.h>
1.26 deraadt 82: #endif
1.25 mickey 83: #include <compat/ibcs2/ibcs2_syscall.h>
84: #include <compat/linux/linux_syscall.h>
85: #include <compat/osf1/osf1_syscall.h>
86: #include <compat/sunos/sunos_syscall.h>
87: #include <compat/svr4/svr4_syscall.h>
88: #include <compat/ultrix/ultrix_syscall.h>
1.1 deraadt 89:
90: #define KTRACE
1.19 mickey 91: #define PTRACE
1.7 deraadt 92: #define NFSCLIENT
93: #define NFSSERVER
94: #define SYSVSEM
95: #define SYSVMSG
96: #define SYSVSHM
97: #define LFS
1.30 ! miod 98: #define RTHREADS
1.25 mickey 99: #include <kern/syscalls.c>
1.1 deraadt 100:
1.25 mickey 101: #include <compat/bsdos/bsdos_syscalls.c>
102: #include <compat/freebsd/freebsd_syscalls.c>
103: #include <compat/netbsd/netbsd_syscalls.c>
1.26 deraadt 104: #if defined(__hppa__) || defined(__m68k__)
1.25 mickey 105: #include <compat/hpux/hpux_syscalls.c>
1.26 deraadt 106: #endif
1.25 mickey 107: #include <compat/ibcs2/ibcs2_syscalls.c>
108: #include <compat/linux/linux_syscalls.c>
109: #include <compat/osf1/osf1_syscalls.c>
110: #include <compat/sunos/sunos_syscalls.c>
111: #include <compat/svr4/svr4_syscalls.c>
112: #include <compat/ultrix/ultrix_syscalls.c>
1.1 deraadt 113: #undef KTRACE
1.19 mickey 114: #undef PTRACE
1.7 deraadt 115: #undef NFSCLIENT
116: #undef NFSSERVER
117: #undef SYSVSEM
118: #undef SYSVMSG
119: #undef SYSVSHM
120: #undef LFS
1.30 ! miod 121: #undef RTHREADS
1.1 deraadt 122:
123: struct emulation {
124: char *name; /* Emulation name */
125: char **sysnames; /* Array of system call names */
126: int nsysnames; /* Number of */
127: };
128:
129: static struct emulation emulations[] = {
1.9 deraadt 130: { "native", syscallnames, SYS_MAXSYSCALL },
1.26 deraadt 131: #if defined(__hppa__) || defined(__m68k__)
1.9 deraadt 132: { "hpux", hpux_syscallnames, HPUX_SYS_MAXSYSCALL },
1.26 deraadt 133: #endif
1.9 deraadt 134: { "ibcs2", ibcs2_syscallnames, IBCS2_SYS_MAXSYSCALL },
135: { "linux", linux_syscallnames, LINUX_SYS_MAXSYSCALL },
136: { "osf1", osf1_syscallnames, OSF1_SYS_MAXSYSCALL },
137: { "sunos", sunos_syscallnames, SUNOS_SYS_MAXSYSCALL },
138: { "svr4", svr4_syscallnames, SVR4_SYS_MAXSYSCALL },
139: { "ultrix", ultrix_syscallnames, ULTRIX_SYS_MAXSYSCALL },
140: { "bsdos", bsdos_syscallnames, BSDOS_SYS_MAXSYSCALL },
141: { "freebsd", freebsd_syscallnames, FREEBSD_SYS_MAXSYSCALL },
1.10 kstailey 142: { "netbsd", netbsd_syscallnames, NETBSD_SYS_MAXSYSCALL },
1.9 deraadt 143: { NULL, NULL, NULL }
1.1 deraadt 144: };
145:
146: struct emulation *current;
147:
148:
149: static char *ptrace_ops[] = {
150: "PT_TRACE_ME", "PT_READ_I", "PT_READ_D", "PT_READ_U",
151: "PT_WRITE_I", "PT_WRITE_D", "PT_WRITE_U", "PT_CONTINUE",
1.15 art 152: "PT_KILL", "PT_ATTACH", "PT_DETACH", "PT_IO",
1.1 deraadt 153: };
154:
1.13 millert 155: static int fread_tail(void *, int, int);
156: static void dumpheader(struct ktr_header *);
157: static void ktrcsw(struct ktr_csw *);
158: static void ktremul(char *, int);
159: static void ktrgenio(struct ktr_genio *, int);
160: static void ktrnamei(const char *, int);
161: static void ktrpsig(struct ktr_psig *);
162: static void ktrsyscall(struct ktr_syscall *);
163: static void ktrsysret(struct ktr_sysret *);
164: static void setemul(const char *);
165: static void usage(void);
1.12 espie 166:
1.1 deraadt 167: int
1.17 deraadt 168: main(int argc, char *argv[])
1.1 deraadt 169: {
1.17 deraadt 170: int ch, ktrlen, size, silent;
171: int trpoints = ALL_POINTS;
1.12 espie 172: void *m;
1.1 deraadt 173:
1.3 deraadt 174: current = &emulations[0]; /* native */
1.1 deraadt 175:
1.17 deraadt 176: while ((ch = getopt(argc, argv, "e:f:dlm:nRp:Tt:")) != -1)
1.1 deraadt 177: switch (ch) {
178: case 'e':
179: setemul(optarg);
180: break;
181: case 'f':
182: tracefile = optarg;
183: break;
184: case 'd':
185: decimal = 1;
186: break;
187: case 'l':
188: tail = 1;
189: break;
190: case 'm':
191: maxdata = atoi(optarg);
192: break;
193: case 'n':
194: fancy = 0;
195: break;
1.17 deraadt 196: case 'p':
197: pid = atoi(optarg);
198: break;
1.1 deraadt 199: case 'R':
200: timestamp = 2; /* relative timestamp */
201: break;
202: case 'T':
203: timestamp = 1;
204: break;
205: case 't':
206: trpoints = getpoints(optarg);
207: if (trpoints < 0)
208: errx(1, "unknown trace point in %s", optarg);
209: break;
210: default:
211: usage();
212: }
1.5 deraadt 213: if (argc > optind)
1.1 deraadt 214: usage();
215:
216: m = (void *)malloc(size = 1025);
217: if (m == NULL)
218: errx(1, "%s", strerror(ENOMEM));
219: if (!freopen(tracefile, "r", stdin))
220: err(1, "%s", tracefile);
221: while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) {
1.17 deraadt 222: silent = 0;
223: if (pid != -1 && pid != ktr_header.ktr_pid)
224: silent = 1;
225: if (silent == 0 && trpoints & (1<<ktr_header.ktr_type))
1.1 deraadt 226: dumpheader(&ktr_header);
227: if ((ktrlen = ktr_header.ktr_len) < 0)
228: errx(1, "bogus length 0x%x", ktrlen);
229: if (ktrlen > size) {
1.23 tedu 230: void *newm;
231:
232: newm = realloc(m, ktrlen+1);
233: if (newm == NULL)
1.1 deraadt 234: errx(1, "%s", strerror(ENOMEM));
1.23 tedu 235: m = newm;
1.1 deraadt 236: size = ktrlen;
237: }
238: if (ktrlen && fread_tail(m, ktrlen, 1) == 0)
239: errx(1, "data too short");
1.17 deraadt 240: if (silent)
241: continue;
1.1 deraadt 242: if ((trpoints & (1<<ktr_header.ktr_type)) == 0)
243: continue;
244: switch (ktr_header.ktr_type) {
245: case KTR_SYSCALL:
246: ktrsyscall((struct ktr_syscall *)m);
247: break;
248: case KTR_SYSRET:
249: ktrsysret((struct ktr_sysret *)m);
250: break;
251: case KTR_NAMEI:
252: ktrnamei(m, ktrlen);
253: break;
254: case KTR_GENIO:
255: ktrgenio((struct ktr_genio *)m, ktrlen);
256: break;
257: case KTR_PSIG:
258: ktrpsig((struct ktr_psig *)m);
259: break;
260: case KTR_CSW:
261: ktrcsw((struct ktr_csw *)m);
262: break;
263: case KTR_EMUL:
264: ktremul(m, ktrlen);
265: break;
266: }
267: if (tail)
268: (void)fflush(stdout);
269: }
1.12 espie 270: exit(0);
1.1 deraadt 271: }
272:
1.12 espie 273: static int
1.17 deraadt 274: fread_tail(void *buf, int size, int num)
1.1 deraadt 275: {
276: int i;
277:
278: while ((i = fread(buf, size, num, stdin)) == 0 && tail) {
279: (void)sleep(1);
280: clearerr(stdin);
281: }
282: return (i);
283: }
284:
1.12 espie 285: static void
1.17 deraadt 286: dumpheader(struct ktr_header *kth)
1.1 deraadt 287: {
1.17 deraadt 288: static struct timeval prevtime;
1.1 deraadt 289: char unknown[64], *type;
290: struct timeval temp;
291:
292: switch (kth->ktr_type) {
293: case KTR_SYSCALL:
294: type = "CALL";
295: break;
296: case KTR_SYSRET:
297: type = "RET ";
298: break;
299: case KTR_NAMEI:
300: type = "NAMI";
301: break;
302: case KTR_GENIO:
303: type = "GIO ";
304: break;
305: case KTR_PSIG:
306: type = "PSIG";
307: break;
308: case KTR_CSW:
309: type = "CSW";
310: break;
311: case KTR_EMUL:
312: type = "EMUL";
313: break;
314: default:
1.17 deraadt 315: (void)snprintf(unknown, sizeof unknown, "UNKNOWN(%d)",
316: kth->ktr_type);
1.1 deraadt 317: type = unknown;
318: }
319:
1.16 mpech 320: (void)printf("%6ld %-8.*s ", (long)kth->ktr_pid, MAXCOMLEN,
321: kth->ktr_comm);
1.1 deraadt 322: if (timestamp) {
323: if (timestamp == 2) {
324: timersub(&kth->ktr_time, &prevtime, &temp);
325: prevtime = kth->ktr_time;
326: } else
327: temp = kth->ktr_time;
328: (void)printf("%ld.%06ld ", temp.tv_sec, temp.tv_usec);
329: }
330: (void)printf("%s ", type);
331: }
332:
1.12 espie 333: static void
1.17 deraadt 334: ioctldecode(u_long cmd)
1.2 deraadt 335: {
336: char dirbuf[4], *dir = dirbuf;
337:
1.6 deraadt 338: if (cmd & IOC_IN)
339: *dir++ = 'W';
1.2 deraadt 340: if (cmd & IOC_OUT)
341: *dir++ = 'R';
342: *dir = '\0';
343:
344: printf(decimal ? ",_IO%s('%c',%ld" : ",_IO%s('%c',%#lx",
345: dirbuf, (cmd >> 8) & 0xff, cmd & 0xff);
346: if ((cmd & IOC_VOID) == 0)
347: printf(decimal ? ",%ld)" : ",%#lx)", (cmd >> 16) & 0xff);
348: else
349: printf(")");
350: }
1.1 deraadt 351:
1.12 espie 352: static void
1.17 deraadt 353: ktrsyscall(struct ktr_syscall *ktr)
1.1 deraadt 354: {
1.12 espie 355: int argsize = ktr->ktr_argsize;
356: register_t *ap;
1.1 deraadt 357:
358: if (ktr->ktr_code >= current->nsysnames || ktr->ktr_code < 0)
359: (void)printf("[%d]", ktr->ktr_code);
360: else
361: (void)printf("%s", current->sysnames[ktr->ktr_code]);
362: ap = (register_t *)((char *)ktr + sizeof(struct ktr_syscall));
1.27 mickey 363: (void)putchar('(');
1.1 deraadt 364: if (argsize) {
1.27 mickey 365: char c = '\0';
1.1 deraadt 366: if (fancy) {
367: if (ktr->ktr_code == SYS_ioctl) {
1.12 espie 368: const char *cp;
1.17 deraadt 369:
1.1 deraadt 370: if (decimal)
1.27 mickey 371: (void)printf("%ld", (long)*ap);
1.1 deraadt 372: else
1.27 mickey 373: (void)printf("%#lx", (long)*ap);
1.1 deraadt 374: ap++;
375: argsize -= sizeof(register_t);
376: if ((cp = ioctlname(*ap)) != NULL)
377: (void)printf(",%s", cp);
1.2 deraadt 378: else
379: ioctldecode(*ap);
1.1 deraadt 380: c = ',';
381: ap++;
382: argsize -= sizeof(register_t);
1.27 mickey 383: } else if (ktr->ktr_code == SYS___sysctl) {
384: int *np, n;
385:
386: n = ap[1];
1.28 deraadt 387: if (n > CTL_MAXNAME)
388: n = CTL_MAXNAME;
1.27 mickey 389: np = (int *)(ap + 6);
390: for (; n--; np++) {
391: if (c)
392: putchar(c);
393: printf("%d", *np);
394: c = '.';
395: }
396:
397: c = ',';
398: ap += 2;
399: argsize -= 2 * sizeof(register_t);
1.1 deraadt 400: } else if (ktr->ktr_code == SYS_ptrace) {
1.24 miod 401: if (*ap >= 0 && *ap <
1.1 deraadt 402: sizeof(ptrace_ops) / sizeof(ptrace_ops[0]))
1.27 mickey 403: (void)printf("%s", ptrace_ops[*ap]);
1.24 miod 404: else switch(*ap) {
405: #ifdef PT_GETFPREGS
406: case PT_GETFPREGS:
1.27 mickey 407: (void)printf("PT_GETFPREGS");
1.24 miod 408: break;
409: #endif
410: case PT_GETREGS:
1.27 mickey 411: (void)printf("PT_GETREGS");
1.24 miod 412: break;
413: #ifdef PT_SETFPREGS
414: case PT_SETFPREGS:
1.27 mickey 415: (void)printf("PT_SETFPREGS");
1.24 miod 416: break;
417: #endif
418: case PT_SETREGS:
1.27 mickey 419: (void)printf("PT_SETREGS");
1.24 miod 420: break;
421: #ifdef PT_STEP
422: case PT_STEP:
1.27 mickey 423: (void)printf("PT_STEP");
1.24 miod 424: break;
425: #endif
426: #ifdef PT_WCOOKIE
427: case PT_WCOOKIE:
1.27 mickey 428: (void)printf("PT_WCOOKIE");
1.24 miod 429: break;
430: #endif
431: default:
1.27 mickey 432: (void)printf("%ld", (long)*ap);
1.24 miod 433: break;
434: }
1.1 deraadt 435: c = ',';
436: ap++;
437: argsize -= sizeof(register_t);
438: }
439: }
440: while (argsize) {
1.27 mickey 441: if (c)
442: putchar(c);
1.1 deraadt 443: if (decimal)
1.27 mickey 444: (void)printf("%ld", (long)*ap);
1.1 deraadt 445: else
1.27 mickey 446: (void)printf("%#lx", (long)*ap);
1.1 deraadt 447: c = ',';
448: ap++;
449: argsize -= sizeof(register_t);
450: }
451: }
1.27 mickey 452: (void)printf(")\n");
1.1 deraadt 453: }
454:
1.12 espie 455: static void
1.17 deraadt 456: ktrsysret(struct ktr_sysret *ktr)
1.1 deraadt 457: {
1.12 espie 458: int ret = ktr->ktr_retval;
459: int error = ktr->ktr_error;
460: int code = ktr->ktr_code;
1.1 deraadt 461:
462: if (code >= current->nsysnames || code < 0)
463: (void)printf("[%d] ", code);
464: else
465: (void)printf("%s ", current->sysnames[code]);
466:
467: if (error == 0) {
468: if (fancy) {
469: (void)printf("%d", ret);
470: if (ret < 0 || ret > 9)
471: (void)printf("/%#x", ret);
472: } else {
473: if (decimal)
474: (void)printf("%d", ret);
475: else
476: (void)printf("%#x", ret);
477: }
478: } else if (error == ERESTART)
479: (void)printf("RESTART");
480: else if (error == EJUSTRETURN)
481: (void)printf("JUSTRETURN");
482: else {
483: (void)printf("-1 errno %d", ktr->ktr_error);
484: if (fancy)
485: (void)printf(" %s", strerror(ktr->ktr_error));
486: }
487: (void)putchar('\n');
488: }
489:
1.12 espie 490: static void
1.17 deraadt 491: ktrnamei(const char *cp, int len)
1.1 deraadt 492: {
493: (void)printf("\"%.*s\"\n", len, cp);
494: }
495:
1.12 espie 496: static void
1.17 deraadt 497: ktremul(char *cp, int len)
1.1 deraadt 498: {
499: char name[1024];
500:
501: if (len >= sizeof(name))
502: errx(1, "Emulation name too long");
503:
504: strncpy(name, cp, len);
505: name[len] = '\0';
506: (void)printf("\"%s\"\n", name);
507:
508: setemul(name);
509: }
510:
1.12 espie 511: static void
1.17 deraadt 512: ktrgenio(struct ktr_genio *ktr, int len)
1.1 deraadt 513: {
1.17 deraadt 514: char *dp = (char *)ktr + sizeof (struct ktr_genio);
1.12 espie 515: int datalen = len - sizeof (struct ktr_genio);
516: static int screenwidth = 0;
1.17 deraadt 517: int col = 0, width;
518: char visbuf[5], *cp;
1.1 deraadt 519:
520: if (screenwidth == 0) {
521: struct winsize ws;
522:
523: if (fancy && ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 &&
524: ws.ws_col > 8)
525: screenwidth = ws.ws_col;
526: else
527: screenwidth = 80;
528: }
529: printf("fd %d %s %d bytes\n", ktr->ktr_fd,
530: ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen);
531: if (maxdata && datalen > maxdata)
532: datalen = maxdata;
533: (void)printf(" \"");
534: col = 8;
535: for (; datalen > 0; datalen--, dp++) {
536: (void) vis(visbuf, *dp, VIS_CSTYLE, *(dp+1));
537: cp = visbuf;
1.17 deraadt 538:
1.1 deraadt 539: /*
540: * Keep track of printables and
541: * space chars (like fold(1)).
542: */
543: if (col == 0) {
544: (void)putchar('\t');
545: col = 8;
546: }
1.17 deraadt 547: switch (*cp) {
1.1 deraadt 548: case '\n':
549: col = 0;
550: (void)putchar('\n');
551: continue;
552: case '\t':
553: width = 8 - (col&07);
554: break;
555: default:
556: width = strlen(cp);
557: }
558: if (col + width > (screenwidth-2)) {
559: (void)printf("\\\n\t");
560: col = 8;
561: }
562: col += width;
563: do {
564: (void)putchar(*cp++);
565: } while (*cp);
566: }
567: if (col == 0)
568: (void)printf(" ");
569: (void)printf("\"\n");
570: }
571:
1.12 espie 572: static void
1.17 deraadt 573: ktrpsig(struct ktr_psig *psig)
1.1 deraadt 574: {
575: (void)printf("SIG%s ", sys_signame[psig->signo]);
576: if (psig->action == SIG_DFL)
1.14 deraadt 577: (void)printf("SIG_DFL code %d", psig->code);
1.1 deraadt 578: else
1.14 deraadt 579: (void)printf("caught handler=0x%lx mask=0x%x",
580: (u_long)psig->action, psig->mask);
581: switch (psig->signo) {
582: case SIGSEGV:
583: case SIGILL:
584: case SIGBUS:
585: case SIGFPE:
586: printf(" addr=%p trapno=%d", psig->si.si_addr,
587: psig->si.si_trapno);
588: break;
589: default:
590: break;
591: }
592: printf("\n");
1.1 deraadt 593: }
594:
1.12 espie 595: static void
1.17 deraadt 596: ktrcsw(struct ktr_csw *cs)
1.1 deraadt 597: {
598: (void)printf("%s %s\n", cs->out ? "stop" : "resume",
599: cs->user ? "user" : "kernel");
600: }
601:
1.12 espie 602: static void
1.17 deraadt 603: usage(void)
1.1 deraadt 604: {
605:
1.19 mickey 606: extern char *__progname;
607: fprintf(stderr, "usage: %s "
608: "[-dnlRT] [-e emulation] [-p pid] [-f trfile] [-m maxdata] "
1.20 deraadt 609: "[-t [ceinsw]]\n", __progname);
1.1 deraadt 610: exit(1);
611: }
612:
1.12 espie 613: static void
1.17 deraadt 614: setemul(const char *name)
1.1 deraadt 615: {
616: int i;
1.17 deraadt 617:
1.1 deraadt 618: for (i = 0; emulations[i].name != NULL; i++)
619: if (strcmp(emulations[i].name, name) == 0) {
620: current = &emulations[i];
621: return;
622: }
623: warnx("Emulation `%s' unknown", name);
624: }