diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-11-05 15:17:51 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-11-05 15:17:51 +0000 |
commit | 6ff2a25ce0873fc736b6eaf7626f1345b6946ce0 (patch) | |
tree | 3a1e82b6ff60a2e7f12fda7a2ffe6152e0982ff4 | |
parent | 89c67b89ea588b9f49cf468d507fcb13123316ff (diff) |
Implement m_print as real ddb command "show mbuf addr" in the way other
such commands are implemented.
"Ja! You'll need to update ddb.4 as well, of course." miod@
-rw-r--r-- | sys/ddb/db_command.c | 10 | ||||
-rw-r--r-- | sys/ddb/db_command.h | 3 | ||||
-rw-r--r-- | sys/ddb/db_interface.h | 5 | ||||
-rw-r--r-- | sys/kern/uipc_mbuf.c | 43 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 5 |
5 files changed, 40 insertions, 26 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 3bf33d09eaf..b55479d8d04 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.61 2010/01/19 01:08:16 guenther Exp $ */ +/* $OpenBSD: db_command.c,v 1.62 2010/11/05 15:17:50 claudio Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -324,6 +324,13 @@ db_malloc_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) /*ARGSUSED*/ void +db_mbuf_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) +{ + m_print((void *)addr, db_printf); +} + +/*ARGSUSED*/ +void db_mount_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { boolean_t full = FALSE; @@ -512,6 +519,7 @@ struct db_command db_show_cmds[] = { { "extents", db_extent_print_cmd, 0, NULL }, { "malloc", db_malloc_print_cmd, 0, NULL }, { "map", db_map_print_cmd, 0, NULL }, + { "mbuf", db_mbuf_print_cmd, 0, NULL }, { "mount", db_mount_print_cmd, 0, NULL }, #ifdef NFSCLIENT { "nfsreq", db_nfsreq_print_cmd, 0, NULL }, diff --git a/sys/ddb/db_command.h b/sys/ddb/db_command.h index db97043cecf..087e5e87145 100644 --- a/sys/ddb/db_command.h +++ b/sys/ddb/db_command.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.h,v 1.29 2009/08/17 13:11:58 jasper Exp $ */ +/* $OpenBSD: db_command.h,v 1.30 2010/11/05 15:17:50 claudio Exp $ */ /* $NetBSD: db_command.h,v 1.8 1996/02/05 01:56:55 christos Exp $ */ /* @@ -41,6 +41,7 @@ void db_command(struct db_command **, struct db_command *); void db_buf_print_cmd(db_expr_t, int, db_expr_t, char *); void db_map_print_cmd(db_expr_t, int, db_expr_t, char *); void db_malloc_print_cmd(db_expr_t, int, db_expr_t, char *); +void db_mbuf_print_cmd(db_expr_t, int, db_expr_t, char *); void db_mount_print_cmd(db_expr_t, int, db_expr_t, char *); void db_show_all_mounts(db_expr_t, int, db_expr_t, char *); void db_show_all_vnodes(db_expr_t, int, db_expr_t, char *); diff --git a/sys/ddb/db_interface.h b/sys/ddb/db_interface.h index 8be1e9b3d75..bcd4956975b 100644 --- a/sys/ddb/db_interface.h +++ b/sys/ddb/db_interface.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.h,v 1.15 2009/08/17 13:11:58 jasper Exp $ */ +/* $OpenBSD: db_interface.h,v 1.16 2010/11/05 15:17:50 claudio Exp $ */ /* $NetBSD: db_interface.h,v 1.1 1996/02/05 01:57:03 christos Exp $ */ /* @@ -55,6 +55,9 @@ void vfs_mount_print(struct mount *, int, int (*)(const char *, ...)); /* kern/subr_pool.c */ void db_show_all_pools(db_expr_t, int, db_expr_t, char *); +/* kern/uipc_mbuf.c */ +void m_print(void *, int (*)(const char *, ...)); + /* nfs/nfs_debug.c */ void db_show_all_nfsreqs(db_expr_t, int, db_expr_t, char *); void nfs_request_print(void *, int, int (*)(const char *, ...)); diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index b082e35c4d1..bd5f8da413b 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.146 2010/10/28 16:28:56 claudio Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.147 2010/11/05 15:17:50 claudio Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -1372,44 +1372,49 @@ m_dup_pkthdr(struct mbuf *to, struct mbuf *from) } #ifdef DDB +#include <machine/db_machdep.h> +#include <ddb/db_interface.h> + void -m_print(struct mbuf *m) +m_print(void *v, int (*pr)(const char *, ...)) { - printf("mbuf %p\n", m); - printf("m_type: %hi\tm_flags: %b\n", m->m_type, m->m_flags, + struct mbuf *m = v; + + (*pr)("mbuf %p\n", m); + (*pr)("m_type: %hi\tm_flags: %b\n", m->m_type, m->m_flags, "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_CLUSTER\5M_PROTO1\6M_VLANTAG" "\7M_LOOP\10M_FILDROP\11M_BCAST\12M_MCAST\13M_CONF\14M_AUTH" "\15M_TUNNEL\16M_AUTH_AH\17M_LINK0"); - printf("m_next: %p\tm_nextpkt: %p\n", m->m_next, m->m_nextpkt); - printf("m_data: %p\tm_len: %u\n", m->m_data, m->m_len); - printf("m_dat: %p m_pktdat: %p\n", m->m_dat, m->m_pktdat); + (*pr)("m_next: %p\tm_nextpkt: %p\n", m->m_next, m->m_nextpkt); + (*pr)("m_data: %p\tm_len: %u\n", m->m_data, m->m_len); + (*pr)("m_dat: %p m_pktdat: %p\n", m->m_dat, m->m_pktdat); if (m->m_flags & M_PKTHDR) { - printf("m_pkthdr.len: %i\tm_ptkhdr.rcvif: %p\t" + (*pr)("m_pkthdr.len: %i\tm_ptkhdr.rcvif: %p\t" "m_ptkhdr.rdomain: %u\n", m->m_pkthdr.len, m->m_pkthdr.rcvif, m->m_pkthdr.rdomain); - printf("m_ptkhdr.tags: %p\tm_pkthdr.tagsset: %hx\n", + (*pr)("m_ptkhdr.tags: %p\tm_pkthdr.tagsset: %hx\n", SLIST_FIRST(&m->m_pkthdr.tags), m->m_pkthdr.tagsset); - printf("m_pkthdr.csum_flags: %hx\tm_pkthdr.ether_vtag: %hu\n", + (*pr)("m_pkthdr.csum_flags: %hx\tm_pkthdr.ether_vtag: %hu\n", m->m_pkthdr.csum_flags, m->m_pkthdr.ether_vtag); - printf("m_pkthdr.pf.flags: %b\n", + (*pr)("m_pkthdr.pf.flags: %b\n", m->m_pkthdr.pf.flags, "\20\1GENERATED\2FRAGCACHE" "\3TRANSLATE_LOCALHOST\4DIVERTED\5DIVERTED_PACKET" "\6PF_TAG_REROUTE"); - printf("m_pkthdr.pf.hdr: %p\tm_pkthdr.pf.statekey: %p\n", + (*pr)("m_pkthdr.pf.hdr: %p\tm_pkthdr.pf.statekey: %p\n", m->m_pkthdr.pf.hdr, m->m_pkthdr.pf.statekey); - printf("m_pkthdr.pf.qid:\t%u m_pkthdr.pf.tag: %hu\n", + (*pr)("m_pkthdr.pf.qid:\t%u m_pkthdr.pf.tag: %hu\n", m->m_pkthdr.pf.qid, m->m_pkthdr.pf.tag); - printf("m_pkthdr.pf.routed: %hhx\n", m->m_pkthdr.pf.routed); + (*pr)("m_pkthdr.pf.routed: %hhx\n", m->m_pkthdr.pf.routed); } if (m->m_flags & M_EXT) { - printf("m_ext.ext_buf: %p\tm_ext.ext_size: %u\n", + (*pr)("m_ext.ext_buf: %p\tm_ext.ext_size: %u\n", m->m_ext.ext_buf, m->m_ext.ext_size); - printf("m_ext.ext_type: %x\tm_ext.ext_backend: %i\n", + (*pr)("m_ext.ext_type: %x\tm_ext.ext_backend: %i\n", m->m_ext.ext_type, m->m_ext.ext_backend); - printf("m_ext.ext_ifp: %p\n", m->m_ext.ext_ifp); - printf("m_ext.ext_free: %p\tm_ext.ext_arg: %p\n", + (*pr)("m_ext.ext_ifp: %p\n", m->m_ext.ext_ifp); + (*pr)("m_ext.ext_free: %p\tm_ext.ext_arg: %p\n", m->m_ext.ext_free, m->m_ext.ext_arg); - printf("m_ext.ext_nextref: %p\tm_ext.ext_prevref: %p\n", + (*pr)("m_ext.ext_nextref: %p\tm_ext.ext_prevref: %p\n", m->m_ext.ext_nextref, m->m_ext.ext_prevref); } } diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 50ac4cad89b..7c98c2fc468 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.143 2010/10/28 16:28:56 claudio Exp $ */ +/* $OpenBSD: mbuf.h,v 1.144 2010/11/05 15:17:50 claudio Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -420,9 +420,6 @@ void m_zero(struct mbuf *); int m_apply(struct mbuf *, int, int, int (*)(caddr_t, caddr_t, unsigned int), caddr_t); int m_dup_pkthdr(struct mbuf *, struct mbuf *); -#ifdef DDB -void m_print(struct mbuf *); -#endif /* Packet tag routines */ struct m_tag *m_tag_get(int, int, int); |