From owner-svn-src-all@FreeBSD.ORG Fri Mar 14 22:07:09 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 642C8A6E; Fri, 14 Mar 2014 22:07:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 503F0398; Fri, 14 Mar 2014 22:07:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2EM79aC012927; Fri, 14 Mar 2014 22:07:09 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2EM79Op012926; Fri, 14 Mar 2014 22:07:09 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201403142207.s2EM79Op012926@svn.freebsd.org> From: Neel Natu Date: Fri, 14 Mar 2014 22:07:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263196 - head/usr.bin/ktrdump X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Mar 2014 22:07:09 -0000 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;