diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_fmt.c | 17 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_io.c | 9 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/modules/genunix/memory.c | 40 | ||||
-rw-r--r-- | usr/src/lib/libc/port/gen/ctime.c | 36 |
4 files changed, 55 insertions, 47 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_fmt.c b/usr/src/cmd/mdb/common/mdb/mdb_fmt.c index 49a302a533..773c451b8c 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_fmt.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_fmt.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -347,7 +346,7 @@ fmt_swapint(mdb_tgt_t *t, mdb_tgt_as_t as, mdb_tgt_addr_t addr, size_t cnt) static mdb_tgt_addr_t fmt_time32(mdb_tgt_t *t, mdb_tgt_as_t as, mdb_tgt_addr_t addr, size_t cnt) { - uint32_t x; + int32_t x; while (cnt-- != 0) { if (mdb_tgt_aread(t, as, &x, sizeof (x), addr) == sizeof (x)) { @@ -365,11 +364,15 @@ fmt_time32(mdb_tgt_t *t, mdb_tgt_as_t as, mdb_tgt_addr_t addr, size_t cnt) static mdb_tgt_addr_t fmt_time64(mdb_tgt_t *t, mdb_tgt_as_t as, mdb_tgt_addr_t addr, size_t cnt) { - uint64_t x; + int64_t x; while (cnt-- != 0) { if (mdb_tgt_aread(t, as, &x, sizeof (x), addr) == sizeof (x)) { - mdb_iob_printf(mdb.m_out, "%-24Y", (time_t)x); + if ((time_t)x == x) + mdb_iob_printf(mdb.m_out, "%-24Y", (time_t)x); + else + mdb_iob_printf(mdb.m_out, "%-24llR", x); + mdb_nv_set_value(mdb.m_rvalue, x); addr += sizeof (x); } else { diff --git a/usr/src/cmd/mdb/common/mdb/mdb_io.c b/usr/src/cmd/mdb/common/mdb/mdb_io.c index 2d0e6af2a1..bd2aabac79 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_io.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_io.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -819,7 +818,7 @@ iob_time2str(time_t *tmp) int i; if (src == NULL) - return (mdb_strerror(errno)); + return (numtostr((uintmax_t)*tmp, mdb.m_radix, 0)); for (i = 20; i < 24; i++) *dst++ = src[i]; /* Copy the 4-digit year */ diff --git a/usr/src/cmd/mdb/common/modules/genunix/memory.c b/usr/src/cmd/mdb/common/modules/genunix/memory.c index 983fbaa4ab..6f4ef1ad58 100644 --- a/usr/src/cmd/mdb/common/modules/genunix/memory.c +++ b/usr/src/cmd/mdb/common/modules/genunix/memory.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -275,8 +275,8 @@ int memstat(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) { ulong_t pagesize; - pgcnt_t total_pages; - ulong_t physmem, freemem; + pgcnt_t total_pages, physmem; + ulong_t freemem; memstat_t stats; memstat_t unused_stats; GElf_Sym sym; @@ -360,52 +360,62 @@ memstat(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) stats.ms_vnode -= unused_stats.ms_kmem; stats.ms_total -= unused_stats.ms_kmem; -#define MS_PCT_TOTAL(x) (((5 * total_pages) + ((x) * 1000ull))) / \ - ((physmem) * 10) +#define MS_PCT_TOTAL(x) ((ulong_t)((((5 * total_pages) + ((x) * 1000ull))) / \ + ((physmem) * 10))) mdb_printf("Page Summary Pages MB" " %%Tot\n"); mdb_printf("------------ ---------------- ----------------" " ----\n"); - mdb_printf("Kernel %16llu %16llu %3llu%%\n", + mdb_printf("Kernel %16llu %16llu %3lu%%\n", stats.ms_kmem, (uint64_t)stats.ms_kmem * pagesize / (1024 * 1024), MS_PCT_TOTAL(stats.ms_kmem)); - mdb_printf("Anon %16llu %16llu %3llu%%\n", + mdb_printf("Anon %16llu %16llu %3lu%%\n", stats.ms_anon, (uint64_t)stats.ms_anon * pagesize / (1024 * 1024), MS_PCT_TOTAL(stats.ms_anon)); - mdb_printf("Exec and libs %16llu %16llu %3llu%%\n", + mdb_printf("Exec and libs %16llu %16llu %3lu%%\n", stats.ms_exec, (uint64_t)stats.ms_exec * pagesize / (1024 * 1024), MS_PCT_TOTAL(stats.ms_exec)); - mdb_printf("Page cache %16llu %16llu %3llu%%\n", + mdb_printf("Page cache %16llu %16llu %3lu%%\n", stats.ms_vnode, (uint64_t)stats.ms_vnode * pagesize / (1024 * 1024), MS_PCT_TOTAL(stats.ms_vnode)); - mdb_printf("Free (cachelist) %16llu %16llu %3llu%%\n", + mdb_printf("Free (cachelist) %16llu %16llu %3lu%%\n", stats.ms_cachelist, (uint64_t)stats.ms_cachelist * pagesize / (1024 * 1024), MS_PCT_TOTAL(stats.ms_cachelist)); - freemem = physmem - stats.ms_total; + /* + * occasionally, we double count pages above. To avoid printing + * absurdly large values for freemem, we clamp it at zero. + */ + if (physmem > stats.ms_total) + freemem = physmem - stats.ms_total; + else + freemem = 0; #if defined(__i386) || defined(__amd64) /* Are we running under Xen? If so, get balloon memory usage. */ if ((bln_size = mdb_readvar(&bln_stats, "bln_stats")) != -1) { - freemem -= bln_stats.bln_hv_pages; + if (freemem > bln_stats.bln_hv_pages) + freemem -= bln_stats.bln_hv_pages; + else + freemem = 0; } #endif - mdb_printf("Free (freelist) %16llu %16llu %3llu%%\n", freemem, + mdb_printf("Free (freelist) %16lu %16llu %3lu%%\n", freemem, (uint64_t)freemem * pagesize / (1024 * 1024), MS_PCT_TOTAL(freemem)); #if defined(__i386) || defined(__amd64) if (bln_size != -1) { - mdb_printf("Balloon %16ld %16ld %3ld%%\n", + mdb_printf("Balloon %16lu %16llu %3lu%%\n", bln_stats.bln_hv_pages, - bln_stats.bln_hv_pages * (long)pagesize / (1024 * 1024), + (uint64_t)bln_stats.bln_hv_pages * pagesize / (1024 * 1024), MS_PCT_TOTAL(bln_stats.bln_hv_pages)); } #endif diff --git a/usr/src/lib/libc/port/gen/ctime.c b/usr/src/lib/libc/port/gen/ctime.c index 097ef8ee0f..c2a58b25b3 100644 --- a/usr/src/lib/libc/port/gen/ctime.c +++ b/usr/src/lib/libc/port/gen/ctime.c @@ -90,13 +90,13 @@ #define CBUFSIZ 26 static char * -ct_numb(char *cp, int n) +ct_numb(char *cp, int n, char pad) { cp++; if (n >= 10) *cp++ = (n / 10) % 10 + '0'; else - *cp++ = ' '; /* Pad with blanks */ + *cp++ = pad; *cp++ = n % 10 + '0'; return (cp); } @@ -110,11 +110,12 @@ __posix_asctime_r(const struct tm *t, char *cbuf) { char *cp; const char *ncp; - const int *tp; - const char *Date = "Day Mon 00 00:00:00 1900\n"; + const char *Date = "Day Mon 00 00:00:00 YYYY\n"; const char *Day = "SunMonTueWedThuFriSat"; const char *Month = "JanFebMarAprMayJunJulAugSepOctNovDec"; + int year = t->tm_year + 1900; + cp = cbuf; for (ncp = Date; *cp++ = *ncp++; /* */) ; @@ -124,28 +125,23 @@ __posix_asctime_r(const struct tm *t, char *cbuf) *cp++ = *ncp++; *cp++ = *ncp++; cp++; - tp = &t->tm_mon; - ncp = Month + ((*tp) * 3); + ncp = Month + (3 * t->tm_mon); *cp++ = *ncp++; *cp++ = *ncp++; *cp++ = *ncp++; - cp = ct_numb(cp, *--tp); - cp = ct_numb(cp, *--tp + 100); - cp = ct_numb(cp, *--tp + 100); - --tp; - cp = ct_numb(cp, *tp + 100); - if (t->tm_year < 100) { - /* Common case: "19" already in buffer */ - cp += 2; - } else if (t->tm_year < 8100) { - cp = ct_numb(cp, (1900 + t->tm_year) / 100); - cp--; - } else { - /* Only 4-digit years are supported */ + cp = ct_numb(cp, t->tm_mday, ' '); + cp = ct_numb(cp, t->tm_hour, '0'); + cp = ct_numb(cp, t->tm_min, '0'); + cp = ct_numb(cp, t->tm_sec, '0'); + + if (year < 0 || year >= 10000) { + /* Only positive, 4-digit years are supported */ errno = EOVERFLOW; return (NULL); } - (void) ct_numb(cp, t->tm_year + 100); + cp = ct_numb(cp, year / 100, '0'); + cp--; + (void) ct_numb(cp, year, '0'); return (cbuf); } |