Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/ktrace Learn about ktrace v1 records.



details:   https://anonhg.NetBSD.org/src/rev/cbbe64f1600b
branches:  trunk
changeset: 586244:cbbe64f1600b
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Dec 11 11:29:06 2005 +0000

description:
Learn about ktrace v1 records.

diffstat:

 usr.bin/ktrace/ktrace.1 |  12 ++++++++++--
 usr.bin/ktrace/ktrace.c |  27 +++++++++++++++++----------
 2 files changed, 27 insertions(+), 12 deletions(-)

diffs (145 lines):

diff -r b24a24fbcc41 -r cbbe64f1600b usr.bin/ktrace/ktrace.1
--- a/usr.bin/ktrace/ktrace.1   Sun Dec 11 06:25:32 2005 +0000
+++ b/usr.bin/ktrace/ktrace.1   Sun Dec 11 11:29:06 2005 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ktrace.1,v 1.28 2004/06/24 15:59:13 wiz Exp $
+.\"    $NetBSD: ktrace.1,v 1.29 2005/12/11 11:29:06 christos Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"    @(#)ktrace.1    8.1 (Berkeley) 6/6/93
 .\"
-.Dd June 24, 2004
+.Dd October 29, 2005
 .Dt KTRACE 1
 .Os
 .Sh NAME
@@ -62,6 +62,7 @@
 .Op Fl m Ar maxdata
 .Op Fl o Ar outfile
 .Op Fl t Ar trstr
+.Op Fl v Ar vers
 command
 .Sh DESCRIPTION
 .Nm
@@ -212,6 +213,13 @@
 Execute
 .Ar command
 with the specified trace flags.
+.It Fl v Ar version
+Determines the
+.Ar version
+of the file generated.
+Version 0 is the compatible ktrace format, and
+version 1 is the new format which lwp id's and nanosecond instead of
+microsecond timestamps.
 .El
 .Pp
 The
diff -r b24a24fbcc41 -r cbbe64f1600b usr.bin/ktrace/ktrace.c
--- a/usr.bin/ktrace/ktrace.c   Sun Dec 11 06:25:32 2005 +0000
+++ b/usr.bin/ktrace/ktrace.c   Sun Dec 11 11:29:06 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ktrace.c,v 1.37 2004/07/16 23:52:01 enami Exp $        */
+/*     $NetBSD: ktrace.c,v 1.38 2005/12/11 11:29:06 christos Exp $     */
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)ktrace.c   8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: ktrace.c,v 1.37 2004/07/16 23:52:01 enami Exp $");
+__RCSID("$NetBSD: ktrace.c,v 1.38 2005/12/11 11:29:06 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -69,7 +69,7 @@
 int    main(int, char *[]);
 static int rpid(char *);
 static void usage(void);
-static int do_ktrace(const char *, int, int, int, int);
+static int do_ktrace(const char *, int, int, int, int, int);
 static void no_ktrace(int);
 static void fset(int fd, int flag);
 static void fclear(int fd, int flag);
@@ -83,6 +83,7 @@
 {
        enum { NOTSET, CLEAR, CLEARALL } clear;
        int block, append, ch, fd, trset, ops, pid, pidset, synclog, trpoints;
+       int vers;
        const char *outfile;
 #ifdef KTRUSS
        const char *infile;
@@ -93,13 +94,14 @@
        append = ops = pidset = trset = synclog = 0;
        trpoints = 0;
        block = 1;
+       vers = 1;
        pid = 0;        /* Appease GCC */
 
 #ifdef KTRUSS
-# define OPTIONS "aCce:df:g:ilm:no:p:RTt:"
+# define OPTIONS "aCce:df:g:ilm:no:p:RTt:v:"
        outfile = infile = NULL;
 #else
-# define OPTIONS "aCcdf:g:ip:st:"
+# define OPTIONS "aCcdf:g:ip:st:v:"
        outfile = DEF_TRACEFILE;
 #endif
 
@@ -178,6 +180,9 @@
                                usage();
                        }
                        break;
+               case 'v':
+                       vers = atoi(optarg);
+                       break;
                default:
                        usage();
                }
@@ -221,7 +226,7 @@
                } else
                        ops |= pid ? KTROP_CLEAR : KTROP_CLEARFILE;
 
-               (void)do_ktrace(outfile, ops, trpoints, pid, block);
+               (void)do_ktrace(outfile, vers, ops, trpoints, pid, block);
                exit(0);
        }
 
@@ -235,17 +240,17 @@
 
        if (*argv) {
 #ifdef KTRUSS
-               if (do_ktrace(outfile, ops, trpoints, getpid(), block) == 1) {
+               if (do_ktrace(outfile, vers, ops, trpoints, getpid(), block) == 1) {
                        execvp(argv[0], &argv[0]);
                        err(EXIT_FAILURE, "exec of '%s' failed", argv[0]);
                }
 #else
-               (void)do_ktrace(outfile, ops, trpoints, getpid(), block);
+               (void)do_ktrace(outfile, vers, ops, trpoints, getpid(), block);
                execvp(argv[0], &argv[0]);
                err(EXIT_FAILURE, "exec of '%s' failed", argv[0]);
 #endif
        } else
-               (void)do_ktrace(outfile, ops, trpoints, pid, block);
+               (void)do_ktrace(outfile, vers, ops, trpoints, pid, block);
        return 0;
 }
 
@@ -326,9 +331,11 @@
 }
 
 static int
-do_ktrace(const char *tracefile, int ops, int trpoints, int pid, int block)
+do_ktrace(const char *tracefile, int vers, int ops, int trpoints, int pid,
+    int block)
 {
        int ret;
+       ops |= vers << KTRFAC_VER_SHIFT;
 
        if (KTROP(ops) == KTROP_SET &&
            (!tracefile || strcmp(tracefile, "-") == 0)) {



Home | Main Index | Thread Index | Old Index