preload: add "show preload" DDB command
This is the DDB equivalent of the debug.dump_modinfo sysctl which outputs pretty-printed bootloader metadata. Move sbuf_db_printf_drain to subr_prf.c and expose it for general use. Reviewed By: jmg Differential Revision: https://reviews.freebsd.org/D53763
This commit is contained in:
@@ -28,6 +28,9 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include "opt_ddb.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/linker.h>
|
||||
@@ -39,6 +42,10 @@
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Preloaded module support
|
||||
*/
|
||||
@@ -607,3 +614,16 @@ SYSCTL_PROC(_debug, OID_AUTO, dump_modinfo,
|
||||
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
|
||||
NULL, 0, sysctl_preload_dump, "A",
|
||||
"pretty-print the bootloader metadata");
|
||||
|
||||
#ifdef DDB
|
||||
DB_SHOW_COMMAND_FLAGS(preload, db_show_preload, DB_CMD_MEMSAFE)
|
||||
{
|
||||
struct sbuf sb;
|
||||
char buffer[128];
|
||||
|
||||
sbuf_new(&sb, buffer, sizeof(buffer), SBUF_FIXEDLEN);
|
||||
sbuf_set_drain(&sb, sbuf_db_printf_drain, NULL);
|
||||
preload_dump_internal(&sb);
|
||||
sbuf_finish(&sb);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1358,3 +1358,12 @@ sbuf_printf_drain(void *arg, const char *data, int len)
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#if defined(_KERNEL) && defined(DDB)
|
||||
int
|
||||
sbuf_db_printf_drain(void *arg __unused, const char *data, int len)
|
||||
{
|
||||
|
||||
return (db_printf("%.*s", len, data));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3121,12 +3121,6 @@ sysctl_debug_witness_badstacks(SYSCTL_HANDLER_ARGS)
|
||||
}
|
||||
|
||||
#ifdef DDB
|
||||
static int
|
||||
sbuf_db_printf_drain(void *arg __unused, const char *data, int len)
|
||||
{
|
||||
return (db_printf("%.*s", len, data));
|
||||
}
|
||||
|
||||
DB_SHOW_COMMAND_FLAGS(badstacks, db_witness_badstacks, DB_CMD_MEMSAFE)
|
||||
{
|
||||
struct sbuf sb;
|
||||
|
||||
@@ -114,6 +114,9 @@ struct uio;
|
||||
struct sbuf *sbuf_uionew(struct sbuf *, struct uio *, int *);
|
||||
int sbuf_bcopyin(struct sbuf *, const void *, size_t);
|
||||
int sbuf_copyin(struct sbuf *, const void *, size_t);
|
||||
#ifdef DDB
|
||||
int sbuf_db_printf_drain(void *arg, const char *data, int len);
|
||||
#endif
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user