#include "ktrace.h"
#include "kdump_subr.h"
+extern const char *ioctlname(u_long);
+
+static int dumpheader(struct ktr_header *);
+static int fread_tail(void *, int, int);
+static void ktrcsw(struct ktr_csw *);
+static void ktrgenio(struct ktr_genio *, int);
+static void ktrnamei(char *, int);
+static void ktrpsig(struct ktr_psig *);
+static void ktrsyscall(struct ktr_syscall *);
+static void ktrsysret(struct ktr_sysret *);
+static void ktruser(int, unsigned char *);
+static void ktruser_malloc(int, unsigned char *);
+static void timevalfix(struct timeval *);
+static void timevalsub(struct timeval *, struct timeval *);
+static void usage(void);
+
int timestamp, decimal, fancy = 1, tail, maxdata = 64;
int fixedformat;
-char *tracefile = DEF_TRACEFILE;
+const char *tracefile = DEF_TRACEFILE;
struct ktr_header ktr_header;
#define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
+int
main(int argc, char **argv)
{
int ch, col, ktrlen, size;
if (tail)
(void)fflush(stdout);
}
+ exit(0);
}
-fread_tail(char *buf, int size, int num)
+static int
+fread_tail(void *buf, int size, int num)
{
int i;
return (i);
}
+static int
dumpheader(struct ktr_header *kth)
{
static char unknown[64];
static struct timeval prevtime, temp;
- char *type;
+ const char *type;
int col;
switch (kth->ktr_type) {
#undef KTRACE
int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]);
-static char *ptrace_ops[] = {
+static const char *ptrace_ops[] = {
"PT_TRACE_ME", "PT_READ_I", "PT_READ_D", "PT_READ_U",
"PT_WRITE_I", "PT_WRITE_D", "PT_WRITE_U", "PT_CONTINUE",
"PT_KILL", "PT_STEP", "PT_ATTACH", "PT_DETACH",
};
+static void
ktrsyscall(struct ktr_syscall *ktr)
{
int narg = ktr->ktr_narg;
register_t *ip;
- char *ioctlname();
if (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)
(void)printf("[%d]", ktr->ktr_code);
} while (0);
if (ktr->ktr_code == SYS_ioctl) {
- char *cp;
+ const char *cp;
print_number(ip,narg,c);
if ((cp = ioctlname(*ip)) != NULL)
(void)printf(",%s", cp);
ip++;
narg--;
} else if (ktr->ktr_code == SYS_ptrace) {
- if (*ip < sizeof(ptrace_ops) /
- sizeof(ptrace_ops[0]) && *ip >= 0)
+ if (*ip < (register_t)(sizeof(ptrace_ops) /
+ sizeof(ptrace_ops[0])) && *ip >= 0)
(void)printf("(%s", ptrace_ops[*ip]);
#ifdef PT_GETREGS
else if (*ip == PT_GETREGS)
(void)putchar('\n');
}
+static void
ktrsysret(struct ktr_sysret *ktr)
{
register_t ret = ktr->ktr_retval;
(void)putchar('\n');
}
+static void
ktrnamei(char *cp, int len)
{
(void)printf("\"%.*s\"\n", len, cp);
}
+static void
ktrgenio(struct ktr_genio *ktr, int len)
{
int datalen = len - sizeof (struct ktr_genio);
int col = 0;
int width;
char visbuf[5];
- static screenwidth = 0;
+ static int screenwidth = 0;
if (screenwidth == 0) {
struct winsize ws;
(void)printf("\"\n");
}
-char *signames[NSIG] = {
+const char *signames[NSIG] = {
"NULL", "HUP", "INT", "QUIT", "ILL", "TRAP", "IOT", /* 1 - 6 */
"EMT", "FPE", "KILL", "BUS", "SEGV", "SYS", /* 7 - 12 */
"PIPE", "ALRM", "TERM", "URG", "STOP", "TSTP", /* 13 - 18 */
"USR2", NULL, /* 31 - 32 */
};
+static void
ktrpsig(struct ktr_psig *psig)
{
(void)printf("SIG%s ", signames[psig->signo]);
(void)printf("SIG_DFL\n");
else
(void)printf("caught handler=0x%lx mask=0x%x code=0x%x\n",
- (u_long)psig->action, psig->mask, psig->code);
+ (u_long)psig->action, psig->mask.__bits[0], psig->code);
}
+static void
ktrcsw(struct ktr_csw *cs)
{
(void)printf("%s %s\n", cs->out ? "stop" : "resume",
void *r;
};
-void
-ktruser_malloc(int len, unsigned char *p)
+static void
+ktruser_malloc(int len __unused, unsigned char *p)
{
struct utrace_malloc *ut = (struct utrace_malloc *)p;
}
}
+static void
ktruser(int len, unsigned char *p)
{
if (len == sizeof(struct utrace_malloc)) {
(void)printf("\n");
}
+static void
usage(void)
{
(void)fprintf(stderr,
exit(1);
}
+static void
timevalsub(struct timeval *t1, struct timeval *t2)
{
t1->tv_sec -= t2->tv_sec;
timevalfix(t1);
}
+static void
timevalfix(struct timeval *t1)
{
if (t1->tv_usec < 0) {