Date: Fri, 14 Mar 2014 22:07:09 +0000 (UTC) From: Neel Natu <neel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263196 - head/usr.bin/ktrdump Message-ID: <201403142207.s2EM79Op012926@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: neel Date: Fri Mar 14 22:07:08 2014 New Revision: 263196 URL: http://svnweb.freebsd.org/changeset/base/263196 Log: Don't dump entries that were modified during the time the KTR buffer was being copied to userspace. Failing to do this would result in entries at the bottom of the ktrdump output to be more recent than entries at the top. With this change the timestamps are monotonically decreasing going from the top to the bottom of the ktrdump output. Modified: head/usr.bin/ktrdump/ktrdump.c Modified: head/usr.bin/ktrdump/ktrdump.c ============================================================================== --- head/usr.bin/ktrdump/ktrdump.c Fri Mar 14 21:45:37 2014 (r263195) +++ head/usr.bin/ktrdump/ktrdump.c Fri Mar 14 22:07:08 2014 (r263196) @@ -93,7 +93,7 @@ main(int ac, char **av) char *p; int version; int entries; - int index; + int index, index2; int parm; int in; int c; @@ -182,7 +182,8 @@ main(int ac, char **av) if (kvm_read(kd, nl[2].n_value, &index, sizeof(index)) == -1 || kvm_read(kd, nl[3].n_value, &bufptr, sizeof(bufptr)) == -1 || - kvm_read(kd, bufptr, buf, sizeof(*buf) * entries) == -1) + kvm_read(kd, bufptr, buf, sizeof(*buf) * entries) == -1 || + kvm_read(kd, nl[2].n_value, &index2, sizeof(index2)) == -1) errx(1, "%s", kvm_geterr(kd)); } @@ -289,7 +290,14 @@ next: if ((c = *p++) == '\0') parms[4], parms[5]); fprintf(out, "\n"); if (!iflag) { - if (i == index) + /* + * 'index' and 'index2' are the values of 'ktr_idx' + * before and after the KTR buffer was copied into + * 'buf'. Since the KTR entries between 'index' and + * 'index2' were in flux while the KTR buffer was + * being copied to userspace we don't dump them. + */ + if (i == index2) break; if (--i < 0) i = entries - 1;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403142207.s2EM79Op012926>