Mercurial > illumos > illumos-gate
changeset 13089:9ff7ff6709c5
6921452 ::time should be usable in a pipeline
author | Jonathan Adams <Jonathan.Adams@Sun.COM> |
---|---|
date | Wed, 11 Aug 2010 14:15:46 -0700 |
parents | e0735b974926 |
children | fac90c60a1e7 |
files | usr/src/cmd/mdb/common/modules/genunix/genunix.c |
diffstat | 1 files changed, 23 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/mdb/common/modules/genunix/genunix.c Wed Aug 11 14:15:45 2010 -0700 +++ b/usr/src/cmd/mdb/common/modules/genunix/genunix.c Wed Aug 11 14:15:46 2010 -0700 @@ -19,8 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2010 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. */ #include <mdb/mdb_param.h> @@ -3798,17 +3797,28 @@ static int time(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { + uint_t opt_dec = FALSE; uint_t opt_lbolt = FALSE; - - if (mdb_getopts(argc, argv, 'l', MDB_OPT_SETBITS, TRUE, &opt_lbolt, + uint_t opt_hex = FALSE; + const char *fmt; + hrtime_t result; + + if (mdb_getopts(argc, argv, + 'd', MDB_OPT_SETBITS, TRUE, &opt_dec, + 'l', MDB_OPT_SETBITS, TRUE, &opt_lbolt, + 'x', MDB_OPT_SETBITS, TRUE, &opt_hex, NULL) != argc) return (DCMD_USAGE); - if (opt_lbolt) - mdb_printf("%ld\n", mdb_get_lbolt()); - else - mdb_printf("%lld\n", mdb_gethrtime()); - + if (opt_dec && opt_hex) + return (DCMD_USAGE); + + result = opt_lbolt ? mdb_get_lbolt() : mdb_gethrtime(); + fmt = + opt_hex ? "0x%llx\n" : + opt_dec ? "0t%lld\n" : "%#llr\n"; + + mdb_printf(fmt, result); return (DCMD_OK); } @@ -3821,7 +3831,9 @@ "time if inspecting one; or the running hires time if we're \n" "looking at a live system.\n\n" "Switches:\n" - " -l prints the number of clock ticks since system boot\n"); + " -d report times in decimal\n" + " -l prints the number of clock ticks since system boot\n" + " -x report times in hexadecimal\n"); } static const mdb_dcmd_t dcmds[] = { @@ -3862,7 +3874,7 @@ "print sysevent subclass list", sysevent_subclass_list}, { "system", NULL, "print contents of /etc/system file", sysfile }, { "task", NULL, "display kernel task(s)", task }, - { "time", "[-l]", "display system time", time, time_help }, + { "time", "[-dlx]", "display system time", time, time_help }, { "vnode2path", ":[-F]", "vnode address to pathname", vnode2path }, { "whereopen", ":", "given a vnode, dumps procs which have it open", whereopen },