add ddb "sh mbuf" command.
This commit is contained in:
parent
25196f3ee3
commit
e8a3b3eb83
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_command.c,v 1.82 2005/12/01 13:21:05 yamt Exp $ */
|
||||
/* $NetBSD: db_command.c,v 1.83 2006/01/24 13:02:57 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.82 2005/12/01 13:21:05 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.83 2006/01/24 13:02:57 yamt Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_kgdb.h"
|
||||
|
@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.82 2005/12/01 13:21:05 yamt Exp $")
|
|||
#include <sys/reboot.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/namei.h>
|
||||
#include <sys/pool.h>
|
||||
#include <sys/proc.h>
|
||||
|
@ -120,6 +121,7 @@ static void db_sync_cmd(db_expr_t, int, db_expr_t, const char *);
|
|||
static void db_uvmexp_print_cmd(db_expr_t, int, db_expr_t, const char *);
|
||||
static void db_vnode_print_cmd(db_expr_t, int, db_expr_t, const char *);
|
||||
static void db_mount_print_cmd(db_expr_t, int, db_expr_t, const char *);
|
||||
static void db_mbuf_print_cmd(db_expr_t, int, db_expr_t, const char *);
|
||||
|
||||
/*
|
||||
* 'show' commands
|
||||
|
@ -143,6 +145,7 @@ static const struct db_command db_show_cmds[] = {
|
|||
{ "malloc", db_malloc_print_cmd, 0, NULL },
|
||||
{ "map", db_map_print_cmd, 0, NULL },
|
||||
{ "mount", db_mount_print_cmd, 0, NULL },
|
||||
{ "mbuf", db_mbuf_print_cmd, 0, NULL },
|
||||
{ "ncache", db_namecache_print_cmd, 0, NULL },
|
||||
{ "object", db_object_print_cmd, 0, NULL },
|
||||
{ "page", db_page_print_cmd, 0, NULL },
|
||||
|
@ -620,6 +623,15 @@ db_mount_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *m
|
|||
vfs_mount_print((struct mount *)(intptr_t) addr, full, db_printf);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
db_mbuf_print_cmd(db_expr_t addr, int have_addr, db_expr_t count,
|
||||
const char *modif)
|
||||
{
|
||||
|
||||
m_print((const struct mbuf *)(intptr_t) addr, modif, db_printf);
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
db_pool_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: uipc_mbuf.c,v 1.104 2005/12/26 18:45:27 perry Exp $ */
|
||||
/* $NetBSD: uipc_mbuf.c,v 1.105 2006/01/24 13:02:58 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -69,9 +69,10 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.104 2005/12/26 18:45:27 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.105 2006/01/24 13:02:58 yamt Exp $");
|
||||
|
||||
#include "opt_mbuftrace.h"
|
||||
#include "opt_ddb.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -1377,3 +1378,63 @@ m_getptr(struct mbuf *m, int loc, int *off)
|
|||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#if defined(DDB)
|
||||
void
|
||||
m_print(const struct mbuf *m, const char *modif, void (*pr)(const char *, ...))
|
||||
{
|
||||
char ch;
|
||||
boolean_t opt_c = FALSE;
|
||||
char buf[512];
|
||||
|
||||
while ((ch = *(modif++)) != '\0') {
|
||||
switch (ch) {
|
||||
case 'c':
|
||||
opt_c = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nextchain:
|
||||
(*pr)("MBUF %p\n", m);
|
||||
bitmask_snprintf(m->m_flags, M_FLAGS_BITS, buf, sizeof(buf));
|
||||
(*pr)(" data=%p, len=%d, type=%d, flags=0x%s\n",
|
||||
m->m_data, m->m_len, m->m_type, buf);
|
||||
(*pr)(" owner=%p, next=%p, nextpkt=%p\n", m->m_owner, m->m_next,
|
||||
m->m_nextpkt);
|
||||
(*pr)(" leadingspace=%u, trailingspace=%u, readonly=%u\n",
|
||||
(int)M_LEADINGSPACE(m), (int)M_TRAILINGSPACE(m),
|
||||
(int)M_READONLY(m));
|
||||
if ((m->m_flags & M_PKTHDR) != 0) {
|
||||
bitmask_snprintf(m->m_pkthdr.csum_flags, M_CSUM_BITS, buf,
|
||||
sizeof(buf));
|
||||
(*pr)(" pktlen=%d, rcvif=%p, csum_flags=0x%s, csum_data=0x%"
|
||||
PRIx32 ", segsz=%u\n",
|
||||
m->m_pkthdr.len, m->m_pkthdr.rcvif,
|
||||
buf, m->m_pkthdr.csum_data, m->m_pkthdr.segsz);
|
||||
}
|
||||
if ((m->m_flags & M_EXT)) {
|
||||
(*pr)(" shared=%u, ext_buf=%p, ext_size=%zd, "
|
||||
"ext_free=%p, ext_arg=%p\n",
|
||||
(int)MCLISREFERENCED(m),
|
||||
m->m_ext.ext_buf, m->m_ext.ext_size,
|
||||
m->m_ext.ext_free, m->m_ext.ext_arg);
|
||||
}
|
||||
if ((~m->m_flags & (M_EXT|M_EXT_PAGES)) == 0) {
|
||||
int i;
|
||||
|
||||
(*pr)(" pages:");
|
||||
for (i = 0; i < m->m_ext.ext_size; i += PAGE_SIZE) {
|
||||
(*pr)(" %p", m->m_ext.ext_pgs[i]);
|
||||
}
|
||||
(*pr)("\n");
|
||||
}
|
||||
|
||||
if (opt_c) {
|
||||
m = m->m_next;
|
||||
if (m != NULL) {
|
||||
goto nextchain;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* defined(DDB) */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbuf.h,v 1.119 2006/01/21 00:15:35 rpaulo Exp $ */
|
||||
/* $NetBSD: mbuf.h,v 1.120 2006/01/24 13:02:57 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996, 1997, 1999, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -181,6 +181,10 @@ struct pkthdr {
|
|||
* is not yet 1s-complemented.
|
||||
*/
|
||||
|
||||
#define M_CSUM_BITS \
|
||||
"\20\1TCPv4\2UDPv4\3TCP_UDP_BAD\4DATA\5TCPv6\6UDPv6\7IPv4\10IPv4_BAD" \
|
||||
"\11TSOv4\38NO_PSEUDOHDR"
|
||||
|
||||
/*
|
||||
* Macros for manipulating csum_data on outgoing packets. These are
|
||||
* used to pass information down from the L4/L3 to the L2.
|
||||
|
@ -323,6 +327,11 @@ MBUF_DEFINE(mbuf, MHLEN, MLEN);
|
|||
/* for source-level compatibility */
|
||||
#define M_CLUSTER M_EXT_CLUSTER
|
||||
|
||||
#define M_FLAGS_BITS \
|
||||
"\20\1EXT\2PKTHDR\3EOR\4PROTO1\5AUTHIPHDR\6DECRYPTED\7LOOP\10AUTHIPDGM" \
|
||||
"\11BCAST\12MCASE\13CANFASTFWD\14ANYCAST6\15LINK0\16LINK1\17LINK2\20LINK3" \
|
||||
"\30EXT_CLUSTER\31EXT_PAGES\32EXT_ROMAP\33EXT_RW"
|
||||
|
||||
/* flags copied when copying m_pkthdr */
|
||||
#define M_COPYFLAGS (M_PKTHDR|M_EOR|M_BCAST|M_MCAST|M_CANFASTFWD|M_ANYCAST6|M_LINK0|M_LINK1|M_LINK2|M_AUTHIPHDR|M_DECRYPTED|M_LOOP|M_AUTHIPDGM)
|
||||
|
||||
|
@ -949,6 +958,7 @@ m_ext_free(struct mbuf *m, boolean_t dofree)
|
|||
pool_cache_put(&mbpool_cache, m);
|
||||
}
|
||||
|
||||
void m_print(const struct mbuf *, const char *, void (*)(const char *, ...));
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* !_SYS_MBUF_H_ */
|
||||
|
|
Loading…
Reference in New Issue