diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-03-19 09:05:40 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-03-19 09:05:40 +0000 |
commit | f2014dc397c2f285566b439a8a6148a14b6a3ef9 (patch) | |
tree | d229ef04133f3436b2ffe28e924b82b41d63c7e6 /usr.bin/kdump | |
parent | 4b4ca199b889eb9f83636a4440711c3e46fc2e8b (diff) |
Add tracing and dumping of "pointer to struct" syscall arguments for
structs timespec, timeval, sigaction, and rlimit.
ok otto@ jsing@
Diffstat (limited to 'usr.bin/kdump')
-rw-r--r-- | usr.bin/kdump/kdump.c | 93 | ||||
-rw-r--r-- | usr.bin/kdump/kdump_subr.h | 3 | ||||
-rw-r--r-- | usr.bin/kdump/mksubr | 3 |
3 files changed, 96 insertions, 3 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 6aacbf468b0..252eccd75eb 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump.c,v 1.64 2012/02/20 21:04:35 guenther Exp $ */ +/* $OpenBSD: kdump.c,v 1.65 2012/03/19 09:05:39 guenther Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -1364,6 +1364,67 @@ ktrstat(const struct stat *statp) } static void +ktrtimespec(const struct timespec *tsp, int relative) +{ + printf("struct timespec { "); + print_timespec(tsp, relative); + printf(" }\n"); +} + +static void +ktrtimeval(const struct timeval *tvp, int relative) +{ + printf("struct timeval { "); + print_time(tvp->tv_sec, relative); + if (tvp->tv_usec != 0) + printf(".%06ld", tvp->tv_usec); + printf(" }\n"); +} + +static void +ktrsigaction(const struct sigaction *sa) +{ + /* + * note: ktrstruct() has already verified that sa points to a + * buffer exactly sizeof(struct sigaction) bytes long. + */ + printf("struct sigaction { "); + if (sa->sa_handler == SIG_DFL) + printf("handler=SIG_DFL"); + else if (sa->sa_handler == SIG_IGN) + printf("handler=SIG_IGN"); + else if (sa->sa_flags & SA_SIGINFO) + printf("sigaction=%p", (void *)sa->sa_sigaction); + else + printf("handler=%p", (void *)sa->sa_handler); + printf(", mask="); + sigset(sa->sa_mask); + printf(", flags="); + sigactionflagname(sa->sa_flags); + printf(" }\n"); +} + +static void +print_rlim(rlim_t lim) +{ + if (lim == RLIM_INFINITY) + printf("infinite"); + else + printf("%llu", (unsigned long long)lim); +} + +static void +ktrrlimit(const struct rlimit *limp) +{ + printf("struct rlimit { "); + printf("cur="); + print_rlim(limp->rlim_cur); + printf(", max="); + print_rlim(limp->rlim_max); + printf(" }\n"); +} + +static void ktrstruct(char *buf, size_t buflen) { char *name, *data; @@ -1402,6 +1463,36 @@ ktrstruct(char *buf, size_t buflen) datalen < sizeof(struct sockaddr)) || datalen != ss.ss_len) goto invalid; ktrsockaddr((struct sockaddr *)&ss); + } else if (strcmp(name, "abstimespec") == 0 || + strcmp(name, "reltimespec") == 0) { + struct timespec ts; + + if (datalen != sizeof(ts)) + goto invalid; + memcpy(&ts, data, datalen); + ktrtimespec(&ts, name[0] == 'r'); + } else if (strcmp(name, "abstimeval") == 0 || + strcmp(name, "reltimeval") == 0) { + struct timeval tv; + + if (datalen != sizeof(tv)) + goto invalid; + memcpy(&tv, data, datalen); + ktrtimeval(&tv, name[0] == 'r'); + } else if (strcmp(name, "sigaction") == 0) { + struct sigaction sa; + + if (datalen != sizeof(sa)) + goto invalid; + memcpy(&sa, data, datalen); + ktrsigaction(&sa); + } else if (strcmp(name, "rlimit") == 0) { + struct rlimit lim; + + if (datalen != sizeof(lim)) + goto invalid; + memcpy(&lim, data, datalen); + ktrrlimit(&lim); } else { printf("unknown structure %s\n", name); } diff --git a/usr.bin/kdump/kdump_subr.h b/usr.bin/kdump/kdump_subr.h index 210d1c1e3a0..6772587ca58 100644 --- a/usr.bin/kdump/kdump_subr.h +++ b/usr.bin/kdump/kdump_subr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump_subr.h,v 1.5 2012/02/20 21:04:35 guenther Exp $ */ +/* $OpenBSD: kdump_subr.h,v 1.6 2012/03/19 09:05:39 guenther Exp $ */ /* * Copyright(c) 2006 2006 David Kirchner <dpk@dpk.net> * @@ -62,6 +62,7 @@ void extattrctlname(int); void kldsymcmdname(int); void sendfileflagsname(int); void acltypename(int); +void sigactionflagname(int); void sigprocmaskhowname(int); void lio_listioname(int); void minheritname(int); diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr index f905b202f74..d3ece70c93c 100644 --- a/usr.bin/kdump/mksubr +++ b/usr.bin/kdump/mksubr @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: mksubr,v 1.8 2012/02/20 21:04:35 guenther Exp $ +# $OpenBSD: mksubr,v 1.9 2012/03/19 09:05:39 guenther Exp $ # # Copyright (c) 2006 David Kirchner <dpk@dpk.net> # @@ -430,6 +430,7 @@ auto_switch_type "clockname" "CLOCK_[A-Z]+[[:space:]]+[0-9]+" "sys/time.h" #auto_switch_type "kldsymcmdname" "KLDSYM_[A-Z]+[[:space:]]+[0-9]+" "sys/linker.h" #auto_switch_type "sendfileflagsname" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h" #auto_switch_type "acltypename" "ACL_TYPE_[A-Z4_]+[[:space:]]+0x[0-9]+" "sys/acl.h" +auto_orz_type "sigactionflagname" "SA_[A-Z]+[[:space:]]+0x[0-9]+" "sys/signal.h" auto_switch_type "sigprocmaskhowname" "SIG_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h" auto_switch_type "sigill_name" "ILL_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h" auto_switch_type "sigtrap_name" "TRAP_[A-Z]+[[:space:]]+[0-9]+" "sys/siginfo.h" |