summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosef 'Jeff' Sipek <josef.sipek@nexenta.com>2014-10-16 18:34:56 -0400
committerRobert Mustacchi <rm@joyent.com>2014-10-24 16:16:43 -0700
commit38ce19d2fe6359bf2fe9536f075f30cc972d2b50 (patch)
tree5ea5ea2ac91d85c0959d48aedcb10541c66d5b3a
parent8f23e9fa8abcb5857661066b954e63400d589b65 (diff)
downloadillumos-joyent-38ce19d2fe6359bf2fe9536f075f30cc972d2b50.tar.gz
5231 ::printf doesn't handle enums
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Reviewed by: Alex Reece <alex@delphix.com> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_print.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_print.c b/usr/src/cmd/mdb/common/mdb/mdb_print.c
index 02ee13abd9..56275fdded 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_print.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_print.c
@@ -26,6 +26,7 @@
/*
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <mdb/mdb_modapi.h>
@@ -2560,14 +2561,21 @@ printf_signed(mdb_ctf_id_t id, uintptr_t addr, ulong_t off, char *fmt,
return (DCMD_ABORT);
}
- if (mdb_ctf_type_kind(base) != CTF_K_INTEGER) {
- mdb_warn("expected integer type\n");
- return (DCMD_ABORT);
- }
-
- if (mdb_ctf_type_encoding(base, &e) != 0) {
- mdb_warn("could not get type encoding");
- return (DCMD_ABORT);
+ switch (mdb_ctf_type_kind(base)) {
+ case CTF_K_ENUM:
+ e.cte_format = CTF_INT_SIGNED;
+ e.cte_offset = 0;
+ e.cte_bits = mdb_ctf_type_size(id) * NBBY;
+ break;
+ case CTF_K_INTEGER:
+ if (mdb_ctf_type_encoding(base, &e) != 0) {
+ mdb_warn("could not get type encoding");
+ return (DCMD_ABORT);
+ }
+ break;
+ default:
+ mdb_warn("expected integer type\n");
+ return (DCMD_ABORT);
}
if (sign)
@@ -2753,6 +2761,25 @@ printf_string(mdb_ctf_id_t id, uintptr_t addr, ulong_t off, char *fmt)
return (0);
}
+ if (mdb_ctf_type_kind(base) == CTF_K_ENUM) {
+ const char *strval;
+ int value;
+
+ if (mdb_vread(&value, sizeof (value), addr) == -1) {
+ mdb_warn("failed to read pointer at %llx", addr);
+ return (DCMD_ERR);
+ }
+
+ if ((strval = mdb_ctf_enum_name(id, value))) {
+ mdb_printf(fmt, strval);
+ } else {
+ (void) mdb_snprintf(buf, sizeof (buf), "<%d>", value);
+ mdb_printf(fmt, buf);
+ }
+
+ return (0);
+ }
+
if (mdb_ctf_type_kind(base) != CTF_K_ARRAY) {
mdb_warn("exepected pointer or array type\n");
return (DCMD_ABORT);