1 /* $NetBSD: kdump.c,v 1.103 2009/04/12 11:23:12 lukem Exp $ */
4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
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
32 #include <sys/cdefs.h>
34 __COPYRIGHT("@(#) Copyright (c) 1988, 1993\
35 The Regents of the University of California. All rights reserved.");
40 static char sccsid
[] = "@(#)kdump.c 8.4 (Berkeley) 4/28/95";
42 __RCSID("$NetBSD: kdump.c,v 1.103 2009/04/12 11:23:12 lukem Exp $");
46 #include <sys/param.h>
48 #include <sys/errno.h>
52 #include <sys/ktrace.h>
53 #include <sys/ioctl.h>
54 #include <sys/ptrace.h>
69 #include <sys/syscall.h>
71 static int timestamp
, decimal
, plain
, tail
, maxdata
= -1, numeric
;
72 static int word_size
= 0;
73 static pid_t do_pid
= -1;
74 static const char *tracefile
= NULL
;
75 static struct ktr_header ktr_header
;
76 static int emul_changed
= 0;
78 #define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
79 #define small(v) (((long)(v) >= 0) && ((long)(v) < 10))
81 static const char * const ptrace_ops
[] = {
82 "PT_TRACE_ME", "PT_READ_I", "PT_READ_D", "PT_READ_U",
83 "PT_WRITE_I", "PT_WRITE_D", "PT_WRITE_U", "PT_CONTINUE",
84 "PT_KILL", "PT_ATTACH", "PT_DETACH", "PT_IO",
85 "PT_DUMPCORE", "PT_LWPINFO", "PT_SYSCALL",
88 #ifdef PT_MACHDEP_STRINGS
89 static const char * const ptrace_machdep_ops
[] = { PT_MACHDEP_STRINGS
};
92 static const char * const linux_ptrace_ops
[] = {
94 "PTRACE_PEEKTEXT", "PTRACE_PEEKDATA", "PTRACE_PEEKUSER",
95 "PTRACE_POKETEXT", "PTRACE_POKEDATA", "PTRACE_POKEUSER",
96 "PTRACE_CONT", "PTRACE_KILL", "PTRACE_SINGLESTEP",
98 "PTRACE_GETREGS", "PTRACE_SETREGS", "PTRACE_GETFPREGS",
99 "PTRACE_SETFPREGS", "PTRACE_ATTACH", "PTRACE_DETACH",
100 NULL
, NULL
, NULL
, NULL
, NULL
, NULL
,
104 int main(int, char **);
105 static int fread_tail(void *, size_t, size_t);
106 static int dumpheader(struct ktr_header
*);
107 static void output_long(u_long
, int);
108 static void ioctldecode(u_long
);
109 static void ktrsyscall(struct ktr_syscall
*);
110 static void ktrsysret(struct ktr_sysret
*, int);
111 static void ktrnamei(char *, int);
112 static void ktremul(char *, int, int);
113 static void ktrgenio(struct ktr_genio
*, int);
114 static void ktrpsig(void *, int);
115 static void ktrcsw(struct ktr_csw
*);
116 static void ktruser(struct ktr_user
*, int);
117 static void ktrmmsg(struct ktr_mmsg
*, int);
118 static void ktrmool(struct ktr_mool
*, int);
119 static void ktrmib(int *, int);
120 static void usage(void) __dead
;
121 static void eprint(int);
122 static void rprint(register_t
);
123 static const char *signame(long, int);
124 static void hexdump_buf(const void *, int, int);
125 static void visdump_buf(const void *, int, int);
128 main(int argc
, char **argv
)
130 int ch
, ktrlen
, size
;
134 const char *emul_name
= "netbsd";
138 setprogname(argv
[0]);
140 if (strcmp(getprogname(), "ioctlname") == 0) {
143 while ((ch
= getopt(argc
, argv
, "e:")) != -1)
152 setemul(emul_name
, 0, 0);
159 for (i
= 0; i
< argc
; i
++) {
160 ioctldecode(strtoul(argv
[i
], NULL
, 0));
166 while ((ch
= getopt(argc
, argv
, "e:f:dlm:Nnp:RTt:xX:")) != -1) {
169 emul_name
= strdup(optarg
); /* it's safer to copy it */
181 do_pid
= strtoul(optarg
, &cp
, 0);
183 errx(1,"invalid number %s", optarg
);
186 maxdata
= strtoul(optarg
, &cp
, 0);
188 errx(1,"invalid number %s", optarg
);
197 timestamp
= 2; /* relative timestamp */
204 trpoints
= getpoints(trpoints
, optarg
);
206 errx(1, "unknown trace point in %s", optarg
);
212 word_size
= strtoul(optarg
, &cp
, 0);
213 if (*cp
!= 0 || word_size
& (word_size
- 1) ||
214 word_size
> 16 || word_size
<= 0)
215 errx(1, "argument to -X must be "
226 trpoints
= ALL_POINTS
;
228 if (tracefile
== NULL
) {
234 tracefile
= DEF_TRACEFILE
;
240 setemul(emul_name
, 0, 0);
243 m
= malloc(size
= 1024);
245 errx(1, "malloc: %s", strerror(ENOMEM
));
246 if (!freopen(tracefile
, "r", stdin
))
247 err(1, "%s", tracefile
);
248 while (fread_tail(&ktr_header
, sizeof(struct ktr_header
), 1)) {
249 if (trpoints
& (1 << ktr_header
.ktr_type
) &&
250 (do_pid
== -1 || ktr_header
.ktr_pid
== do_pid
))
251 col
= dumpheader(&ktr_header
);
254 if ((ktrlen
= ktr_header
.ktr_len
) < 0)
255 errx(1, "bogus length 0x%x", ktrlen
);
257 while (ktrlen
> size
)
259 m
= realloc(m
, size
);
261 errx(1, "realloc: %s", strerror(ENOMEM
));
263 if (ktrlen
&& fread_tail(m
, ktrlen
, 1) == 0)
264 errx(1, "data too short");
268 /* update context to match currently processed record */
269 ectx_sanify(ktr_header
.ktr_pid
);
271 switch (ktr_header
.ktr_type
) {
276 ktrsysret(m
, ktrlen
);
291 ktremul(m
, ktrlen
, size
);
304 visdump_buf(m
, ktrlen
, col
);
311 hexdump_buf(m
, ktrlen
, word_size
? word_size
: 1);
314 (void)fflush(stdout
);
320 fread_tail(void *buf
, size_t num
, size_t size
)
324 while ((i
= fread(buf
, size
, num
, stdin
)) == 0 && tail
) {
332 dumpheader(struct ktr_header
*kth
)
340 static union holdtime prevtime
;
344 switch (kth
->ktr_type
) {
388 (void)snprintf(unknown
, sizeof(unknown
), "UNKNOWN(%d)",
393 col
= printf("%6d ", kth
->ktr_pid
);
394 if (kth
->ktr_version
> KTRFACv0
)
395 col
+= printf("%6d ", kth
->ktr_lid
);
396 col
+= printf("%-8.*s ", MAXCOMLEN
, kth
->ktr_comm
);
399 if (timestamp
== 2) {
400 switch (kth
->ktr_version
) {
401 case KTRFAC_VERSION(KTRFACv0
):
402 if (prevtime
.tv
.tv_sec
== 0)
403 temp
.tv
.tv_sec
= temp
.tv
.tv_usec
= 0;
405 timersub(&kth
->ktr_otv
,
406 &prevtime
.tv
, &temp
.tv
);
407 prevtime
.tv
.tv_sec
= kth
->ktr_otv
.tv_sec
;
408 prevtime
.tv
.tv_usec
= kth
->ktr_otv
.tv_usec
;
410 case KTRFAC_VERSION(KTRFACv1
):
411 if (prevtime
.ts
.tv_sec
== 0)
412 temp
.ts
.tv_sec
= temp
.ts
.tv_nsec
= 0;
414 timespecsub(&kth
->ktr_ots
,
415 &prevtime
.ts
, &temp
.ts
);
416 prevtime
.ts
.tv_sec
= kth
->ktr_ots
.tv_sec
;
417 prevtime
.ts
.tv_nsec
= kth
->ktr_ots
.tv_nsec
;
419 case KTRFAC_VERSION(KTRFACv2
):
420 if (prevtime
.ts
.tv_sec
== 0)
421 temp
.ts
.tv_sec
= temp
.ts
.tv_nsec
= 0;
423 timespecsub(&kth
->ktr_ts
,
424 &prevtime
.ts
, &temp
.ts
);
425 prevtime
.ts
.tv_sec
= kth
->ktr_ts
.tv_sec
;
426 prevtime
.ts
.tv_nsec
= kth
->ktr_ts
.tv_nsec
;
432 switch (kth
->ktr_version
) {
433 case KTRFAC_VERSION(KTRFACv0
):
434 temp
.tv
.tv_sec
= kth
->ktr_otv
.tv_sec
;
435 temp
.tv
.tv_usec
= kth
->ktr_otv
.tv_usec
;
437 case KTRFAC_VERSION(KTRFACv1
):
438 temp
.ts
.tv_sec
= kth
->ktr_ots
.tv_sec
;
439 temp
.ts
.tv_nsec
= kth
->ktr_ots
.tv_nsec
;
441 case KTRFAC_VERSION(KTRFACv2
):
442 temp
.ts
.tv_sec
= kth
->ktr_ts
.tv_sec
;
443 temp
.ts
.tv_nsec
= kth
->ktr_ts
.tv_nsec
;
447 err(1, "Unsupported ktrace version %x\n",
451 if (kth
->ktr_version
== KTRFACv0
)
452 col
+= printf("%lld.%06ld ",
453 (long long)temp
.tv
.tv_sec
, (long)temp
.tv
.tv_usec
);
455 col
+= printf("%lld.%09ld ",
456 (long long)temp
.ts
.tv_sec
, (long)temp
.ts
.tv_nsec
);
458 col
+= printf("%-4s ", type
);
463 output_long(u_long it
, int as_x
)
465 if (cur_emul
->flags
& EMUL_FLAG_NETBSD32
)
466 printf(as_x
? "%#x" : "%d", (u_int
)it
);
468 printf(as_x
? "%#lx" : "%ld", it
);
472 ioctldecode(u_long cmd
)
474 char dirbuf
[4], *dir
= dirbuf
;
483 c
= (cmd
>> 8) & 0xff;
485 printf("_IO%s('%c',", dirbuf
, c
);
487 printf("_IO%s(0x%02x,", dirbuf
, c
);
488 output_long(cmd
& 0xff, decimal
== 0);
489 if ((cmd
& IOC_VOID
) == 0) {
491 output_long(IOCPARM_LEN(cmd
), decimal
== 0);
497 ktrsyscall(struct ktr_syscall
*ktr
)
500 const struct emulation
*emul
= cur_emul
;
504 const char *sys_name
;
506 argcount
= ktr
->ktr_argsize
/ sizeof (*ap
);
511 ((ktr
->ktr_code
>= emul
->nsysnames
|| ktr
->ktr_code
< 0) &&
512 mach_traps_dispatch(&ktr
->ktr_code
, &emul
) == 0)) {
514 (void)printf("[%d]", ktr
->ktr_code
);
516 sys_name
= emul
->sysnames
[ktr
->ktr_code
];
517 (void)printf("%s", sys_name
);
520 #define NETBSD32_ "netbsd32_"
521 if (cur_emul
->flags
& EMUL_FLAG_NETBSD32
) {
522 size_t len
= strlen(NETBSD32_
);
523 if (strncmp(sys_name
, NETBSD32_
, len
) == 0)
529 ap
= (register_t
*)((char *)ktr
+ sizeof(struct ktr_syscall
));
535 } else if (strcmp(sys_name
, "exit") == 0) {
538 } else if (strcmp(sys_name
, "ioctl") == 0 && argcount
>= 2) {
540 output_long((long)*ap
, !(decimal
|| small(*ap
)));
543 if ((cp
= ioctlname(*ap
)) != NULL
)
544 (void)printf(",%s", cp
);
553 } else if ((strstr(sys_name
, "sigaction") != NULL
||
554 strstr(sys_name
, "sigvec") != NULL
) && argcount
>= 1) {
555 (void)printf("(SIG%s", signame(ap
[0], 1));
560 } else if ((strcmp(sys_name
, "kill") == 0 ||
561 strcmp(sys_name
, "killpg") == 0) && argcount
>= 2) {
563 output_long((long)ap
[0], !(decimal
|| small(*ap
)));
564 (void)printf(", SIG%s", signame(ap
[1], 1));
569 } else if (strcmp(sys_name
, "ptrace") == 0 && argcount
>= 1) {
571 if (strcmp(emul
->name
, "linux") == 0 ||
572 strcmp(emul
->name
, "linux32") == 0) {
573 if ((long)*ap
>= 0 && *ap
<
574 (register_t
)(sizeof(linux_ptrace_ops
) /
575 sizeof(linux_ptrace_ops
[0])))
577 linux_ptrace_ops
[*ap
]);
579 output_long((long)*ap
, 1);
581 if ((long)*ap
>= 0 && *ap
<
582 (register_t
)(sizeof(ptrace_ops
) / sizeof(ptrace_ops
[0])))
583 (void)printf("%s", ptrace_ops
[*ap
]);
584 #ifdef PT_MACHDEP_STRINGS
585 else if (*ap
>= PT_FIRSTMACH
&&
587 (register_t
)(sizeof(ptrace_machdep_ops
) /
588 sizeof(ptrace_machdep_ops
[0])))
589 (void)printf("%s", ptrace_machdep_ops
[*ap
- PT_FIRSTMACH
]);
592 output_long((long)*ap
, 1);
599 while (argcount
> 0) {
601 output_long((long)*ap
, !(decimal
|| small(*ap
)));
612 ktrsysret(struct ktr_sysret
*ktr
, int len
)
614 const struct emulation
*emul
;
615 int error
= ktr
->ktr_error
;
616 int code
= ktr
->ktr_code
;
619 /* In order to get system call name right in execve return */
625 if (numeric
|| ((code
>= emul
->nsysnames
|| code
< 0 || plain
> 1) &&
626 mach_traps_dispatch(&code
, &emul
) == 0))
627 (void)printf("[%d] ", code
);
629 (void)printf("%s ", emul
->sysnames
[code
]);
633 rprint(ktr
->ktr_retval
);
634 if (len
> (int)offsetof(struct ktr_sysret
, ktr_retval_1
) &&
635 ktr
->ktr_retval_1
!= 0) {
637 rprint(ktr
->ktr_retval_1
);
649 rprint(register_t ret
)
653 (void)printf("%ld", (long)ret
);
655 (void)printf("/%#lx", (long)ret
);
657 if (decimal
|| small(ret
))
658 (void)printf("%ld", (long)ret
);
660 (void)printf("%#lx", (long)ret
);
665 * We print the original emulation's error numerically, but we
666 * translate it to netbsd to print it symbolically.
673 if (cur_emul
->errnomap
) {
675 /* No remapping for ERESTART and EJUSTRETURN */
676 /* Kludge for linux that has negative error numbers */
677 if (cur_emul
->errnomap
[2] > 0 && e
< 0)
680 for (i
= 0; i
< cur_emul
->nerrnomap
; i
++)
681 if (e
== cur_emul
->errnomap
[i
])
684 if (i
== cur_emul
->nerrnomap
) {
685 printf("-1 unknown errno %d", e
);
693 (void)printf("RESTART");
697 (void)printf("JUSTRETURN");
701 (void)printf("-1 errno %d", e
);
703 (void)printf(" %s", strerror(i
));
708 ktrnamei(char *cp
, int len
)
711 (void)printf("\"%.*s\"\n", len
, cp
);
715 ktremul(char *name
, int len
, int bufsize
)
722 setemul(name
, ktr_header
.ktr_pid
, 1);
725 (void)printf("\"%s\"\n", name
);
729 hexdump_buf(const void *vdp
, int datalen
, int word_sz
)
731 const char hex
[] = "0123456789abcdef";
732 char chars
[16], prev
[16];
733 char bytes
[16 * 3 + 4];
734 const unsigned char *dp
= vdp
;
735 const unsigned char *datalim
= dp
+ datalen
;
736 const unsigned char *line_end
;
739 int divmask
= word_sz
- 1; /* block size in bytes */
740 int gdelim
= 3; /* gap between blocks */
741 int bsize
= 2; /* increment for each byte */
744 #if _BYTE_ORDER == _LITTLE_ENDIAN
745 int bswap
= word_sz
- 1;
762 width
= 16 * bsize
+ (16 / (divmask
+ 1)) * gdelim
;
766 for (off
= 0; dp
< datalim
; off
+= l
) {
767 memset(bytes
, ' ', sizeof bytes
);
769 if (line_end
>= datalim
) {
771 dupl
|= 1; /* need to print */
773 if (dupl
== 0 || memcmp(dp
, prev
, sizeof chars
))
778 /* This is a duplicate of the line above, count 'em */
785 /* previous line as a duplicate */
787 /* Only one duplicate, print line */
788 printf("\t%-5.3x%.*s%.*s\n",
789 off
- l
, width
, bytes
, l
, chars
);
792 snprintf(NULL
, 0, "%3x", off
), "*****");
795 for (l
= 0, bp
= bytes
, cp
= chars
; dp
< line_end
; l
++) {
798 if ((l
& divmask
) == 0)
800 bp
[(l
^ bswap
) * bsize
] = hex
[c
>> 4];
801 bp
[(l
^ bswap
) * bsize
+ 1] = hex
[c
& 0xf];
802 *cp
++ = isgraph(c
) ? c
: '.';
805 printf("\t%-5.3x%.*s%.*s\n", off
, width
, bytes
, l
, chars
);
811 visdump_buf(const void *vdp
, int datalen
, int col
)
813 const unsigned char *dp
= vdp
;
817 static int screenwidth
= 0;
819 if (screenwidth
== 0) {
822 if (!plain
&& ioctl(fileno(stderr
), TIOCGWINSZ
, &ws
) != -1 &&
824 screenwidth
= ws
.ws_col
;
831 for (; datalen
> 0; datalen
--, dp
++) {
832 (void)svis(visbuf
, *dp
, VIS_CSTYLE
,
833 datalen
> 1 ? *(dp
+ 1) : 0, "\"\n");
836 * Keep track of printables and
837 * space chars (like fold(1)).
849 width
= 8 - (col
& 07);
854 if (col
+ width
> (screenwidth
- 2)) {
855 (void)printf("\\\n\t");
862 (void)putchar(*cp
++);
867 (void)printf("\"\n");
871 ktrgenio(struct ktr_genio
*ktr
, int len
)
873 int datalen
= len
- sizeof (struct ktr_genio
);
874 char *dp
= (char *)ktr
+ sizeof (struct ktr_genio
);
876 if (ktr
->ktr_fd
!= -1)
877 printf("fd %d ", ktr
->ktr_fd
);
878 printf("%s %d bytes\n",
879 ktr
->ktr_rw
== UIO_READ
? "read" : "wrote", datalen
);
882 if (maxdata
> 0 && datalen
> maxdata
)
885 hexdump_buf(dp
, datalen
, word_size
);
889 visdump_buf(dp
, datalen
, 7);
893 ktrpsig(void *v
, int len
)
900 siginfo_t
*si
= &psig
->si
;
903 (void)printf("SIG%s ", signame(psig
->ps
.signo
, 0));
904 if (psig
->ps
.action
== SIG_DFL
)
905 (void)printf("SIG_DFL");
907 (void)printf("caught handler=%p mask=(", psig
->ps
.action
);
909 for (signo
= 1; signo
< NSIG
; signo
++) {
910 if (sigismember(&psig
->ps
.mask
, signo
)) {
915 (void)printf("%d", signo
);
921 case sizeof(struct ktr_psig
):
923 printf(" code=0x%x", psig
->ps
.code
);
924 printf(psig
->ps
.action
== SIG_DFL
? "\n" : ")\n");
927 if (si
->si_code
== 0) {
928 printf(": code=SI_USER sent by pid=%d, uid=%d)\n",
929 si
->si_pid
, si
->si_uid
);
933 if (si
->si_code
< 0) {
934 switch (si
->si_code
) {
936 printf(": code=SI_TIMER sigval %p)\n",
937 si
->si_value
.sival_ptr
);
956 printf(": code=%s unimplemented)\n", code
);
958 printf(": code=%d unimplemented)\n",
963 if (si
->si_code
== SI_NOINFO
) {
964 printf(": code=SI_NOINFO\n");
968 code
= siginfocodename(si
->si_signo
, si
->si_code
);
969 switch (si
->si_signo
) {
971 printf(": code=%s child pid=%d, uid=%d, "
972 " status=%u, utime=%lu, stime=%lu)\n",
974 si
->si_uid
, si
->si_status
,
975 (unsigned long) si
->si_utime
,
976 (unsigned long) si
->si_stime
);
983 printf(": code=%s, addr=%p, trap=%d)\n",
984 code
, si
->si_addr
, si
->si_trap
);
987 printf(": code=%s, fd=%d, band=%lx)\n",
988 code
, si
->si_fd
, si
->si_band
);
991 printf(": code=%s, errno=%d)\n",
997 warnx("Unhandled size %d for ktrpsig\n", len
);
1003 ktrcsw(struct ktr_csw
*cs
)
1006 (void)printf("%s %s\n", cs
->out
? "stop" : "resume",
1007 cs
->user
? "user" : "kernel");
1011 ktruser(struct ktr_user
*usr
, int len
)
1016 len
-= sizeof(struct ktr_user
);
1017 printf("%.*s:", KTR_USER_MAXIDLEN
, usr
->ktr_id
);
1018 dta
= (unsigned char *)(usr
+ 1);
1021 hexdump_buf(dta
, len
, word_size
);
1024 printf(" %d, ", len
);
1025 for (i
= 0; i
< len
; i
++)
1026 printf("%02x", (unsigned int) dta
[i
]);
1031 ktrmmsg(struct ktr_mmsg
*mmsg
, int len
)
1033 const char *service_name
;
1038 if ((id
/ 100) % 2) { /* Message reply */
1045 if ((service_name
= mach_service_name(id
)) != NULL
)
1046 printf("%s%s [%d]\n", service_name
, reply
, mmsg
->ktr_id
);
1048 printf("unknown service%s [%d]\n", reply
, mmsg
->ktr_id
);
1050 hexdump_buf(mmsg
, len
, word_size
? word_size
: 4);
1054 ktrmool(struct ktr_mool
*mool
, int len
)
1056 size_t size
= mool
->size
;
1058 printf("%ld/0x%lx bytes at %p\n",
1059 (u_long
)size
, (u_long
)size
, mool
->uaddr
);
1061 hexdump_buf(mool
, size
, word_size
? word_size
: 4);
1065 ktrmib(int *namep
, int len
)
1069 for (i
= 0; i
< (len
/ sizeof(*namep
)); i
++)
1070 printf("%s%d", (i
== 0) ? "" : ".", namep
[i
]);
1075 signame(long sig
, int xlat
)
1077 static char buf
[64];
1081 else if (sig
< 0 || sig
>= NSIG
) {
1082 (void)snprintf(buf
, sizeof(buf
), "*unknown %ld*", sig
);
1085 return sys_signame
[(xlat
&& cur_emul
->signalmap
!= NULL
) ?
1086 cur_emul
->signalmap
[sig
] : sig
];
1092 if (strcmp(getprogname(), "ioctlname") == 0) {
1093 (void)fprintf(stderr
, "Usage: %s [-e emulation] <ioctl> ...\n",
1096 (void)fprintf(stderr
, "Usage: %s [-dlNnRT] [-e emulation] "
1097 "[-f file] [-m maxdata] [-p pid]\n [-t trstr] "
1098 "[-x | -X size] [file]\n", getprogname());