diff options
author | bz <bz@FreeBSD.org> | 2010-02-09 22:39:34 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2010-02-09 22:39:34 +0000 |
commit | 7b5cc4e51b57df31f63a8d802fe6c25ad3461194 (patch) | |
tree | 8ea333e2e0d992b200d0eb1a9a0d490e21d47b08 | |
parent | 54ac71ad0f6c9320cedd699c4dce60be1177e418 (diff) | |
download | FreeBSD-src-7b5cc4e51b57df31f63a8d802fe6c25ad3461194.zip FreeBSD-src-7b5cc4e51b57df31f63a8d802fe6c25ad3461194.tar.gz |
Add DDB support for printing vnet_sysinit and vnet_sysuninit
ordered call lists. Try to lookup function/symbol names and print
those in addition to the pointers, along with the constants for
subsystem and order.
This is useful for debugging vnet teardown ordering issues.
Make it possible to call the actual printing frunction from normal
code at runtime, ie. from vnet_sysuninit(), if DDB support is there.
Sponsored by: ISPsystem
MFC After: 8 days
-rw-r--r-- | sys/net/vnet.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/sys/net/vnet.c b/sys/net/vnet.c index fe8df65..323ed08 100644 --- a/sys/net/vnet.c +++ b/sys/net/vnet.c @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #ifdef DDB #include <ddb/ddb.h> +#include <ddb/db_sym.h> #endif #include <net/if.h> @@ -219,6 +220,10 @@ SDT_PROBE_DEFINE2(vnet, functions, vnet_alloc, return, "int", "struct vnet *"); SDT_PROBE_DEFINE2(vnet, functions, vnet_destroy, entry, "int", "struct vnet *"); SDT_PROBE_DEFINE1(vnet, functions, vnet_destroy, return, "int"); +#ifdef DDB +static void db_show_vnet_print_vs(struct vnet_sysinit *, int); +#endif + /* * Allocate a virtual network stack. */ @@ -713,6 +718,64 @@ DB_SHOW_COMMAND(vnets, db_show_vnets) } } +static void +db_show_vnet_print_vs(struct vnet_sysinit *vs, int ddb) +{ + const char *vsname, *funcname; + c_db_sym_t sym; + db_expr_t offset; + +#define xprint(...) \ + if (ddb) \ + db_printf(__VA_ARGS__); \ + else \ + printf(__VA_ARGS__) + + if (vs == NULL) { + xprint("%s: no vnet_sysinit * given\n", __func__); + return; + } + + sym = db_search_symbol((vm_offset_t)vs, DB_STGY_ANY, &offset); + db_symbol_values(sym, &vsname, NULL); + sym = db_search_symbol((vm_offset_t)vs->func, DB_STGY_PROC, &offset); + db_symbol_values(sym, &funcname, NULL); + xprint("%s(%p)\n", (vsname != NULL) ? vsname : "", vs); + xprint(" 0x%08x 0x%08x\n", vs->subsystem, vs->order); + xprint(" %p(%s)(%p)\n", + vs->func, (funcname != NULL) ? funcname : "", vs->arg); +#undef xprint +} + +DB_SHOW_COMMAND(vnet_sysinit, db_show_vnet_sysinit) +{ + struct vnet_sysinit *vs; + + db_printf("VNET_SYSINIT vs Name(Ptr)\n"); + db_printf(" Subsystem Order\n"); + db_printf(" Function(Name)(Arg)\n"); + TAILQ_FOREACH(vs, &vnet_constructors, link) { + db_show_vnet_print_vs(vs, 1); + if (db_pager_quit) + break; + } +} + +DB_SHOW_COMMAND(vnet_sysuninit, db_show_vnet_sysuninit) +{ + struct vnet_sysinit *vs; + + db_printf("VNET_SYSUNINIT vs Name(Ptr)\n"); + db_printf(" Subsystem Order\n"); + db_printf(" Function(Name)(Arg)\n"); + TAILQ_FOREACH_REVERSE(vs, &vnet_destructors, vnet_sysuninit_head, + link) { + db_show_vnet_print_vs(vs, 1); + if (db_pager_quit) + break; + } +} + #ifdef VNET_DEBUG DB_SHOW_COMMAND(vnetrcrs, db_show_vnetrcrs) { |