summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Ahrens <mahrens@delphix.com>2013-04-08 13:11:12 -0800
committerChristopher Siden <chris.siden@delphix.com>2013-04-08 14:11:12 -0700
commit22ce014825a14b6ce90123db2834a13e343d6caf (patch)
tree6d2735e31262dd86026216b68f0c821cf76ffea5
parentd5ee8a1311accef11ec2057f70da38d1dd687088 (diff)
downloadillumos-joyent-22ce014825a14b6ce90123db2834a13e343d6caf.tar.gz
3650 mdb global symbol tab completion should find all symbols
3651 mdb_readsym() and friends should find all symbols 3652 convert ::spa and ::spa_vdevs to use mdb_ctf_vread() 3653 userland ::whatis always complains about "umem_internal_arena" symbol Reviewed by: Henrik Mattson <henrik.mattson@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Christopher Siden <christopher.siden@delphix.com> Approved by: Dan McDonald <danmcd@nexenta.com>
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_ctf.c2
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_modapi.c11
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_tab.c2
-rw-r--r--usr/src/cmd/mdb/common/modules/libumem/umem.c3
-rw-r--r--usr/src/cmd/mdb/common/modules/zfs/zfs.c80
5 files changed, 37 insertions, 61 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_ctf.c b/usr/src/cmd/mdb/common/mdb/mdb_ctf.c
index 8f43c8cb0f..3181f8290c 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_ctf.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_ctf.c
@@ -1513,7 +1513,7 @@ mdb_ctf_readsym(void *buf, const char *typename, const char *name, uint_t flags)
{
GElf_Sym sym;
- if (mdb_lookup_by_name(name, &sym) != 0) {
+ if (mdb_lookup_by_obj(MDB_TGT_OBJ_EVERY, name, &sym) != 0) {
mdb_ctf_warn(flags, "couldn't find symbol %s\n", name);
return (-1); /* errno is set for us */
}
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_modapi.c b/usr/src/cmd/mdb/common/mdb/mdb_modapi.c
index ef2c4da93f..df954e2a6d 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_modapi.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_modapi.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <mdb/mdb_modapi.h>
@@ -120,7 +121,7 @@ ssize_t
mdb_readsym(void *buf, size_t nbytes, const char *name)
{
ssize_t rbytes = mdb_tgt_readsym(mdb.m_target, MDB_TGT_AS_VIRT,
- buf, nbytes, MDB_TGT_OBJ_EXEC, name);
+ buf, nbytes, MDB_TGT_OBJ_EVERY, name);
if (rbytes > 0 && rbytes < nbytes)
return (set_errbytes(rbytes, nbytes));
@@ -132,7 +133,7 @@ ssize_t
mdb_writesym(const void *buf, size_t nbytes, const char *name)
{
return (mdb_tgt_writesym(mdb.m_target, MDB_TGT_AS_VIRT,
- buf, nbytes, MDB_TGT_OBJ_EXEC, name));
+ buf, nbytes, MDB_TGT_OBJ_EVERY, name));
}
ssize_t
@@ -140,7 +141,7 @@ mdb_readvar(void *buf, const char *name)
{
GElf_Sym sym;
- if (mdb_tgt_lookup_by_name(mdb.m_target, MDB_TGT_OBJ_EXEC,
+ if (mdb_tgt_lookup_by_name(mdb.m_target, MDB_TGT_OBJ_EVERY,
name, &sym, NULL))
return (-1);
@@ -156,7 +157,7 @@ mdb_writevar(const void *buf, const char *name)
{
GElf_Sym sym;
- if (mdb_tgt_lookup_by_name(mdb.m_target, MDB_TGT_OBJ_EXEC,
+ if (mdb_tgt_lookup_by_name(mdb.m_target, MDB_TGT_OBJ_EVERY,
name, &sym, NULL))
return (-1);
@@ -170,7 +171,7 @@ mdb_writevar(const void *buf, const char *name)
int
mdb_lookup_by_name(const char *name, GElf_Sym *sym)
{
- return (mdb_lookup_by_obj(MDB_TGT_OBJ_EXEC, name, sym));
+ return (mdb_lookup_by_obj(MDB_TGT_OBJ_EVERY, name, sym));
}
int
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_tab.c b/usr/src/cmd/mdb/common/mdb/mdb_tab.c
index 0fc5b3644e..b06b5db680 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_tab.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_tab.c
@@ -506,7 +506,7 @@ mdb_tab_complete_global(mdb_tab_cookie_t *mcp, const char *name)
{
mdb_tab_setmbase(mcp, name);
(void) mdb_tgt_symbol_iter(mdb.m_target, MDB_TGT_OBJ_EVERY,
- MDB_TGT_SYMTAB, MDB_TGT_BIND_GLOBAL | MDB_TGT_TYPE_OBJECT |
+ MDB_TGT_SYMTAB, MDB_TGT_BIND_ANY | MDB_TGT_TYPE_OBJECT |
MDB_TGT_TYPE_FUNC, tab_complete_global, mcp);
return (0);
}
diff --git a/usr/src/cmd/mdb/common/modules/libumem/umem.c b/usr/src/cmd/mdb/common/modules/libumem/umem.c
index 0bd52baf1e..26a62c7b52 100644
--- a/usr/src/cmd/mdb/common/modules/libumem/umem.c
+++ b/usr/src/cmd/mdb/common/modules/libumem/umem.c
@@ -25,6 +25,7 @@
/*
* Copyright 2011 Joyent, Inc. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include "umem.h"
@@ -2102,7 +2103,7 @@ whatis_run_umem(mdb_whatis_t *w, void *ignored)
wi.wi_w = w;
/* umem's metadata is allocated from the umem_internal_arena */
- if (mdb_readvar(&wi.wi_msb_arena, "umem_internal_arena") == -1)
+ if (umem_readvar(&wi.wi_msb_arena, "umem_internal_arena") == -1)
mdb_warn("unable to readvar \"umem_internal_arena\"");
/*
diff --git a/usr/src/cmd/mdb/common/modules/zfs/zfs.c b/usr/src/cmd/mdb/common/modules/zfs/zfs.c
index e2a05550c2..b04b05d75a 100644
--- a/usr/src/cmd/mdb/common/modules/zfs/zfs.c
+++ b/usr/src/cmd/mdb/common/modules/zfs/zfs.c
@@ -36,7 +36,6 @@
#include <sys/metaslab_impl.h>
#include <sys/space_map.h>
#include <sys/list.h>
-#include <sys/spa_impl.h>
#include <sys/vdev_impl.h>
#include <sys/zap_leaf.h>
#include <sys/zap_impl.h>
@@ -778,7 +777,7 @@ abuf_find(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
}
for (i = 0; i < sizeof (syms) / sizeof (syms[0]); i++) {
- if (mdb_lookup_by_name(syms[i], &sym)) {
+ if (mdb_lookup_by_obj(ZFS_OBJ_NAME, syms[i], &sym)) {
mdb_warn("can't find symbol %s", syms[i]);
return (DCMD_ERR);
}
@@ -896,7 +895,7 @@ arc_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
NULL
};
- if (mdb_lookup_by_name("arc_stats", &sym) == -1) {
+ if (mdb_lookup_by_obj(ZFS_OBJ_NAME, "arc_stats", &sym) == -1) {
mdb_warn("failed to find 'arc_stats'");
return (DCMD_ERR);
}
@@ -963,7 +962,7 @@ arc_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
for (i = 0; extras[i]; i++) {
uint64_t buf;
- if (mdb_lookup_by_name(extras[i], &sym) == -1) {
+ if (mdb_lookup_by_obj(ZFS_OBJ_NAME, extras[i], &sym) == -1) {
mdb_warn("failed to find '%s'", extras[i]);
return (DCMD_ERR);
}
@@ -992,12 +991,17 @@ arc_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_OK);
}
+typedef struct mdb_spa_print {
+ pool_state_t spa_state;
+ char spa_name[MAXNAMELEN];
+} mdb_spa_print_t;
+
/*
* ::spa
*
- * -c Print configuration information as well
- * -v Print vdev state
- * -e Print vdev error stats
+ * -c Print configuration information as well
+ * -v Print vdev state
+ * -e Print vdev error stats
*
* Print a summarized spa_t. When given no arguments, prints out a table of all
* active pools on the system.
@@ -1006,7 +1010,6 @@ arc_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
static int
spa_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
- spa_t spa;
const char *statetab[] = { "ACTIVE", "EXPORTED", "DESTROYED",
"SPARE", "L2CACHE", "UNINIT", "UNAVAIL", "POTENTIAL" };
const char *state;
@@ -1039,10 +1042,9 @@ spa_print(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_printf("%<u>%-?s %9s %-*s%</u>\n", "ADDR", "STATE",
sizeof (uintptr_t) == 4 ? 60 : 52, "NAME");
- if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
- mdb_warn("failed to read spa_t at %p", addr);
+ mdb_spa_print_t spa;
+ if (mdb_ctf_vread(&spa, "spa_t", "mdb_spa_print_t", addr, 0) == -1)
return (DCMD_ERR);
- }
if (spa.spa_state < 0 || spa.spa_state > POOL_STATE_UNAVAIL)
state = "UNKNOWN";
@@ -1577,36 +1579,19 @@ spa_space(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_OK);
}
-/*
- * ::spa_verify
- *
- * Given a spa_t, verify that that the pool is self-consistent.
- * Currently, it only checks to make sure that the vdev tree exists.
- */
-/* ARGSUSED */
-static int
-spa_verify(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
- spa_t spa;
-
- if (argc != 0 || !(flags & DCMD_ADDRSPEC))
- return (DCMD_USAGE);
-
- if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
- mdb_warn("failed to read spa_t at %p", addr);
- return (DCMD_ERR);
- }
-
- if (spa.spa_root_vdev == NULL) {
- mdb_printf("no vdev tree present\n");
- return (DCMD_OK);
- }
+typedef struct mdb_spa_aux_vdev {
+ int sav_count;
+ uintptr_t sav_vdevs;
+} mdb_spa_aux_vdev_t;
- return (DCMD_OK);
-}
+typedef struct mdb_spa_vdevs {
+ uintptr_t spa_root_vdev;
+ mdb_spa_aux_vdev_t spa_l2cache;
+ mdb_spa_aux_vdev_t spa_spares;
+} mdb_spa_vdevs_t;
static int
-spa_print_aux(spa_aux_vdev_t *sav, uint_t flags, mdb_arg_t *v,
+spa_print_aux(mdb_spa_aux_vdev_t *sav, uint_t flags, mdb_arg_t *v,
const char *name)
{
uintptr_t *aux;
@@ -1627,8 +1612,7 @@ spa_print_aux(spa_aux_vdev_t *sav, uint_t flags, mdb_arg_t *v,
len = sav->sav_count * sizeof (uintptr_t);
aux = mdb_alloc(len, UM_SLEEP);
- if (mdb_vread(aux, len,
- (uintptr_t)sav->sav_vdevs) == -1) {
+ if (mdb_vread(aux, len, sav->sav_vdevs) == -1) {
mdb_free(aux, len);
mdb_warn("failed to read l2cache vdevs at %p",
sav->sav_vdevs);
@@ -1664,7 +1648,6 @@ spa_print_aux(spa_aux_vdev_t *sav, uint_t flags, mdb_arg_t *v,
static int
spa_vdevs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
- spa_t spa;
mdb_arg_t v[3];
int errors = FALSE;
int ret;
@@ -1677,10 +1660,9 @@ spa_vdevs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
if (!(flags & DCMD_ADDRSPEC))
return (DCMD_USAGE);
- if (mdb_vread(&spa, sizeof (spa), addr) == -1) {
- mdb_warn("failed to read spa_t at %p", addr);
+ mdb_spa_vdevs_t spa;
+ if (mdb_ctf_vread(&spa, "spa_t", "mdb_spa_vdevs_t", addr, 0) == -1)
return (DCMD_ERR);
- }
/*
* Unitialized spa_t structures can have a NULL root vdev.
@@ -2045,14 +2027,7 @@ spa_walk_init(mdb_walk_state_t *wsp)
static int
spa_walk_step(mdb_walk_state_t *wsp)
{
- spa_t spa;
-
- if (mdb_vread(&spa, sizeof (spa), wsp->walk_addr) == -1) {
- mdb_warn("failed to read spa_t at %p", wsp->walk_addr);
- return (WALK_ERR);
- }
-
- return (wsp->walk_callback(wsp->walk_addr, &spa, wsp->walk_cbdata));
+ return (wsp->walk_callback(wsp->walk_addr, NULL, wsp->walk_cbdata));
}
/*
@@ -3077,7 +3052,6 @@ static const mdb_dcmd_t dcmds[] = {
abuf_find },
{ "spa", "?[-cv]", "spa_t summary", spa_print },
{ "spa_config", ":", "print spa_t configuration", spa_print_config },
- { "spa_verify", ":", "verify spa_t consistency", spa_verify },
{ "spa_space", ":[-b]", "print spa_t on-disk space usage", spa_space },
{ "spa_vdevs", ":", "given a spa_t, print vdev summary", spa_vdevs },
{ "vdev", ":[-re]\n"