diff -ru /usr/src/sys/amd64/include/asm.h sys/amd64/include/asm.h --- /usr/src/sys/amd64/include/asm.h 2007-12-30 13:49:11.000000000 +0000 +++ sys/amd64/include/asm.h 2007-12-30 22:09:37.000000000 +0000 @@ -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 */ Only in /usr/src/sys/arm/compile: KB920X diff -ru /usr/src/sys/arm/include/asm.h sys/arm/include/asm.h --- /usr/src/sys/arm/include/asm.h 2007-12-30 13:49:12.000000000 +0000 +++ sys/arm/include/asm.h 2008-01-03 01:19:27.000000000 +0000 @@ -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 Only in /usr/src/sys/compat/linux: fluxbox.core Only in sys: db_command.c.0.patch diff -ru /usr/src/sys/ddb/db_command.c sys/ddb/db_command.c --- /usr/src/sys/ddb/db_command.c 2007-12-30 13:49:21.000000000 +0000 +++ sys/ddb/db_command.c 2007-12-31 19:46:26.000000000 +0000 @@ -103,50 +103,50 @@ }; static struct command db_commands[] = { - { "print", db_print_cmd, 0, 0 }, - { "p", db_print_cmd, 0, 0 }, - { "examine", db_examine_cmd, CS_SET_DOT, 0 }, - { "x", db_examine_cmd, CS_SET_DOT, 0 }, - { "search", db_search_cmd, CS_OWN|CS_SET_DOT, 0 }, - { "set", db_set_cmd, CS_OWN, 0 }, - { "write", db_write_cmd, CS_MORE|CS_SET_DOT, 0 }, - { "w", db_write_cmd, CS_MORE|CS_SET_DOT, 0 }, - { "delete", db_delete_cmd, 0, 0 }, - { "d", db_delete_cmd, 0, 0 }, - { "break", db_breakpoint_cmd, 0, 0 }, - { "b", db_breakpoint_cmd, 0, 0 }, - { "dwatch", db_deletewatch_cmd, 0, 0 }, - { "watch", db_watchpoint_cmd, CS_MORE,0 }, - { "dhwatch", db_deletehwatch_cmd, 0, 0 }, - { "hwatch", db_hwatchpoint_cmd, 0, 0 }, - { "step", db_single_step_cmd, 0, 0 }, - { "s", db_single_step_cmd, 0, 0 }, - { "continue", db_continue_cmd, 0, 0 }, - { "c", db_continue_cmd, 0, 0 }, - { "until", db_trace_until_call_cmd,0, 0 }, - { "next", db_trace_until_matching_cmd,0, 0 }, - { "match", db_trace_until_matching_cmd,0, 0 }, - { "trace", db_stack_trace, CS_OWN, 0 }, - { "t", db_stack_trace, CS_OWN, 0 }, { "alltrace", db_stack_trace_all, 0, 0 }, - { "where", db_stack_trace, CS_OWN, 0 }, + { "b", db_breakpoint_cmd, 0, 0 }, + { "break", db_breakpoint_cmd, 0, 0 }, { "bt", db_stack_trace, CS_OWN, 0 }, + { "c", db_continue_cmd, 0, 0 }, { "call", db_fncall, CS_OWN, 0 }, - { "show", 0, 0, &db_show_table }, - { "ps", db_ps, 0, 0 }, + { "capture", db_capture_cmd, CS_OWN, 0 }, + { "continue", db_continue_cmd, 0, 0 }, + { "d", db_delete_cmd, 0, 0 }, + { "delete", db_delete_cmd, 0, 0 }, + { "dhwatch", db_deletehwatch_cmd, 0, 0 }, + { "dwatch", db_deletewatch_cmd, 0, 0 }, + { "examine", db_examine_cmd, CS_SET_DOT, 0 }, { "gdb", db_gdb, 0, 0 }, { "halt", db_halt, 0, 0 }, + { "hwatch", db_hwatchpoint_cmd, 0, 0 }, + { "kill", db_kill, CS_OWN, 0 }, + { "match", db_trace_until_matching_cmd,0, 0 }, + { "next", db_trace_until_matching_cmd,0, 0 }, + { "p", db_print_cmd, 0, 0 }, + { "print", db_print_cmd, 0, 0 }, + { "ps", db_ps, 0, 0 }, { "reboot", db_reset, 0, 0 }, { "reset", db_reset, 0, 0 }, - { "kill", db_kill, CS_OWN, 0 }, - { "watchdog", db_watchdog, 0, 0 }, - { "thread", db_set_thread, CS_OWN, 0 }, { "run", db_run_cmd, CS_OWN, 0 }, + { "s", db_single_step_cmd, 0, 0 }, { "script", db_script_cmd, CS_OWN, 0 }, { "scripts", db_scripts_cmd, 0, 0 }, - { "unscript", db_unscript_cmd, CS_OWN, 0 }, - { "capture", db_capture_cmd, CS_OWN, 0 }, + { "search", db_search_cmd, CS_OWN|CS_SET_DOT, 0 }, + { "set", db_set_cmd, CS_OWN, 0 }, + { "show", 0, 0, &db_show_table }, + { "step", db_single_step_cmd, 0, 0 }, + { "t", db_stack_trace, CS_OWN, 0 }, { "textdump", db_textdump_cmd, CS_OWN, 0 }, + { "thread", db_set_thread, CS_OWN, 0 }, + { "trace", db_stack_trace, CS_OWN, 0 }, + { "unscript", db_unscript_cmd, CS_OWN, 0 }, + { "until", db_trace_until_call_cmd,0, 0 }, + { "w", db_write_cmd, CS_MORE|CS_SET_DOT, 0 }, + { "watch", db_watchpoint_cmd, CS_MORE,0 }, + { "watchdog", db_watchdog, 0, 0 }, + { "where", db_stack_trace, CS_OWN, 0 }, + { "write", db_write_cmd, CS_MORE|CS_SET_DOT, 0 }, + { "x", db_examine_cmd, CS_SET_DOT, 0 }, { (char *)0, } }; @@ -268,23 +268,50 @@ return (result); } +static int +db_cmd_cmp(const void *a, const void *b) +{ + const char **ap; + const char **bp; + + ap = __DECONST(const char **, a); + bp = __DECONST(const char **, b); + + return (strcmp(*ap, *bp)); +} + +/* + * Unless number of both: staticly compiled commands and those brought + * to the DDB by DB_COMMAND() and DB_SHOW_COMMANDS() macros doesn't + * exceed db_cmdlist_tmp[] array size, the list of commands will consist + * all of them. + */ +static char *db_cmdlist_tmp[256]; + static void db_cmd_list(table) struct command_table *table; { register struct command *cmd; register struct command **aux_cmdp; + int i, j, n; - for (cmd = table->table; cmd->name != 0; cmd++) { - db_printf("%-12s", cmd->name); - db_end_line(12); - } - if (table->aux_tablep == NULL) - return; - for (aux_cmdp = table->aux_tablep; aux_cmdp < table->aux_tablep_end; - aux_cmdp++) { - db_printf("%-12s", (*aux_cmdp)->name); - db_end_line(12); + n = sizeof(db_cmdlist_tmp) / sizeof(db_cmdlist_tmp[0]); + for (i = 0; i < n; i++) + db_cmdlist_tmp[i] = NULL; + for (cmd = table->table, i = 0; cmd->name != 0 && i < n; + cmd++, i++) + db_cmdlist_tmp[i] = cmd->name; + if (table->aux_tablep != NULL) { + for (aux_cmdp = table->aux_tablep; + aux_cmdp < table->aux_tablep_end && i < n; + aux_cmdp++, i++) + db_cmdlist_tmp[i] = (*aux_cmdp)->name; + } + qsort(db_cmdlist_tmp, i, sizeof(db_cmdlist_tmp[0]), db_cmd_cmp); + for (j = 0; j < i; j++) { + db_printf("%-12s", db_cmdlist_tmp[j]); + db_end_line(12); } } diff -ru /usr/src/sys/ddb/db_ps.c sys/ddb/db_ps.c --- /usr/src/sys/ddb/db_ps.c 2007-12-30 13:49:21.000000000 +0000 +++ sys/ddb/db_ps.c 2007-12-30 22:09:38.000000000 +0000 @@ -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: diff -ru /usr/src/sys/ddb/db_textdump.c sys/ddb/db_textdump.c --- /usr/src/sys/ddb/db_textdump.c 2007-12-30 13:49:21.000000000 +0000 +++ sys/ddb/db_textdump.c 2008-01-08 20:10:24.000000000 +0000 @@ -137,6 +137,7 @@ #define TAR_CONFIG_FILENAME "config.txt" /* Kernel configuration. */ #define TAR_MSGBUF_FILENAME "msgbuf.txt" /* Kernel messsage buffer. */ #define TAR_PANIC_FILENAME "panic.txt" /* Panic message. */ +#define TAR_SRCIDS_FILENAME "srcids.txt" /* VCS strings. */ #define TAR_VERSION_FILENAME "version.txt" /* Kernel version. */ /* @@ -160,6 +161,15 @@ SYSCTL_INT(_debug_ddb_textdump, OID_AUTO, do_panic, CTLFLAG_RW, &textdump_do_panic, 0, "Dump kernel panic message in textdump"); +/* + * With old VCS macro we don't get revision control strings. + */ +#if !defined(OLD_FBSDID) && !defined(STRIP_FBSDID) +static int textdump_do_srcids = 1; +SYSCTL_INT(_debug_ddb_textdump, OID_AUTO, do_srcids, CTLFLAG_RW, + &textdump_do_srcids, 0, "Dump kernel source files' version"); +#endif + static int textdump_do_version = 1; SYSCTL_INT(_debug_ddb_textdump, OID_AUTO, do_version, CTLFLAG_RW, &textdump_do_version, 0, "Dump kernel version string in textdump"); @@ -332,6 +342,77 @@ } #endif /* INCLUDE_CONFIG_FILE */ +#if !defined(OLD_FBSDID) && !defined(STRIP_FBSDID) +/* + * Magic generated by the gcc(1) to mark the section ranges with special + * variable names. + * + * XXX: Those should go somewhere else (maybe globally), as I use them + * also in kern_mib.c. + */ +extern char __start_set_srcid[]; +extern char __stop_set_srcid[]; + +#define FBSDID_BEGIN (&__start_set_srcid[0]) +#define FBSDID_END (&__stop_set_srcid[0]) + +/* + * Dump revision control information. + */ +static void +textdump_dump_srcids(struct dumperinfo *di) +{ + u_int len; + char c; + char *bid, *eid, *s; + int needflush; + int idx; + + bid = s = FBSDID_BEGIN; + eid = FBSDID_END; + len = eid - bid; + bzero(textdump_block_buffer, sizeof(textdump_block_buffer)); + textdump_mkustar(textdump_block_buffer, TAR_SRCIDS_FILENAME, len); + (void)textdump_writenextblock(di, textdump_block_buffer); + + needflush = 0; + idx = 0; + do { + if (*s == '\0') + c = '\n'; + else + c = *s; + if (idx == sizeof(textdump_block_buffer)) { + /* + * Block was full. Write it. We'll try to get + * current character handled handled correctly + * in the next iteration. + */ + (void)textdump_writenextblock(di, + textdump_block_buffer); + idx = 0; + needflush = 0; + continue; + } else { + textdump_block_buffer[idx] = c; + idx++; + needflush++; + s++; + } + } while (s < eid); + + if (needflush > 0) { + KASSERT(needflush < sizeof(textdump_block_buffer), + ("needflush is bigger than the textdump block " + "size")); + bzero(textdump_block_buffer + needflush, + sizeof(textdump_block_buffer) - needflush); + (void)textdump_writenextblock(di, textdump_block_buffer); + } +} +#endif + + /* * Dump kernel message buffer. */ @@ -481,6 +562,10 @@ textdump_dump_msgbuf(di); if (textdump_do_panic && panicstr != NULL) textdump_dump_panic(di); +#if !defined(OLD_FBSDID) && !defined(STRIP_FBSDID) + if (textdump_do_srcids) + textdump_dump_srcids(di); +#endif if (textdump_do_version) textdump_dump_version(di); diff -ru /usr/src/sys/i386/i386/local_apic.c sys/i386/i386/local_apic.c --- /usr/src/sys/i386/i386/local_apic.c 2007-12-30 13:54:25.000000000 +0000 +++ sys/i386/i386/local_apic.c 2007-12-30 22:09:38.000000000 +0000 @@ -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; diff -ru /usr/src/sys/i386/include/asm.h sys/i386/include/asm.h --- /usr/src/sys/i386/include/asm.h 2007-12-30 13:54:25.000000000 +0000 +++ sys/i386/include/asm.h 2007-12-30 22:09:38.000000000 +0000 @@ -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 */ diff -ru /usr/src/sys/ia64/include/asm.h sys/ia64/include/asm.h --- /usr/src/sys/ia64/include/asm.h 2007-12-30 13:54:27.000000000 +0000 +++ sys/ia64/include/asm.h 2007-12-30 22:09:38.000000000 +0000 @@ -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 */ diff -ru /usr/src/sys/kern/kern_mib.c sys/kern/kern_mib.c --- /usr/src/sys/kern/kern_mib.c 2008-01-08 02:46:46.000000000 +0000 +++ sys/kern/kern_mib.c 2008-01-08 01:32:07.000000000 +0000 @@ -38,6 +38,7 @@ #include __FBSDID("$FreeBSD: src/sys/kern/kern_mib.c,v 1.86 2007/12/31 22:03:57 jhb 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[]; diff -ru /usr/src/sys/kern/subr_lock.c sys/kern/subr_lock.c --- /usr/src/sys/kern/subr_lock.c 2008-01-08 02:46:47.000000000 +0000 +++ sys/kern/subr_lock.c 2007-12-31 12:23:45.000000000 +0000 @@ -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)); diff -ru /usr/src/sys/kern/subr_rman.c sys/kern/subr_rman.c --- /usr/src/sys/kern/subr_rman.c 2007-12-30 13:54:28.000000000 +0000 +++ sys/kern/subr_rman.c 2007-12-30 22:09:39.000000000 +0000 @@ -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) diff -ru /usr/src/sys/kern/subr_sleepqueue.c sys/kern/subr_sleepqueue.c --- /usr/src/sys/kern/subr_sleepqueue.c 2007-12-30 13:54:28.000000000 +0000 +++ sys/kern/subr_sleepqueue.c 2007-12-30 22:09:40.000000000 +0000 @@ -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 diff -ru /usr/src/sys/kern/subr_turnstile.c sys/kern/subr_turnstile.c --- /usr/src/sys/kern/subr_turnstile.c 2007-12-30 13:54:28.000000000 +0000 +++ sys/kern/subr_turnstile.c 2007-12-30 22:09:40.000000000 +0000 @@ -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 diff -ru /usr/src/sys/kern/vfs_subr.c sys/kern/vfs_subr.c --- /usr/src/sys/kern/vfs_subr.c 2007-12-30 13:54:28.000000000 +0000 +++ sys/kern/vfs_subr.c 2007-12-30 22:09:42.000000000 +0000 @@ -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 "); } diff -ru /usr/src/sys/powerpc/include/asm.h sys/powerpc/include/asm.h --- /usr/src/sys/powerpc/include/asm.h 2007-12-30 13:54:39.000000000 +0000 +++ sys/powerpc/include/asm.h 2007-12-30 22:09:42.000000000 +0000 @@ -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 */ Only in sys/sparc64/conf: MINI diff -ru /usr/src/sys/sparc64/include/asm.h sys/sparc64/include/asm.h --- /usr/src/sys/sparc64/include/asm.h 2007-12-30 13:54:40.000000000 +0000 +++ sys/sparc64/include/asm.h 2007-12-30 22:09:42.000000000 +0000 @@ -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 */ diff -ru /usr/src/sys/sun4v/include/asm.h sys/sun4v/include/asm.h --- /usr/src/sys/sun4v/include/asm.h 2007-12-30 13:54:41.000000000 +0000 +++ sys/sun4v/include/asm.h 2007-12-30 22:09:42.000000000 +0000 @@ -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 */ diff -ru /usr/src/sys/sys/cdefs.h sys/sys/cdefs.h --- /usr/src/sys/sys/cdefs.h 2007-12-30 13:54:41.000000000 +0000 +++ sys/sys/cdefs.h 2008-01-08 01:32:19.000000000 +0000 @@ -402,11 +402,52 @@ * __FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.94 2007/12/09 21:00:36 alc Exp $"); */ #ifndef __FBSDID -#if !defined(lint) && !defined(STRIP_FBSDID) +#if defined(lint) || defined(STRIP_FBSDID) +#define __FBSDID(s) struct __hack +#else +/* + * We want to have tags embedded. We let the user choose between the + * behaviour he wants to have. This can still be old, bare and boring + * FBSDID... Note that you won't get kern.srcids handling that way. + */ +#if defined(OLD_FBSDID) #define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) #else -#define __FBSDID(s) struct __hack +/* + * Smart user however prefers fully featured, brand new one FBSDID. + * This is the right choice to get kern.srcids working. DDB command + * "show srcids" included as well. + * + * ARM is a bit special. + */ +#ifdef __arm__ +#define FBSDID_SECTYPE "%progbits" +#else +#define FBSDID_SECTYPE "@progbits" +#endif + +/* + * i386, amd64 and ia64 are special too--instead of: .section "name", + * they want: .section name + */ +#if defined(__i386__) || defined(__amd64__) || defined(__ia64__) +#define FBSDID_SECTION() \ + __asm__(".section set_srcid,\"a\"," FBSDID_SECTYPE) +#else /* expect __sparc64__, __arm__, __powerpc__ and __sun4v */ +#define FBSDID_SECTION() \ + __asm__(".section \"set_srcid\",\"a\"," FBSDID_SECTYPE) #endif + +/* + * And finally + */ +#define __FBSDID(s) \ + FBSDID_SECTION(); \ + __asm__(".p2align 0"); \ + __asm__(".asciz " #s); \ + __asm__(".previous"); +#endif /* __FBSDID */ +#endif /* defined(STRIP_FBSDID) || defined(lint) */ #endif #ifndef __RCSID diff -ru /usr/src/sys/sys/proc.h sys/sys/proc.h --- /usr/src/sys/sys/proc.h 2007-12-30 13:54:42.000000000 +0000 +++ sys/sys/proc.h 2007-12-30 22:09:43.000000000 +0000 @@ -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. */ diff -ru /usr/src/sys/vm/vm_map.c sys/vm/vm_map.c --- /usr/src/sys/vm/vm_map.c 2008-01-08 02:46:50.000000000 +0000 +++ sys/vm/vm_map.c 2008-01-08 01:32:23.000000000 +0000 @@ -3365,11 +3365,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; + + 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, diff -ru /usr/src/sys/vm/vm_object.c sys/vm/vm_object.c --- /usr/src/sys/vm/vm_object.c 2007-12-30 13:49:10.000000000 +0000 +++ sys/vm/vm_object.c 2007-12-31 12:23:46.000000000 +0000 @@ -2115,12 +2115,18 @@ */ 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; + + /* XXX count is an (unused) arg. Avoid shadowing it. */ #define count was_count