--- //depot/vendor/freebsd/src/sys/amd64/include/asm.h 2007/08/22 04:32:22 +++ src/sys/amd64/include/asm.h 2007/1227 23:50:32 @@ -83,7 +83,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) + .section set_srcid,"a",@progbits + .p2align 0 + .asciz #s + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ --- //depot/vendor/freebsd/src/sys/arm/include/asm.h 2007/10/13 12:06:51 +++ src/sys/arm/include/asm.h 2007/1227 23:50:32 @@ -104,7 +104,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) + .section set_srcid,"a",@progbits + .p2align 0 + .asciz #s + .previous #else #define __FBSDID(s) /* nothing */ #endif --- //depot/vendor/freebsd/src/sys/ddb/db_ps.c 2007/10/16 17:57:22 +++ src/sys/ddb/db_ps.c 2007/1226 01:57:59 @@ -280,10 +280,133 @@ db_printf("\n"); } +struct tdflagmap { + int val; + char *name; +}; + +/* + * Mapping between TDF_* flags and their ASCII representation. + * Keep those values synchronized with proc.h. + */ +static struct tdflagmap tdf_map[] = { +#define TDF_FLAGMAPADD(x) \ + { (x), #x } + TDF_FLAGMAPADD(TDF_BORROWING), + TDF_FLAGMAPADD(TDF_INPANIC), + TDF_FLAGMAPADD(TDF_INMEM), + TDF_FLAGMAPADD(TDF_SINTR), + TDF_FLAGMAPADD(TDF_TIMEOUT), + TDF_FLAGMAPADD(TDF_IDLETD), + TDF_FLAGMAPADD(TDF_UNUSEDx40), + TDF_FLAGMAPADD(TDF_SLEEPABORT), + TDF_FLAGMAPADD(TDF_KTH_SUSP), + TDF_FLAGMAPADD(TDF_UBORROWING), + TDF_FLAGMAPADD(TDF_BOUNDARY), + TDF_FLAGMAPADD(TDF_ASTPENDING), + TDF_FLAGMAPADD(TDF_TIMOFAIL), + TDF_FLAGMAPADD(TDF_INTERRUPT), + TDF_FLAGMAPADD(TDF_UPIBLOCKED), + TDF_FLAGMAPADD(TDF_UNUSED15), + TDF_FLAGMAPADD(TDF_NEEDRESCHED), + TDF_FLAGMAPADD(TDF_NEEDSIGCHK), + TDF_FLAGMAPADD(TDF_XSIG), + TDF_FLAGMAPADD(TDF_UNUSED19), + TDF_FLAGMAPADD(TDF_THRWAKEUP), + TDF_FLAGMAPADD(TDF_DBSUSPEND), + TDF_FLAGMAPADD(TDF_SWAPINREQ), + TDF_FLAGMAPADD(TDF_UNUSED23), + TDF_FLAGMAPADD(TDF_SCHED0), + TDF_FLAGMAPADD(TDF_SCHED1), + TDF_FLAGMAPADD(TDF_SCHED2), + TDF_FLAGMAPADD(TDF_SCHED3), + TDF_FLAGMAPADD(TDF_ALRMPEND), + TDF_FLAGMAPADD(TDF_PROFPEND), + TDF_FLAGMAPADD(TDF_MACPEND), +#undef TDF_FLAGMAPADD +}; + +/* + * Mapping between TDP_* flags and their ASCII representation. + * Keep those values synchronized with proc.h. + */ +static struct tdflagmap tdp_map[] = { +#define TDP_FLAGMAPADD(x) \ + { (x), #x } + TDP_FLAGMAPADD(TDP_OLDMASK), + TDP_FLAGMAPADD(TDP_INKTR), + TDP_FLAGMAPADD(TDP_INKTRACE), + TDP_FLAGMAPADD(TDP_UPCALLING), + TDP_FLAGMAPADD(TDP_COWINPROGRESS), + TDP_FLAGMAPADD(TDP_ALTSTACK), + TDP_FLAGMAPADD(TDP_DEADLKTREAT), + TDP_FLAGMAPADD(TDP_SA), + TDP_FLAGMAPADD(TDP_NOSLEEPING), + TDP_FLAGMAPADD(TDP_OWEUPC), + TDP_FLAGMAPADD(TDP_ITHREAD), + TDP_FLAGMAPADD(TDP_CAN_UNBIND), + TDP_FLAGMAPADD(TDP_SCHED1), + TDP_FLAGMAPADD(TDP_SCHED2), + TDP_FLAGMAPADD(TDP_SCHED3), + TDP_FLAGMAPADD(TDP_SCHED4), + TDP_FLAGMAPADD(TDP_GEOM), + TDP_FLAGMAPADD(TDP_SOFTDEP), + TDP_FLAGMAPADD(TDP_NORUNNINGBUF), + TDP_FLAGMAPADD(TDP_WAKEUP), + TDP_FLAGMAPADD(TDP_INBDFLUSH), + TDP_FLAGMAPADD(TDP_KTHREAD), + TDP_FLAGMAPADD(TDP_CALLCHAIN), +#undef TDP_FLAGMAPADD +}; + +enum { + TDFLAG_TD_FLAGS, + TDFLAG_TD_PFLAGS, +}; + +static void +flags_externalize(int which, char *buf, int bufsize, int flags) +{ + int fst, i, sz; + struct tdflagmap *map; + char *s; + + KASSERT(buf != NULL, ("buf == NULL")); + + bzero(buf, bufsize); + snprintf(buf, bufsize, "(%#x) ", flags); + if (which == TDFLAG_TD_FLAGS) { + map = tdf_map; + sz = sizeof(tdf_map) / sizeof(tdf_map[0]); + } else if (which == TDFLAG_TD_PFLAGS) { + map = tdp_map; + sz = sizeof(tdp_map) / sizeof(tdp_map[0]); + } else { + snprintf(buf, bufsize, "\n"); + return; + } + fst = 1; + for (i = 0; i < sz; i++) { + if (flags & map[i].val) { + if (fst == 1) + s = "<"; + else + s = ","; + strlcat(buf, s, bufsize); + strlcat(buf, map[i].name, bufsize); + fst = 0; + } + } + if (fst == 0) + /* At least one known flag present */ + strlcat(buf, ">", bufsize); +} + DB_SHOW_COMMAND(thread, db_show_thread) { struct thread *td; boolean_t comma; + char flstr[512]; /* Determine which thread to examine. */ if (have_addr) @@ -297,8 +420,12 @@ db_printf(" name: %s\n", td->td_name); db_printf(" stack: %p-%p\n", (void *)td->td_kstack, (void *)(td->td_kstack + td->td_kstack_pages * PAGE_SIZE - 1)); - db_printf(" flags: %#x ", td->td_flags); - db_printf(" pflags: %#x\n", td->td_pflags); + flags_externalize(TDFLAG_TD_FLAGS, flstr, sizeof(flstr), + td->td_flags); + db_printf(" flags: %s\n", flstr); + flags_externalize(TDFLAG_TD_PFLAGS, flstr, sizeof(flstr), + td->td_pflags); + db_printf(" pflags: %s\n", flstr); db_printf(" state: "); switch (td->td_state) { case TDS_INACTIVE: --- //depot/vendor/freebsd/src/sys/i386/i386/local_apic.c 2007/09/11 22:57:37 +++ src/sys/i386/i386/local_apic.c 2007/1226 01:56:49 @@ -928,6 +928,11 @@ DB_SHOW_COMMAND(lapic, db_show_lapic) { uint32_t v; + + if (lapic_paddr == 0) { + db_printf("Local APIC is not used.\n"); + return; + } db_printf("lapic ID = %d\n", lapic_id()); v = lapic->version; --- //depot/vendor/freebsd/src/sys/i386/include/asm.h 2007/08/22 04:27:53 +++ src/sys/i386/include/asm.h 2007/1227 23:50:32 @@ -93,7 +93,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) + .section set_srcid,"a",@progbits + .p2align 0 + .asciz #s + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ --- //depot/vendor/freebsd/src/sys/ia64/include/asm.h 2005/01/31 08:20:43 +++ src/sys/ia64/include/asm.h 2007/1227 23:50:32 @@ -182,7 +182,11 @@ * ID tag macros */ #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) + .section set_srcid,"a",@progbits + .p2align 0 + .asciz #s + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ --- //depot/vendor/freebsd/src/sys/kern/kern_conf.c 2007/12/05 01:26:52 +++ src/sys/kern/kern_conf.c 2007/1226 19:57:52 @@ -27,6 +27,8 @@ #include __FBSDID("$FreeBSD: src/sys/kern/kern_conf.c,v 1.209 2007/12/05 01:22:03 thompsa Exp $"); +#include "opt_ddb.h" + #include #include #include @@ -48,6 +50,10 @@ #include +#ifdef DDB +#include +#endif + static MALLOC_DEFINE(M_DEVT, "cdev", "cdev storage"); struct mtx devmtx; @@ -1078,3 +1084,84 @@ } SYSINIT(devdtr, SI_SUB_DEVFS, SI_ORDER_SECOND, devdtr_init, NULL); + + +#ifdef DDB +enum { + CDEV_PRINT_HEADER = 1, + CDEV_NOHEADER = 2, +}; + +static void +show_cdev(struct cdev *dev, int flag) +{ + int align; + + if (flag == CDEV_PRINT_HEADER) { + db_printf("addr\tname\tuid\tgid\trefcount\tusecount\n" + "flags\n"); + } + + align = 18; + db_printf("%*.s: %p\n", align, "si_priv", dev->si_priv); + + /* more ASCII */ + db_printf("%*.s: %p\n", align, "si_flags", dev->si_priv); + db_printf("%*.s: %p\n", align, "si_atime", &dev->si_atime); + db_printf("%*.s: %p\n", align, "si_ctime", &dev->si_ctime); + db_printf("%*.s: %p\n", align, "si_mtime", &dev->si_mtime); + db_printf("%*.s: %d\n", align, "si_uid", dev->si_uid); + db_printf("%*.s: %d\n", align, "si_gid", dev->si_gid); + db_printf("%*.s: %x\n", align, "si_mode", dev->si_mode); + db_printf("%*.s: %p\n", align, "si_cred", dev->si_cred); + db_printf("%*.s: %d\n", align, "si_drv0", dev->si_drv0); + db_printf("%*.s: %d\n", align, "si_refcount", dev->si_refcount); + db_printf("%*.s: %d\n", align, "si_parent", dev->si_parent); + db_printf("%*.s: %d\n", align, "si_name", dev->si_name); + db_printf("%*.s: %d\n", align, "si_dvr1", dev->si_drv1); + db_printf("%*.s: %d\n", align, "si_drv2", dev->si_drv2); + db_printf("%*.s: %d\n", align, "si_devsw", dev->si_devsw); + db_printf("%*.s: %d\n", align, "si_iosize_max", dev->si_iosize_max); + db_printf("%*.s: %d\n", align, "si_usecount", dev->si_usecount); + db_printf("%*.s: %d\n", align, "si_threadcount", dev->si_threadcount); + /* bring __si_u here */ + db_printf("%*.s: %d\n", align, "__si_namebuf", dev->__si_namebuf); +}; + +DB_SHOW_COMMAND(cdev, db_show_cdev) +{ + struct cdev *cdevp; + + if (!have_addr) { + db_printf("Usage: show cdev \n"); + return; + } + cdevp = (struct cdev *) addr; + show_cdev(cdevp, CDEV_PRINT_HEADER); +} + +DB_SHOW_COMMAND(cdevsw, db_show_cdevsw) +{ + struct cdevsw *sw; + struct cdev *cdevp; + int fst; + + if (!have_addr) { + db_printf("db show cdevsw
\n"); + return; + } + sw = (struct cdevsw *) addr; + db_printf("cdevsw at %p\n", sw); + + fst = 1; + LIST_FOREACH(cdevp, &sw->d_devs, si_list) { + if (fst == 1) { + show_cdev(cdevp, CDEV_PRINT_HEADER); + fst = 0; + } else { + show_cdev(cdevp, CDEV_NOHEADER); + } + } +} +#endif /* DDB */ + --- //depot/vendor/freebsd/src/sys/kern/kern_mib.c 2007/12/04 12:31:49 +++ src/sys/kern/kern_mib.c 2007/1227 12:40:53 @@ -38,6 +38,7 @@ #include __FBSDID("$FreeBSD: src/sys/kern/kern_mib.c,v 1.85 2007/12/04 12:28:07 kib Exp $"); +#include "opt_ddb.h" #include "opt_posix.h" #include "opt_config.h" @@ -308,6 +309,106 @@ CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_PRISON, 0, 0, sysctl_kern_securelvl, "I", "Current secure level"); +/* + * If STRIP_FBSDID is defined it means we should save as much as + * possible in terms of the kernel size. Handle "kern.srcids" and "show + * srcids" DDB command only in !STRIP_FBSDID case. Otherwise, we'd need + * at least one thing lying in the srcid magic section so that we + * wouldn't be getting an error about __(start|stop)_set_srcid being + * undefined due to non-existent .srcid section; and it all would be + * just to get useless output.. + */ +#ifndef STRIP_FBSDID + +/* + * Based on __FBSDID format, skip common parts that bring no valueable + * information in this context. + */ +static void __unused +srcid_fname(char *id, char **ret, int *retlen) +{ + char *p = NULL; + int l = 0; + + KASSERT(id != NULL, ("id == NULL")); + KASSERT(ret != NULL, ("p == NULL")); + KASSERT(retlen != NULL, ("len == NULL")); + + p = strstr(id, "$FreeBSD: "); + if (p != NULL) + id += strlen("$FreeBSD: "); + l = strlen(id); + p = strstr(id, " Exp $"); + if (p != NULL) + l = p - id; + *ret = id; + *retlen = l; +} + + +/* + * Magic generated by the gcc(1) to mark the section ranges with special + * variable names. + */ +extern char __start_set_srcid[]; +extern char __stop_set_srcid[]; + +#define FBSDID_BEGIN (&__start_set_srcid[0]) +#define FBSDID_END (&__stop_set_srcid[0]) + +/* + * Return all __FBSDID tags. The output is huge. + */ +static int +sysctl_kern_srcids(SYSCTL_HANDLER_ARGS) +{ + char *bid = FBSDID_BEGIN; + char *eid = FBSDID_END; + char *s; + int idlen; + char *id; + int error = 0; + + for (s = bid; s < eid; s++) { + srcid_fname(s, &id, &idlen); + error = sysctl_handle_opaque(oidp, "\n", 1, req); + if (error) + break; + error = sysctl_handle_opaque(oidp, id, idlen, req); + if (error) + break; + s += strlen(s); + } + error = sysctl_handle_opaque(oidp, "\0", 1, req); + if (error) + return (error); + return (error); +} +SYSCTL_PROC(_kern, OID_AUTO, srcids, CTLTYPE_STRING|CTLFLAG_RD, 0, 0, + sysctl_kern_srcids, "A", "Revision control tags for kernel sources"); + +#ifdef DDB +#include + +DB_SHOW_COMMAND(srcids, db_srcid_list) +{ + char *bid = FBSDID_BEGIN; + char *eid = FBSDID_END; + char *s; + int slen; + int idlen; + char *id; + + for (s = bid; s < eid; s++) { + srcid_fname(s, &id, &idlen); + db_printf("%.*s\n", idlen, id); + slen = strlen(s); + s += slen; + } +} +#endif +#endif /* STRIP_FBSDID */ + #ifdef INCLUDE_CONFIG_FILE /* Actual kernel configuration options. */ extern char kernconfstring[]; --- //depot/vendor/freebsd/src/sys/kern/subr_lock.c 2007/12/15 23:17:04 +++ src/sys/kern/subr_lock.c 2007/1226 01:56:49 @@ -111,8 +111,10 @@ struct lock_object *lock; struct lock_class *class; - if (!have_addr) + if (!have_addr) { + db_printf("Usage: show lock \n"); return; + } lock = (struct lock_object *)addr; if (LO_CLASSINDEX(lock) > LOCK_CLASS_MAX) { db_printf("Unknown lock class: %d\n", LO_CLASSINDEX(lock)); --- //depot/vendor/freebsd/src/sys/kern/subr_rman.c 2007/04/28 07:41:42 +++ src/sys/kern/subr_rman.c 2007/1226 01:56:49 @@ -923,7 +923,7 @@ if (db_pager_quit) return; - db_printf("rman: %s\n", rm->rm_descr); + db_printf("rman: %p (%s)\n", rm, rm->rm_descr); db_printf(" 0x%lx-0x%lx (full range)\n", rm->rm_start, rm->rm_end); TAILQ_FOREACH(r, &rm->rm_list, r_link) { if (r->r_dev != NULL) { @@ -947,6 +947,8 @@ if (have_addr) dump_rman((struct rman *)addr); + else + db_printf("Usage: show rman addr\n"); } DB_SHOW_COMMAND(allrman, db_show_all_rman) --- //depot/vendor/freebsd/src/sys/kern/subr_sleepqueue.c 2007/11/14 06:57:03 +++ src/sys/kern/subr_sleepqueue.c 2007/1226 01:56:49 @@ -911,8 +911,11 @@ void *wchan; int i; - if (!have_addr) + if (!have_addr) { + db_printf("Usage: show sleepqueue \n"); + db_printf(" show sleepq \n"); return; + } /* * First, see if there is an active sleep queue for the wait channel --- //depot/vendor/freebsd/src/sys/kern/subr_turnstile.c 2007/11/14 06:27:32 +++ src/sys/kern/subr_turnstile.c 2007/1226 01:56:49 @@ -1049,8 +1049,10 @@ struct lock_object *lock; int i; - if (!have_addr) + if (!have_addr) { + db_printf("Usage: show turnstile \n"); return; + } /* * First, see if there is an active turnstile for the lock indicated --- //depot/vendor/freebsd/src/sys/kern/tty_cons.c 2007/12/25 21:21:35 +++ src/sys/kern/tty_cons.c 2007/1226 19:57:52 @@ -61,7 +61,9 @@ #include #include +#if DDB #include +#endif #include @@ -732,3 +734,43 @@ } SYSINIT(cndev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, cn_drvinit, NULL) + +#if DDB +DB_SHOW_COMMAND(cons, db_show_cons) +{ + struct cn_device *cnd; + struct consdev *cn; + int al, i, n; + char namebuf[64]; + long off; + + off = 0; + n = 0; + al = 20; /* alignment */ + + STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { + if (have_addr && addr != n) { + n++; + continue; + } + db_printf("%4d:\n", n); + db_printf("%*s = %p", al, "cnd_cn", cnd->cnd_cn); + db_printf("%*s = %p\n", al, "cnd_vp", cnd->cnd_vp); + cn = cnd->cnd_cn; + db_printf("%*s = %p\n", al, "cn_tp", cn->cn_tp); + db_printf("%*s = %d\n", al, "cn_pri", cn->cn_pri); + db_printf("%*s = %p\n", al, "cn_arg", cn->cn_arg); + db_printf("%*s = %d\n", al, "cn_unit", cn->cn_unit); + db_printf("%*s = %d ", al, "cn_flags", cn->cn_flags); + i = cn->cn_flags & CN_FLAG_NODEBUG; + if (i == 1) + db_printf("CN_FLAG_NODEBUG"); + if (cn->cn_flags & CN_FLAG_NOAVAIL) + db_printf("%s%s", i == 1 ? "," : "", + "CN_FLAG_NOAVAIL"); + db_printf("\n"); + db_printf("%*s = '%s'\n", al, "cn_namex", cn->cn_name); + n++; + } +} +#endif --- //depot/vendor/freebsd/src/sys/kern/vfs_subr.c 2007/12/27 20:56:57 +++ src/sys/kern/vfs_subr.c 2007/1226 01:56:49 @@ -39,7 +39,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/kern/vfs_subr.c,v 1.712 2007/12/27 20:52:05 attilio Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/vfs_subr.c,v 1.711 2007/12/25 17:51:59 rwatson Exp $"); #include "opt_ddb.h" #include "opt_mac.h" @@ -2210,7 +2210,7 @@ v_decr_useonly(vp); vp->v_iflag |= VI_OWEINACT; if (VOP_ISLOCKED(vp, NULL) != LK_EXCLUSIVE) { - error = VOP_LOCK(vp, LK_UPGRADE|LK_INTERLOCK|LK_NOWAIT, td); + error = VOP_LOCK(vp, LK_EXCLUPGRADE|LK_INTERLOCK|LK_NOWAIT, td); VI_LOCK(vp); if (error) { if (vp->v_usecount > 0) @@ -2699,8 +2699,10 @@ { struct vnode *vp; - if (!have_addr) + if (!have_addr) { + db_printf("Usage: show vnode \n"); return; + } vp = (struct vnode *)addr; vn_printf(vp, "vnode "); } --- //depot/vendor/freebsd/src/sys/powerpc/include/asm.h 2005/01/07 02:32:16 +++ src/sys/powerpc/include/asm.h 2007/1227 23:50:32 @@ -79,7 +79,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) + .section set_srcid,"a",@progbits + .p2align 0 + .asciz #s + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ --- //depot/vendor/freebsd/src/sys/sparc64/include/asm.h 2004/04/07 05:01:20 +++ src/sys/sparc64/include/asm.h 2007/1227 23:50:32 @@ -101,7 +101,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) + .section set_srcid,"a",@progbits + .p2align 0 + .asciz #s + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ --- //depot/vendor/freebsd/src/sys/sun4v/include/asm.h 2006/11/23 02:28:21 +++ src/sys/sun4v/include/asm.h 2007/1227 23:50:32 @@ -108,7 +108,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) + .section set_srcid,"a",@progbits + .p2align 0 + .asciz #s + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ --- //depot/vendor/freebsd/src/sys/sys/cdefs.h 2007/12/09 21:02:26 +++ src/sys/sys/cdefs.h 2007/1227 12:13:19 @@ -403,8 +403,12 @@ */ #ifndef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) -#else +#define __FBSDID(s) \ + __asm__(".section set_srcid, \"a\", @progbits"); \ + __asm__(".p2align 0"); \ + __asm__(".asciz " #s); \ + __asm__(".previous"); +#else /* defined(line) || defined(STRIP_FBSDID) */ #define __FBSDID(s) struct __hack #endif #endif --- //depot/vendor/freebsd/src/sys/sys/proc.h 2007/12/16 06:23:53 +++ src/sys/sys/proc.h 2007/1227 12:04:33 @@ -314,6 +314,7 @@ /* * Flags kept in td_flags: * To change these you MUST have the scheduler lock. + * Remember to keep those flags consistent with src/sys/ddb/db_ps.c. */ #define TDF_BORROWING 0x00000001 /* Thread is borrowing pri from another. */ #define TDF_INPANIC 0x00000002 /* Caused a panic, let it drive crashdump. */ @@ -349,7 +350,7 @@ /* * "Private" flags kept in td_pflags: - * These are only written by curthread and thus need no locking. + * Remember to keep those flags consistent with src/sys/ddb/db_ps.c. */ #define TDP_OLDMASK 0x00000001 /* Need to restore mask after suspend. */ #define TDP_INKTR 0x00000002 /* Thread is currently in KTR code. */ --- //depot/vendor/freebsd/src/sys/vm/vm_map.c 2007/11/07 21:57:26 +++ src/sys/vm/vm_map.c 2007/1227 15:28:33 @@ -3363,11 +3363,16 @@ DB_SHOW_COMMAND(map, vm_map_print) { static int nlines; - /* XXX convert args. */ - vm_map_t map = (vm_map_t)addr; - boolean_t full = have_addr; + vm_map_t map; + vm_map_entry_t entry; + boolean_t full; - vm_map_entry_t entry; + if (!have_addr) { + db_printf("Usage: show map \n"); + return; + } + map = (vm_map_t)addr; + full = have_addr; db_iprintf("Task map %p: pmap=%p, nentries=%d, version=%u\n", (void *)map, --- //depot/vendor/freebsd/src/sys/vm/vm_object.c 2007/11/17 22:57:01 +++ src/sys/vm/vm_object.c 2007/1227 15:28:33 @@ -2070,11 +2070,17 @@ */ DB_SHOW_COMMAND(object, vm_object_print_static) { - /* XXX convert args. */ - vm_object_t object = (vm_object_t)addr; - boolean_t full = have_addr; + vm_object_t object; + boolean_t full; + vm_page_t p; + + if (!have_addr) { + db_printf("Usage: show object \n"); + return; + } + object = (vm_object_t)addr; + full = have_addr; - vm_page_t p; /* XXX count is an (unused) arg. Avoid shadowing it. */ #define count was_count --- //depot/vendor/freebsd/src/usr.sbin/config/config.8 2007/05/12 21:41:47 +++ src/usr.sbin/config/config.8 2007/1227 14:19:16 @@ -28,7 +28,7 @@ .\" @(#)config.8 8.2 (Berkeley) 4/19/94 .\" $FreeBSD: src/usr.sbin/config/config.8,v 1.46 2007/05/12 19:38:18 wkoszek Exp $ .\" -.Dd May 8, 2007 +.Dd December 27, 2007 .Dt CONFIG 8 .Os .Sh NAME @@ -40,6 +40,7 @@ .Op Fl d Ar destdir .Ar SYSTEM_NAME .Nm +.Op Fl i .Op Fl x Ar kernel .Sh DESCRIPTION .\" This is the old version of the @@ -100,6 +101,23 @@ This option makes sense only if .Cd "options INCLUDE_CONFIG_FILE" entry was present in your configuration file. +.It Fl i +This flag can't be used separately. It works in conjunction +with +.Fl x +flag. It makes +.Nm +to print revision control system tags embedded in a +.Ar kernel +binary file. In order to print both the kernel configuration +file and revision control system tags, flag +.Fl i +can be specified twice. +Please note that revision control data is not preserved if +.Ar kernel +was built with +.Cd STRIP_FBSDID +environment variable set. .It Fl p Configure a system for profiling; for example, .Xr kgmon 8 --- //depot/vendor/freebsd/src/usr.sbin/config/main.c 2007/05/22 16:04:22 +++ src/usr.sbin/config/main.c 2007/1227 16:32:51 @@ -90,6 +90,7 @@ static void usage(void); static void cleanheaders(char *); static void kernconfdump(const char *); +static void srciddump(const char *file); struct hdr_list { char *h_name; @@ -105,13 +106,14 @@ { struct stat buf; - int ch, len; + int ch, flag_i, len; char *p; char xxx[MAXPATHLEN]; char *kernfile; + flag_i = 0; kernfile = NULL; - while ((ch = getopt(argc, argv, "Cd:gpVx:")) != -1) + while ((ch = getopt(argc, argv, "Cd:gipVx:")) != -1) switch (ch) { case 'C': filebased = 1; @@ -125,6 +127,9 @@ case 'g': debugging++; break; + case 'i': + flag_i++; + break; case 'p': profiling++; break; @@ -141,7 +146,15 @@ argc -= optind; argv += optind; + if (flag_i >= 1 && kernfile == NULL) + err(EXIT_FAILURE, "-i works only if -x is specified. See " + "config(8)"); if (kernfile != NULL) { + if (flag_i >= 1) { + srciddump(kernfile); + if (flag_i > 1) + exit(EXIT_SUCCESS); + } kernconfdump(kernfile); exit(EXIT_SUCCESS); } @@ -638,20 +651,57 @@ htab = hl; } +enum { + OPT_PRINT_DEFINED = 0, + OPT_PRINT_UNDEFINED = 1, +}; + +/* + * Map between optional ELF section and it's respective kernel compile + * time option. + */ +static struct { + const char *sectname; + const char *optname; + int onlack; +} optsects[] = { + /* + * "kern_conf" (embedded kernel file) is in the kernel binary + * when INCLUDE_CONFIG_FILE is defined. + */ + { "kern_conf", "INCLUDE_CONFIG_FILE", OPT_PRINT_UNDEFINED }, + + /* + * "srcid" section responsible for __FBSDID() handling is present if + * STRIP_FBSDID was *not* passed to the kernel at build stage. + */ + { "srcid", "STRIP_FBSDID", OPT_PRINT_DEFINED }, +}; + +#define SECTION_KERN_CONF 0 +#define SECTION_SRCIDS 1 +#define SECTION_MAX 1 + /* * This one is quick hack. Will be probably moved to elf(3) interface. * It takes kernel configuration file name, passes it as an argument to * elfdump -a, which output is parsed by some UNIX tools... */ static void -kernconfdump(const char *file) +section_dump(const char *file, int sectid) { struct stat st; FILE *fp, *pp; - int error, len, osz, r; + int error, len, neg, osz, r; unsigned int off, size; char *cmd, *o; + const char *optname, *sectname; + assert(sectid >= 0 && sectid <= SECTION_MAX && "wrong sectid!"); + optname = optsects[sectid].optname; + sectname = optsects[sectid].sectname; + neg = (optsects[sectid].onlack == OPT_PRINT_UNDEFINED); + r = open(file, O_RDONLY); if (r == -1) errx(EXIT_FAILURE, "Couldn't open file '%s'", file); @@ -668,8 +718,9 @@ if (o == NULL) errx(EXIT_FAILURE, "Couldn't allocate memory"); /* ELF note section header. */ - asprintf(&cmd, "/usr/bin/elfdump -c %s | grep -A 5 kern_conf" - "| tail -2 | cut -d ' ' -f 2 | paste - - -", file); + asprintf(&cmd, "/usr/bin/elfdump -c %s | grep -A 5 %s" + "| tail -2 | cut -d ' ' -f 2 | paste - - -", file, + sectname); if (cmd == NULL) errx(EXIT_FAILURE, "asprintf() failed"); pp = popen(cmd, "r"); @@ -681,9 +732,10 @@ r = sscanf(o, "%d\t%d", &off, &size); free(o); if (r != 2) - errx(EXIT_FAILURE, "File %s doesn't contain configuration " - "file. Either unsupported, or not compiled with " - "INCLUDE_CONFIG_FILE", file); + errx(EXIT_FAILURE, "File %s doesn't provide required " + "data.\nLooks like the kernel option %s was %s " + "defined at build time.\n", file, optname, + neg == 1 ? "not" : ""); r = fseek(fp, off, SEEK_CUR); if (r != 0) errx(EXIT_FAILURE, "fseek() failed"); @@ -691,3 +743,17 @@ fputc(r, stdout); fclose(fp); } + +static void +kernconfdump(const char *file) +{ + + section_dump(file, SECTION_KERN_CONF); +} + +static void +srciddump(const char *file) +{ + + section_dump(file, SECTION_SRCIDS); +}