kdump.c revision 1.13 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.12 jtc #if 0
42 1.12 jtc static char sccsid[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95";
43 1.12 jtc #endif
44 1.13 christos static char *rcsid = "$NetBSD: kdump.c,v 1.13 1996/05/13 21:12:25 christos Exp $";
45 1.1 cgd #endif /* not lint */
46 1.1 cgd
47 1.1 cgd #include <sys/param.h>
48 1.1 cgd #include <sys/errno.h>
49 1.1 cgd #include <sys/time.h>
50 1.1 cgd #include <sys/uio.h>
51 1.1 cgd #include <sys/ktrace.h>
52 1.1 cgd #include <sys/ioctl.h>
53 1.1 cgd #include <sys/ptrace.h>
54 1.8 jtc #define _KERNEL
55 1.1 cgd #include <sys/errno.h>
56 1.8 jtc #undef _KERNEL
57 1.4 mycroft
58 1.4 mycroft #include <err.h>
59 1.4 mycroft #include <signal.h>
60 1.1 cgd #include <stdio.h>
61 1.1 cgd #include <stdlib.h>
62 1.1 cgd #include <string.h>
63 1.4 mycroft #include <unistd.h>
64 1.4 mycroft #include <vis.h>
65 1.4 mycroft
66 1.1 cgd #include "ktrace.h"
67 1.1 cgd
68 1.1 cgd int timestamp, decimal, fancy = 1, tail, maxdata;
69 1.1 cgd char *tracefile = DEF_TRACEFILE;
70 1.1 cgd struct ktr_header ktr_header;
71 1.1 cgd
72 1.1 cgd #define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
73 1.1 cgd
74 1.11 christos #include <sys/syscall.h>
75 1.11 christos
76 1.11 christos #include "../../sys/compat/hpux/hpux_syscall.h"
77 1.11 christos #include "../../sys/compat/ibcs2/ibcs2_syscall.h"
78 1.11 christos #include "../../sys/compat/linux/linux_syscall.h"
79 1.11 christos #include "../../sys/compat/osf1/osf1_syscall.h"
80 1.11 christos #include "../../sys/compat/sunos/sunos_syscall.h"
81 1.11 christos #include "../../sys/compat/svr4/svr4_syscall.h"
82 1.11 christos #include "../../sys/compat/ultrix/ultrix_syscall.h"
83 1.11 christos
84 1.11 christos #define KTRACE
85 1.11 christos #include "../../sys/kern/syscalls.c"
86 1.11 christos
87 1.11 christos #include "../../sys/compat/hpux/hpux_syscalls.c"
88 1.11 christos #include "../../sys/compat/ibcs2/ibcs2_syscalls.c"
89 1.11 christos #include "../../sys/compat/linux/linux_syscalls.c"
90 1.11 christos #include "../../sys/compat/osf1/osf1_syscalls.c"
91 1.11 christos #include "../../sys/compat/sunos/sunos_syscalls.c"
92 1.11 christos #include "../../sys/compat/svr4/svr4_syscalls.c"
93 1.11 christos #include "../../sys/compat/ultrix/ultrix_syscalls.c"
94 1.11 christos #undef KTRACE
95 1.11 christos
96 1.11 christos struct emulation {
97 1.11 christos char *name; /* Emulation name */
98 1.11 christos char **sysnames; /* Array of system call names */
99 1.11 christos int nsysnames; /* Number of */
100 1.11 christos };
101 1.11 christos
102 1.11 christos static struct emulation emulations[] = {
103 1.11 christos { "netbsd", syscallnames, SYS_MAXSYSCALL },
104 1.11 christos { "hpux", hpux_syscallnames, HPUX_SYS_MAXSYSCALL },
105 1.11 christos { "ibcs2", ibcs2_syscallnames, IBCS2_SYS_MAXSYSCALL },
106 1.11 christos { "linux", linux_syscallnames, LINUX_SYS_MAXSYSCALL },
107 1.11 christos { "osf1", osf1_syscallnames, OSF1_SYS_MAXSYSCALL },
108 1.11 christos { "sunos", sunos_syscallnames, SUNOS_SYS_MAXSYSCALL },
109 1.11 christos { "svr4", svr4_syscallnames, SVR4_SYS_MAXSYSCALL },
110 1.11 christos { "ultrix", ultrix_syscallnames, ULTRIX_SYS_MAXSYSCALL },
111 1.11 christos { NULL, NULL, NULL }
112 1.11 christos };
113 1.11 christos
114 1.11 christos struct emulation *current;
115 1.11 christos
116 1.11 christos
117 1.11 christos static char *ptrace_ops[] = {
118 1.11 christos "PT_TRACE_ME", "PT_READ_I", "PT_READ_D", "PT_READ_U",
119 1.11 christos "PT_WRITE_I", "PT_WRITE_D", "PT_WRITE_U", "PT_CONTINUE",
120 1.11 christos "PT_KILL", "PT_ATTACH", "PT_DETACH",
121 1.11 christos };
122 1.11 christos
123 1.4 mycroft int
124 1.1 cgd main(argc, argv)
125 1.1 cgd int argc;
126 1.1 cgd char *argv[];
127 1.1 cgd {
128 1.1 cgd int ch, ktrlen, size;
129 1.1 cgd register void *m;
130 1.1 cgd int trpoints = ALL_POINTS;
131 1.1 cgd
132 1.11 christos current = &emulations[0]; /* NetBSD */
133 1.11 christos
134 1.11 christos while ((ch = getopt(argc, argv, "e:f:dlm:nRTt:")) != -1)
135 1.4 mycroft switch (ch) {
136 1.11 christos case 'e':
137 1.11 christos setemul(optarg);
138 1.11 christos break;
139 1.1 cgd case 'f':
140 1.1 cgd tracefile = optarg;
141 1.1 cgd break;
142 1.1 cgd case 'd':
143 1.1 cgd decimal = 1;
144 1.1 cgd break;
145 1.1 cgd case 'l':
146 1.1 cgd tail = 1;
147 1.1 cgd break;
148 1.1 cgd case 'm':
149 1.1 cgd maxdata = atoi(optarg);
150 1.1 cgd break;
151 1.1 cgd case 'n':
152 1.1 cgd fancy = 0;
153 1.1 cgd break;
154 1.1 cgd case 'R':
155 1.1 cgd timestamp = 2; /* relative timestamp */
156 1.1 cgd break;
157 1.1 cgd case 'T':
158 1.1 cgd timestamp = 1;
159 1.1 cgd break;
160 1.1 cgd case 't':
161 1.1 cgd trpoints = getpoints(optarg);
162 1.4 mycroft if (trpoints < 0)
163 1.4 mycroft errx(1, "unknown trace point in %s", optarg);
164 1.1 cgd break;
165 1.1 cgd default:
166 1.1 cgd usage();
167 1.1 cgd }
168 1.1 cgd argv += optind;
169 1.1 cgd argc -= optind;
170 1.1 cgd
171 1.1 cgd if (argc > 1)
172 1.1 cgd usage();
173 1.1 cgd
174 1.1 cgd m = (void *)malloc(size = 1025);
175 1.4 mycroft if (m == NULL)
176 1.4 mycroft errx(1, "%s", strerror(ENOMEM));
177 1.4 mycroft if (!freopen(tracefile, "r", stdin))
178 1.4 mycroft err(1, "%s", tracefile);
179 1.1 cgd while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) {
180 1.1 cgd if (trpoints & (1<<ktr_header.ktr_type))
181 1.1 cgd dumpheader(&ktr_header);
182 1.4 mycroft if ((ktrlen = ktr_header.ktr_len) < 0)
183 1.4 mycroft errx(1, "bogus length 0x%x", ktrlen);
184 1.1 cgd if (ktrlen > size) {
185 1.1 cgd m = (void *)realloc(m, ktrlen+1);
186 1.4 mycroft if (m == NULL)
187 1.4 mycroft errx(1, "%s", strerror(ENOMEM));
188 1.1 cgd size = ktrlen;
189 1.1 cgd }
190 1.4 mycroft if (ktrlen && fread_tail(m, ktrlen, 1) == 0)
191 1.4 mycroft errx(1, "data too short");
192 1.1 cgd if ((trpoints & (1<<ktr_header.ktr_type)) == 0)
193 1.1 cgd continue;
194 1.1 cgd switch (ktr_header.ktr_type) {
195 1.1 cgd case KTR_SYSCALL:
196 1.1 cgd ktrsyscall((struct ktr_syscall *)m);
197 1.1 cgd break;
198 1.1 cgd case KTR_SYSRET:
199 1.1 cgd ktrsysret((struct ktr_sysret *)m);
200 1.1 cgd break;
201 1.1 cgd case KTR_NAMEI:
202 1.1 cgd ktrnamei(m, ktrlen);
203 1.1 cgd break;
204 1.1 cgd case KTR_GENIO:
205 1.1 cgd ktrgenio((struct ktr_genio *)m, ktrlen);
206 1.1 cgd break;
207 1.1 cgd case KTR_PSIG:
208 1.1 cgd ktrpsig((struct ktr_psig *)m);
209 1.1 cgd break;
210 1.1 cgd case KTR_CSW:
211 1.1 cgd ktrcsw((struct ktr_csw *)m);
212 1.1 cgd break;
213 1.11 christos case KTR_EMUL:
214 1.11 christos ktremul(m, ktrlen);
215 1.11 christos break;
216 1.1 cgd }
217 1.1 cgd if (tail)
218 1.1 cgd (void)fflush(stdout);
219 1.1 cgd }
220 1.1 cgd }
221 1.1 cgd
222 1.1 cgd fread_tail(buf, size, num)
223 1.1 cgd char *buf;
224 1.1 cgd int num, size;
225 1.1 cgd {
226 1.1 cgd int i;
227 1.1 cgd
228 1.1 cgd while ((i = fread(buf, size, num, stdin)) == 0 && tail) {
229 1.1 cgd (void)sleep(1);
230 1.1 cgd clearerr(stdin);
231 1.1 cgd }
232 1.1 cgd return (i);
233 1.1 cgd }
234 1.1 cgd
235 1.1 cgd dumpheader(kth)
236 1.1 cgd struct ktr_header *kth;
237 1.1 cgd {
238 1.6 mycroft char unknown[64], *type;
239 1.6 mycroft static struct timeval prevtime;
240 1.6 mycroft struct timeval temp;
241 1.1 cgd
242 1.1 cgd switch (kth->ktr_type) {
243 1.1 cgd case KTR_SYSCALL:
244 1.1 cgd type = "CALL";
245 1.1 cgd break;
246 1.1 cgd case KTR_SYSRET:
247 1.1 cgd type = "RET ";
248 1.1 cgd break;
249 1.1 cgd case KTR_NAMEI:
250 1.1 cgd type = "NAMI";
251 1.1 cgd break;
252 1.1 cgd case KTR_GENIO:
253 1.1 cgd type = "GIO ";
254 1.1 cgd break;
255 1.1 cgd case KTR_PSIG:
256 1.1 cgd type = "PSIG";
257 1.1 cgd break;
258 1.1 cgd case KTR_CSW:
259 1.1 cgd type = "CSW";
260 1.1 cgd break;
261 1.11 christos case KTR_EMUL:
262 1.11 christos type = "EMUL";
263 1.11 christos break;
264 1.1 cgd default:
265 1.1 cgd (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type);
266 1.1 cgd type = unknown;
267 1.1 cgd }
268 1.1 cgd
269 1.10 cgd (void)printf("%6d %-8.*s ", kth->ktr_pid, MAXCOMLEN, kth->ktr_comm);
270 1.1 cgd if (timestamp) {
271 1.1 cgd if (timestamp == 2) {
272 1.5 mycroft timersub(&kth->ktr_time, &prevtime, &temp);
273 1.5 mycroft prevtime = kth->ktr_time;
274 1.5 mycroft } else
275 1.1 cgd temp = kth->ktr_time;
276 1.5 mycroft (void)printf("%ld.%06ld ", temp.tv_sec, temp.tv_usec);
277 1.1 cgd }
278 1.1 cgd (void)printf("%s ", type);
279 1.1 cgd }
280 1.1 cgd
281 1.13 christos void
282 1.13 christos ioctldecode(cmd)
283 1.13 christos u_long cmd;
284 1.13 christos {
285 1.13 christos char dirbuf[4], *dir = dirbuf;
286 1.13 christos
287 1.13 christos if (cmd & IOC_OUT)
288 1.13 christos *dir++ = 'W';
289 1.13 christos if (cmd & IOC_IN)
290 1.13 christos *dir++ = 'R';
291 1.13 christos *dir = '\0';
292 1.13 christos
293 1.13 christos printf(decimal ? ",_IO%s('%c',%ld" : ",_IO%s('%c',%#lx",
294 1.13 christos dirbuf, (cmd >> 8) & 0xff, cmd & 0xff);
295 1.13 christos if ((cmd & IOC_VOID) == 0)
296 1.13 christos printf(decimal ? ",%ld)" : ",%#lx)", (cmd >> 16) & 0xff);
297 1.13 christos else
298 1.13 christos printf(")");
299 1.13 christos }
300 1.1 cgd
301 1.1 cgd ktrsyscall(ktr)
302 1.1 cgd register struct ktr_syscall *ktr;
303 1.1 cgd {
304 1.7 cgd register argsize = ktr->ktr_argsize;
305 1.7 cgd register register_t *ap;
306 1.1 cgd char *ioctlname();
307 1.1 cgd
308 1.11 christos if (ktr->ktr_code >= current->nsysnames || ktr->ktr_code < 0)
309 1.1 cgd (void)printf("[%d]", ktr->ktr_code);
310 1.1 cgd else
311 1.11 christos (void)printf("%s", current->sysnames[ktr->ktr_code]);
312 1.7 cgd ap = (register_t *)((char *)ktr + sizeof(struct ktr_syscall));
313 1.7 cgd if (argsize) {
314 1.1 cgd char c = '(';
315 1.1 cgd if (fancy) {
316 1.1 cgd if (ktr->ktr_code == SYS_ioctl) {
317 1.1 cgd char *cp;
318 1.1 cgd if (decimal)
319 1.7 cgd (void)printf("(%ld", (long)*ap);
320 1.1 cgd else
321 1.7 cgd (void)printf("(%#lx", (long)*ap);
322 1.7 cgd ap++;
323 1.7 cgd argsize -= sizeof(register_t);
324 1.7 cgd if ((cp = ioctlname(*ap)) != NULL)
325 1.1 cgd (void)printf(",%s", cp);
326 1.13 christos else
327 1.13 christos ioctldecode(*ap);
328 1.1 cgd c = ',';
329 1.7 cgd ap++;
330 1.7 cgd argsize -= sizeof(register_t);
331 1.1 cgd } else if (ktr->ktr_code == SYS_ptrace) {
332 1.12 jtc if (*ap >= 0 && *ap <=
333 1.12 jtc sizeof(ptrace_ops) / sizeof(ptrace_ops[0]))
334 1.7 cgd (void)printf("(%s", ptrace_ops[*ap]);
335 1.1 cgd else
336 1.7 cgd (void)printf("(%ld", (long)*ap);
337 1.1 cgd c = ',';
338 1.7 cgd ap++;
339 1.7 cgd argsize -= sizeof(register_t);
340 1.1 cgd }
341 1.1 cgd }
342 1.7 cgd while (argsize) {
343 1.1 cgd if (decimal)
344 1.7 cgd (void)printf("%c%ld", c, (long)*ap);
345 1.1 cgd else
346 1.7 cgd (void)printf("%c%#lx", c, (long)*ap);
347 1.1 cgd c = ',';
348 1.7 cgd ap++;
349 1.7 cgd argsize -= sizeof(register_t);
350 1.1 cgd }
351 1.1 cgd (void)putchar(')');
352 1.1 cgd }
353 1.1 cgd (void)putchar('\n');
354 1.1 cgd }
355 1.1 cgd
356 1.1 cgd ktrsysret(ktr)
357 1.1 cgd struct ktr_sysret *ktr;
358 1.1 cgd {
359 1.1 cgd register int ret = ktr->ktr_retval;
360 1.1 cgd register int error = ktr->ktr_error;
361 1.1 cgd register int code = ktr->ktr_code;
362 1.1 cgd
363 1.11 christos if (code >= current->nsysnames || code < 0)
364 1.1 cgd (void)printf("[%d] ", code);
365 1.1 cgd else
366 1.11 christos (void)printf("%s ", current->sysnames[code]);
367 1.1 cgd
368 1.1 cgd if (error == 0) {
369 1.1 cgd if (fancy) {
370 1.1 cgd (void)printf("%d", ret);
371 1.1 cgd if (ret < 0 || ret > 9)
372 1.1 cgd (void)printf("/%#x", ret);
373 1.1 cgd } else {
374 1.1 cgd if (decimal)
375 1.1 cgd (void)printf("%d", ret);
376 1.1 cgd else
377 1.1 cgd (void)printf("%#x", ret);
378 1.1 cgd }
379 1.1 cgd } else if (error == ERESTART)
380 1.1 cgd (void)printf("RESTART");
381 1.1 cgd else if (error == EJUSTRETURN)
382 1.1 cgd (void)printf("JUSTRETURN");
383 1.1 cgd else {
384 1.1 cgd (void)printf("-1 errno %d", ktr->ktr_error);
385 1.1 cgd if (fancy)
386 1.1 cgd (void)printf(" %s", strerror(ktr->ktr_error));
387 1.1 cgd }
388 1.1 cgd (void)putchar('\n');
389 1.1 cgd }
390 1.1 cgd
391 1.1 cgd ktrnamei(cp, len)
392 1.1 cgd char *cp;
393 1.1 cgd {
394 1.1 cgd (void)printf("\"%.*s\"\n", len, cp);
395 1.1 cgd }
396 1.1 cgd
397 1.11 christos ktremul(cp, len)
398 1.11 christos char *cp;
399 1.11 christos {
400 1.11 christos char name[1024];
401 1.11 christos
402 1.11 christos if (len >= sizeof(name))
403 1.11 christos errx(1, "Emulation name too long");
404 1.11 christos
405 1.11 christos strncpy(name, cp, len);
406 1.11 christos name[len] = '\0';
407 1.11 christos (void)printf("\"%s\"\n", name);
408 1.11 christos
409 1.11 christos setemul(name);
410 1.11 christos }
411 1.11 christos
412 1.1 cgd ktrgenio(ktr, len)
413 1.1 cgd struct ktr_genio *ktr;
414 1.1 cgd {
415 1.1 cgd register int datalen = len - sizeof (struct ktr_genio);
416 1.1 cgd register char *dp = (char *)ktr + sizeof (struct ktr_genio);
417 1.1 cgd register char *cp;
418 1.1 cgd register int col = 0;
419 1.1 cgd register width;
420 1.1 cgd char visbuf[5];
421 1.1 cgd static screenwidth = 0;
422 1.1 cgd
423 1.1 cgd if (screenwidth == 0) {
424 1.1 cgd struct winsize ws;
425 1.1 cgd
426 1.1 cgd if (fancy && ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 &&
427 1.1 cgd ws.ws_col > 8)
428 1.1 cgd screenwidth = ws.ws_col;
429 1.1 cgd else
430 1.1 cgd screenwidth = 80;
431 1.1 cgd }
432 1.1 cgd printf("fd %d %s %d bytes\n", ktr->ktr_fd,
433 1.1 cgd ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen);
434 1.1 cgd if (maxdata && datalen > maxdata)
435 1.1 cgd datalen = maxdata;
436 1.1 cgd (void)printf(" \"");
437 1.1 cgd col = 8;
438 1.4 mycroft for (; datalen > 0; datalen--, dp++) {
439 1.1 cgd (void) vis(visbuf, *dp, VIS_CSTYLE, *(dp+1));
440 1.1 cgd cp = visbuf;
441 1.1 cgd /*
442 1.1 cgd * Keep track of printables and
443 1.1 cgd * space chars (like fold(1)).
444 1.1 cgd */
445 1.1 cgd if (col == 0) {
446 1.1 cgd (void)putchar('\t');
447 1.1 cgd col = 8;
448 1.1 cgd }
449 1.1 cgd switch(*cp) {
450 1.1 cgd case '\n':
451 1.1 cgd col = 0;
452 1.1 cgd (void)putchar('\n');
453 1.1 cgd continue;
454 1.1 cgd case '\t':
455 1.1 cgd width = 8 - (col&07);
456 1.1 cgd break;
457 1.1 cgd default:
458 1.1 cgd width = strlen(cp);
459 1.1 cgd }
460 1.1 cgd if (col + width > (screenwidth-2)) {
461 1.1 cgd (void)printf("\\\n\t");
462 1.1 cgd col = 8;
463 1.1 cgd }
464 1.1 cgd col += width;
465 1.1 cgd do {
466 1.1 cgd (void)putchar(*cp++);
467 1.1 cgd } while (*cp);
468 1.1 cgd }
469 1.1 cgd if (col == 0)
470 1.1 cgd (void)printf(" ");
471 1.1 cgd (void)printf("\"\n");
472 1.1 cgd }
473 1.1 cgd
474 1.1 cgd ktrpsig(psig)
475 1.1 cgd struct ktr_psig *psig;
476 1.1 cgd {
477 1.4 mycroft (void)printf("SIG%s ", sys_signame[psig->signo]);
478 1.1 cgd if (psig->action == SIG_DFL)
479 1.1 cgd (void)printf("SIG_DFL\n");
480 1.1 cgd else
481 1.7 cgd (void)printf("caught handler=0x%lx mask=0x%x code=0x%x\n",
482 1.7 cgd (u_long)psig->action, psig->mask, psig->code);
483 1.1 cgd }
484 1.1 cgd
485 1.1 cgd ktrcsw(cs)
486 1.1 cgd struct ktr_csw *cs;
487 1.1 cgd {
488 1.1 cgd (void)printf("%s %s\n", cs->out ? "stop" : "resume",
489 1.4 mycroft cs->user ? "user" : "kernel");
490 1.1 cgd }
491 1.1 cgd
492 1.1 cgd usage()
493 1.1 cgd {
494 1.4 mycroft
495 1.1 cgd (void)fprintf(stderr,
496 1.11 christos "usage: kdump [-dnlRT] [-e emulation] [-f trfile] [-m maxdata] [-t [cnis]]\n");
497 1.1 cgd exit(1);
498 1.11 christos }
499 1.11 christos
500 1.11 christos setemul(name)
501 1.11 christos char *name;
502 1.11 christos {
503 1.11 christos int i;
504 1.11 christos for (i = 0; emulations[i].name != NULL; i++)
505 1.11 christos if (strcmp(emulations[i].name, name) == 0) {
506 1.11 christos current = &emulations[i];
507 1.11 christos return;
508 1.11 christos }
509 1.11 christos warnx("Emulation `%s' unknown", name);
510 1.1 cgd }
511