diff options
author | Robert Mustacchi <rm@fingolfin.org> | 2020-02-19 00:00:27 +0000 |
---|---|---|
committer | Robert Mustacchi <rm@fingolfin.org> | 2020-03-06 22:41:05 +0000 |
commit | c71ad1764a07b4be9b04c56fd0d199c0f547404a (patch) | |
tree | 3dad2743b54073cb2714037cc04f7ccd95306cca | |
parent | 4e4d1bad19e83eed004cbbbec13ba7d42ae7d17a (diff) | |
download | illumos-joyent-c71ad1764a07b4be9b04c56fd0d199c0f547404a.tar.gz |
12366 Want mdb typelist command
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Reviewed by: Mike Zeller <mike.zeller@joyent.com>
Approved by: Joshua M. Clulow <josh@sysmgr.org>
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_cmds.c | 1 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_ctf.c | 32 | ||||
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_ctf.h | 3 |
3 files changed, 36 insertions, 0 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c index fff03274d5..aa706c690d 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c @@ -3163,6 +3163,7 @@ const mdb_dcmd_t mdb_dcmd_builtins[] = { { "typeset", "[+/-t] var ...", "set variable attributes", cmd_typeset }, { "typedef", "[-c model | -d | -l | -r file | -w file ] [type] [name]", "create synthetic types", cmd_typedef, cmd_typedef_help }, + { "typelist", NULL, "list known types", cmd_typelist }, { "unset", "[name ...]", "unset variables", cmd_unset }, { "vars", "[-npt]", "print listing of variables", cmd_vars }, { "version", NULL, "print debugger version string", cmd_version }, diff --git a/usr/src/cmd/mdb/common/mdb/mdb_ctf.c b/usr/src/cmd/mdb/common/mdb/mdb_ctf.c index 1be7357f05..90cedaea4e 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_ctf.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_ctf.c @@ -2218,3 +2218,35 @@ mdb_ctf_synthetics_to_file(const char *file) return (err); } + +static int +cmd_typelist_type(mdb_ctf_id_t id, void *arg) +{ + char buf[1024]; + + if (mdb_ctf_type_name(id, buf, sizeof (buf)) != NULL) { + mdb_printf("%s\n", buf); + } + return (0); +} + +static int +cmd_typelist_module(void *data, const mdb_map_t *mp, const char *name) +{ + (void) mdb_ctf_type_iter(name, cmd_typelist_type, data); + return (0); +} + +int +cmd_typelist(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) +{ + if ((flags & DCMD_ADDRSPEC) != 0) { + return (DCMD_USAGE); + } + + (void) mdb_tgt_object_iter(mdb.m_target, cmd_typelist_module, NULL); + (void) mdb_ctf_type_iter(MDB_CTF_SYNTHETIC_ITER, cmd_typelist_type, + NULL); + + return (DCMD_OK); +} diff --git a/usr/src/cmd/mdb/common/mdb/mdb_ctf.h b/usr/src/cmd/mdb/common/mdb/mdb_ctf.h index 74bc8e95da..639e7b2bdc 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_ctf.h +++ b/usr/src/cmd/mdb/common/mdb/mdb_ctf.h @@ -35,6 +35,7 @@ #ifdef _MDB #include <sys/machelf.h> +#include <mdb/mdb_modapi.h> #endif /* @@ -159,6 +160,8 @@ extern int mdb_ctf_synthetics_init(void); /* Internal */ extern void mdb_ctf_synthetics_fini(void); /* Internal */ extern int mdb_ctf_synthetics_from_file(const char *); /* Internal */ extern int mdb_ctf_synthetics_to_file(const char *); /* Internal */ +extern int cmd_typelist(uintptr_t, uint_t, int, /* Internal */ + const mdb_arg_t *); #endif |