summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJoshua M. Clulow <jmc@joyent.com>2015-01-24 16:32:07 -0800
committerRobert Mustacchi <rm@joyent.com>2015-02-19 07:29:01 -0800
commit8f88a51fa5d22e056a70484fd9496b2dee9876b0 (patch)
treeecdb5dbf580cf0d62e4379cd3b1b7be7ca0098eb /usr/src
parent6b35cb3cf158584a9408d44b9b6796564e8e1882 (diff)
downloadillumos-gate-8f88a51fa5d22e056a70484fd9496b2dee9876b0.tar.gz
5628 mdb ::regs could print registers from a ucontext
5629 mdb ::ucontext should print uc_flags symbols Reviewed by: Timothy J Fontaine <tj.fontaine@joyent.com> Reviewed by: Gordon Ross <gwr@nexenta.com> Reviewed by: Dan McDonald <danmcd@omniti.com> Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_proc.c6
-rw-r--r--usr/src/cmd/mdb/common/modules/libc/libc.c19
-rw-r--r--usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c36
-rw-r--r--usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c36
4 files changed, 88 insertions, 9 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_proc.c b/usr/src/cmd/mdb/common/mdb/mdb_proc.c
index 4cd0e1efbe..2a3e491313 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_proc.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_proc.c
@@ -24,7 +24,7 @@
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ * Copyright 2015 Joyent, Inc.
*/
/*
@@ -2109,7 +2109,7 @@ static const mdb_dcmd_t pt_dcmds[] = {
{ "$i", NULL, "print signals that are ignored", pt_ignored },
{ "$l", NULL, "print the representative thread's lwp id", pt_lwpid },
{ "$L", NULL, "print list of the active lwp ids", pt_lwpids },
- { "$r", "?", "print general-purpose registers", pt_regs },
+ { "$r", "?[-u]", "print general-purpose registers", pt_regs },
{ "$x", "?", "print floating point registers", pt_fpregs },
{ "$X", "?", "print floating point registers", pt_fpregs },
{ "$y", "?", "print floating point registers", pt_fpregs },
@@ -2129,7 +2129,7 @@ static const mdb_dcmd_t pt_dcmds[] = {
{ "kill", NULL, "forcibly kill and release target", pt_kill },
{ "release", "[-a]",
"release the previously attached process", pt_detach },
- { "regs", "?", "print general-purpose registers", pt_regs },
+ { "regs", "?[-u]", "print general-purpose registers", pt_regs },
{ "fpregs", "?[-dqs]", "print floating point registers", pt_fpregs },
{ "setenv", "name=value", "set an environment variable", pt_setenv },
{ "stack", "?[cnt]", "print stack backtrace", pt_stack },
diff --git a/usr/src/cmd/mdb/common/modules/libc/libc.c b/usr/src/cmd/mdb/common/modules/libc/libc.c
index 44e4f49b87..967198e40b 100644
--- a/usr/src/cmd/mdb/common/modules/libc/libc.c
+++ b/usr/src/cmd/mdb/common/modules/libc/libc.c
@@ -24,7 +24,7 @@
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2015, Joyent, Inc.
*/
#include <sys/mdb_modapi.h>
@@ -99,6 +99,20 @@ d_jmp_buf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_OK);
}
+const mdb_bitmask_t uc_flags_bits[] = {
+ { "UC_SIGMASK", UC_SIGMASK, UC_SIGMASK },
+ { "UC_STACK", UC_STACK, UC_STACK },
+ { "UC_CPU", UC_CPU, UC_CPU },
+ { "UC_FPU", UC_FPU, UC_FPU },
+#if defined(UC_INTR)
+ { "UC_INTR", UC_INTR, UC_INTR },
+#endif
+#if defined(UC_ASR)
+ { "UC_ASR", UC_ASR, UC_ASR },
+#endif
+ { NULL, 0, 0 }
+};
+
/*ARGSUSED*/
static int
d_ucontext(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
@@ -113,7 +127,8 @@ d_ucontext(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_ERR);
}
- mdb_printf(" flags = 0x%lx\n", uc.uc_flags);
+ mdb_printf(" flags = 0x%lx <%b>\n", uc.uc_flags,
+ (uint_t)uc.uc_flags, uc_flags_bits);
mdb_printf(" link = 0x%p\n", uc.uc_link);
mdb_printf(" sigmask = 0x%08x 0x%08x 0x%08x 0x%08x\n",
uc.uc_sigmask.__sigbits[0], uc.uc_sigmask.__sigbits[1],
diff --git a/usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c b/usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c
index 75dd430c7d..ed61bade77 100644
--- a/usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c
+++ b/usr/src/cmd/mdb/intel/mdb/proc_amd64dep.c
@@ -24,7 +24,7 @@
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2015 Joyent, Inc.
*/
/*
@@ -40,11 +40,14 @@
#include <mdb/mdb_amd64util.h>
#include <mdb/mdb.h>
+#include <sys/ucontext.h>
#include <sys/frame.h>
#include <libproc.h>
#include <sys/fp.h>
#include <ieeefp.h>
+#include <stddef.h>
+
const mdb_tgt_regdesc_t pt_regdesc[] = {
{ "r15", REG_R15, MDB_TGT_R_EXPORT },
{ "r15d", REG_R15, MDB_TGT_R_EXPORT | MDB_TGT_R_32 },
@@ -153,9 +156,37 @@ pt_regs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_tgt_tid_t tid;
prgregset_t grs;
prgreg_t rflags;
+ boolean_t from_ucontext = B_FALSE;
- if (argc != 0)
+ if (mdb_getopts(argc, argv,
+ 'u', MDB_OPT_SETBITS, B_TRUE, &from_ucontext, NULL) != argc) {
return (DCMD_USAGE);
+ }
+
+ if (from_ucontext) {
+ int off;
+ int o0, o1;
+
+ if (!(flags & DCMD_ADDRSPEC)) {
+ mdb_warn("-u requires a ucontext_t address\n");
+ return (DCMD_ERR);
+ }
+
+ o0 = mdb_ctf_offsetof_by_name("ucontext_t", "uc_mcontext");
+ o1 = mdb_ctf_offsetof_by_name("mcontext_t", "gregs");
+ if (o0 == -1 || o1 == -1) {
+ off = offsetof(ucontext_t, uc_mcontext) +
+ offsetof(mcontext_t, gregs);
+ } else {
+ off = o0 + o1;
+ }
+
+ if (mdb_vread(&grs, sizeof (grs), addr + off) != sizeof (grs)) {
+ mdb_warn("failed to read from ucontext_t %p", addr);
+ return (DCMD_ERR);
+ }
+ goto print_regs;
+ }
if (t->t_pshandle == NULL || Pstate(t->t_pshandle) == PS_UNDEAD) {
mdb_warn("no process active\n");
@@ -177,6 +208,7 @@ pt_regs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_ERR);
}
+print_regs:
rflags = grs[REG_RFL];
mdb_printf("%%rax = 0x%0?p\t%%r8 = 0x%0?p\n",
diff --git a/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c b/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c
index b532dc9149..5ebe2df9f4 100644
--- a/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c
+++ b/usr/src/cmd/mdb/intel/mdb/proc_ia32dep.c
@@ -24,7 +24,7 @@
* Use is subject to license terms.
*/
/*
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright 2015 Joyent, Inc.
*/
/*
@@ -40,11 +40,14 @@
#include <mdb/mdb_ia32util.h>
#include <mdb/mdb.h>
+#include <sys/ucontext.h>
#include <sys/frame.h>
#include <libproc.h>
#include <sys/fp.h>
#include <ieeefp.h>
+#include <stddef.h>
+
const mdb_tgt_regdesc_t pt_regdesc[] = {
{ "gs", GS, MDB_TGT_R_EXPORT },
{ "fs", FS, MDB_TGT_R_EXPORT },
@@ -108,9 +111,37 @@ pt_regs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_tgt_tid_t tid;
prgregset_t grs;
prgreg_t eflags;
+ boolean_t from_ucontext = B_FALSE;
- if (argc != 0)
+ if (mdb_getopts(argc, argv,
+ 'u', MDB_OPT_SETBITS, B_TRUE, &from_ucontext, NULL) != argc) {
return (DCMD_USAGE);
+ }
+
+ if (from_ucontext) {
+ int off;
+ int o0, o1;
+
+ if (!(flags & DCMD_ADDRSPEC)) {
+ mdb_warn("-u requires a ucontext_t address\n");
+ return (DCMD_ERR);
+ }
+
+ o0 = mdb_ctf_offsetof_by_name("ucontext_t", "uc_mcontext");
+ o1 = mdb_ctf_offsetof_by_name("mcontext_t", "gregs");
+ if (o0 == -1 || o1 == -1) {
+ off = offsetof(ucontext_t, uc_mcontext) +
+ offsetof(mcontext_t, gregs);
+ } else {
+ off = o0 + o1;
+ }
+
+ if (mdb_vread(&grs, sizeof (grs), addr + off) != sizeof (grs)) {
+ mdb_warn("failed to read from ucontext_t %p", addr);
+ return (DCMD_ERR);
+ }
+ goto print_regs;
+ }
if (t->t_pshandle == NULL || Pstate(t->t_pshandle) == PS_UNDEAD) {
mdb_warn("no process active\n");
@@ -132,6 +163,7 @@ pt_regs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_ERR);
}
+print_regs:
eflags = grs[EFL];
mdb_printf("%%cs = 0x%04x\t\t%%eax = 0x%0?p %A\n",