From owner-svn-src-head@FreeBSD.ORG Tue Mar 25 23:37:58 2014 Return-Path: Delivered-To: svn-src-head@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 8A30FAAE; Tue, 25 Mar 2014 23:37:58 +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 6A7393CC; Tue, 25 Mar 2014 23:37:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2PNbw8u055928; Tue, 25 Mar 2014 23:37:58 GMT (envelope-from sobomax@svn.freebsd.org) Received: (from sobomax@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2PNbwAp055927; Tue, 25 Mar 2014 23:37:58 GMT (envelope-from sobomax@svn.freebsd.org) Message-Id: <201403252337.s2PNbwAp055927@svn.freebsd.org> From: Maxim Sobolev Date: Tue, 25 Mar 2014 23:37:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263756 - head/usr.bin/kdump X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Mar 2014 23:37:58 -0000 Author: sobomax Date: Tue Mar 25 23:37:57 2014 New Revision: 263756 URL: http://svnweb.freebsd.org/changeset/base/263756 Log: Make `-R', `-T' and `-E' options mutially non-exclusive. It is often useful to see two or three types at the same time when inspecting the dump. MFC after: 1 month Sponsored by: Sippy Software, Inc. Modified: head/usr.bin/kdump/kdump.c Modified: head/usr.bin/kdump/kdump.c ============================================================================== --- head/usr.bin/kdump/kdump.c Tue Mar 25 23:30:35 2014 (r263755) +++ head/usr.bin/kdump/kdump.c Tue Mar 25 23:37:57 2014 (r263756) @@ -117,6 +117,11 @@ void limitfd(int fd); void usage(void); void ioctlname(unsigned long, int); +#define TIMESTAMP_NONE 0x0 +#define TIMESTAMP_ABSOLUTE 0x1 +#define TIMESTAMP_ELAPSED 0x2 +#define TIMESTAMP_RELATIVE 0x4 + int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, resolv = 0, abiflag = 0; const char *tracefile = DEF_TRACEFILE; @@ -254,6 +259,8 @@ main(int argc, char *argv[]) setlocale(LC_CTYPE, ""); + timestamp = TIMESTAMP_NONE; + while ((ch = getopt(argc,argv,"f:dElm:np:AHRrsTt:")) != -1) switch (ch) { case 'A': @@ -284,16 +291,16 @@ main(int argc, char *argv[]) suppressdata = 1; break; case 'E': - timestamp = 3; /* elapsed timestamp */ + timestamp |= TIMESTAMP_ELAPSED; break; case 'H': threads = 1; break; case 'R': - timestamp = 2; /* relative timestamp */ + timestamp |= TIMESTAMP_RELATIVE; break; case 'T': - timestamp = 1; + timestamp |= TIMESTAMP_ABSOLUTE; break; case 't': trpoints = getpoints(optarg); @@ -567,7 +574,7 @@ void dumpheader(struct ktr_header *kth) { static char unknown[64]; - static struct timeval prevtime, temp; + static struct timeval prevtime, prevtime_e, temp; const char *type; switch (kth->ktr_type) { @@ -631,19 +638,26 @@ dumpheader(struct ktr_header *kth) else printf("%6jd %-8.*s ", (intmax_t)kth->ktr_pid, MAXCOMLEN, kth->ktr_comm); - if (timestamp) { - if (timestamp == 3) { - if (prevtime.tv_sec == 0) - prevtime = kth->ktr_time; - timevalsub(&kth->ktr_time, &prevtime); + if (timestamp) { + if (timestamp & TIMESTAMP_ABSOLUTE) { + printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec, + kth->ktr_time.tv_usec); + } + if (timestamp & TIMESTAMP_ELAPSED) { + if (prevtime_e.tv_sec == 0) + prevtime_e = kth->ktr_time; + timevalsub(&kth->ktr_time, &prevtime_e); + printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec, + kth->ktr_time.tv_usec); + timevaladd(&kth->ktr_time, &prevtime_e); } - if (timestamp == 2) { + if (timestamp & TIMESTAMP_RELATIVE) { temp = kth->ktr_time; timevalsub(&kth->ktr_time, &prevtime); prevtime = temp; + printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec, + kth->ktr_time.tv_usec); } - printf("%jd.%06ld ", (intmax_t)kth->ktr_time.tv_sec, - kth->ktr_time.tv_usec); } printf("%s ", type); }