summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2017-04-28 00:12:28 +0000
committerBryan Cantrill <bryan@joyent.com>2017-05-04 00:48:04 +0000
commitfdfe9d092a94f3271359e9c6b68846276c58d119 (patch)
treedac20ede3fc2bb545655ddbcb85fd179fa684fea
parente14f48674b1d80f3f8d374fdd837d53e312aa7d7 (diff)
downloadillumos-joyent-fdfe9d092a94f3271359e9c6b68846276c58d119.tar.gz
OS-6083 mdb's output autowrapping should be optional -- and disabled
Reviewed by: Dave Pacheco <dap@joyent.com> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb.h43
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_io.c24
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_set.c16
-rw-r--r--usr/src/cmd/mdb/test/options/tst.autowrap.mdb8
-rw-r--r--usr/src/cmd/mdb/test/typedef/tst.cleanupstruct.ksh2
-rw-r--r--usr/src/man/man1/mdb.115
6 files changed, 75 insertions, 33 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb.h b/usr/src/cmd/mdb/common/mdb/mdb.h
index 7f712ad340..cb43f4828d 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb.h
+++ b/usr/src/cmd/mdb/common/mdb/mdb.h
@@ -25,7 +25,7 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
- * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ * Copyright (c) 2017 Joyent, Inc. All rights reserved.
*/
#ifndef _MDB_H
@@ -76,28 +76,29 @@ extern "C" {
#define MDB_ARR_NOLIMIT -1UL /* No limit on number of array elements */
-#define MDB_FL_PSYM 0x00001 /* Print dot as symbol + offset when possible */
-#define MDB_FL_LOG 0x00002 /* Logging is enabled */
-#define MDB_FL_NOMODS 0x00004 /* Skip automatic mdb module loading */
-#define MDB_FL_USECUP 0x00008 /* Use terminal cup initialization sequences */
-#define MDB_FL_ADB 0x00010 /* Enable stricter adb(1) compatibility */
-#define MDB_FL_SHOWLMID 0x00020 /* Always show link map id with symbol names */
-#define MDB_FL_IGNEOF 0x00040 /* Ignore EOF as a synonym for ::quit */
-#define MDB_FL_REPLAST 0x00080 /* Naked newline repeats previous command */
-#define MDB_FL_PAGER 0x00100 /* Enable pager by default */
-#define MDB_FL_LATEST 0x00200 /* Replace version string with "latest" */
-#define MDB_FL_VCREATE 0x00400 /* Victim process was created by debugger */
-#define MDB_FL_JOBCTL 0x00800 /* Victim process jobctl stopped on same tty */
-#define MDB_FL_DEMANGLE 0x01000 /* Demangle symbols as part of %a processing */
-#define MDB_FL_EXEC 0x02000 /* Debugger exec'd by a previous instance */
-#define MDB_FL_NOCTF 0x04000 /* Skip automatic CTF data loading */
-#define MDB_FL_BPTNOSYMSTOP 0x08000 /* Stop on deferred bkpts for unk symbols */
-#define MDB_FL_TERMGUESS 0x10000 /* m_termtype derived from userland */
-#define MDB_FL_READBACK 0x20000 /* Read value back after write */
+#define MDB_FL_PSYM 0x000001 /* Print dot as symbol + offset */
+#define MDB_FL_LOG 0x000002 /* Logging is enabled */
+#define MDB_FL_NOMODS 0x000004 /* Skip automatic mdb module loading */
+#define MDB_FL_USECUP 0x000008 /* Use term cup init sequences */
+#define MDB_FL_ADB 0x000010 /* Enable stricter adb(1) compat */
+#define MDB_FL_SHOWLMID 0x000020 /* Show link map id with symbol names */
+#define MDB_FL_IGNEOF 0x000040 /* Ignore EOF as a synonym for ::quit */
+#define MDB_FL_REPLAST 0x000080 /* Naked newline repeats prev command */
+#define MDB_FL_PAGER 0x000100 /* Enable pager by default */
+#define MDB_FL_LATEST 0x000200 /* Replace verstring with "latest" */
+#define MDB_FL_VCREATE 0x000400 /* Victim process created by debugger */
+#define MDB_FL_JOBCTL 0x000800 /* Victim process jobctl on same tty */
+#define MDB_FL_DEMANGLE 0x001000 /* Demangle symbols as part of %a */
+#define MDB_FL_EXEC 0x002000 /* Debugger exec'd by a prev instance */
+#define MDB_FL_NOCTF 0x004000 /* Skip automatic CTF data loading */
+#define MDB_FL_BPTNOSYMSTOP 0x008000 /* Stop on def bkpts for unk symbols */
+#define MDB_FL_TERMGUESS 0x010000 /* m_termtype derived from userland */
+#define MDB_FL_READBACK 0x020000 /* Read value back after write */
#ifdef _KMDB
-#define MDB_FL_NOUNLOAD 0x40000 /* Don't allow debugger unload */
+#define MDB_FL_NOUNLOAD 0x040000 /* Don't allow debugger unload */
#endif
-#define MDB_FL_LMRAW 0x80000 /* Show unresolved link map object names */
+#define MDB_FL_LMRAW 0x080000 /* Show unres link map object names */
+#define MDB_FL_AUTOWRAP 0x100000 /* Autowrap lines at term width */
#define MDB_FL_VOLATILE 0x0001 /* Mask of all volatile flags to save/restore */
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_io.c b/usr/src/cmd/mdb/common/mdb/mdb_io.c
index 84e7c92784..12608a89d3 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_io.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_io.c
@@ -24,7 +24,7 @@
*/
/*
- * Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2017, Joyent, Inc. All rights reserved.
* Copyright (c) 2016 by Delphix. All rights reserved.
*/
@@ -155,13 +155,17 @@ typedef struct {
#define CTRL(c) ((c) & 0x01f)
#endif
+#define IOB_AUTOWRAP(iob) \
+ ((mdb.m_flags & MDB_FL_AUTOWRAP) && \
+ ((iob)->iob_flags & MDB_IOB_AUTOWRAP))
+
/*
* Define macro for determining if we should automatically wrap to the next
* line of output, based on the amount of consumed buffer space and the
* specified size of the next thing to be inserted (n).
*/
#define IOB_WRAPNOW(iob, n) \
- (((iob)->iob_flags & MDB_IOB_AUTOWRAP) && ((iob)->iob_nbytes != 0) && \
+ (IOB_AUTOWRAP(iob) && (iob)->iob_nbytes != 0 && \
((n) + (iob)->iob_nbytes > (iob)->iob_cols))
/*
@@ -414,7 +418,7 @@ void
mdb_iob_destroy(mdb_iob_t *iob)
{
/*
- * Don't flush a pipe, since it may cause a context swith when the
+ * Don't flush a pipe, since it may cause a context switch when the
* other side has already been destroyed.
*/
if (!mdb_iob_isapipe(iob))
@@ -1808,7 +1812,7 @@ mdb_iob_nputs(mdb_iob_t *iob, const char *s, size_t nbytes)
* flush the buffer if we reach the end of a line.
*/
while (nleft != 0) {
- if (iob->iob_flags & MDB_IOB_AUTOWRAP) {
+ if (IOB_AUTOWRAP(iob)) {
ASSERT(iob->iob_cols >= iob->iob_nbytes);
n = iob->iob_cols - iob->iob_nbytes;
} else {
@@ -1826,10 +1830,11 @@ mdb_iob_nputs(mdb_iob_t *iob, const char *s, size_t nbytes)
iob->iob_nbytes += m;
if (m == n && nleft != 0) {
- if (iob->iob_flags & MDB_IOB_AUTOWRAP)
+ if (IOB_AUTOWRAP(iob)) {
mdb_iob_nl(iob);
- else
+ } else {
mdb_iob_flush(iob);
+ }
}
}
}
@@ -1875,7 +1880,7 @@ mdb_iob_fill(mdb_iob_t *iob, int c, size_t nfill)
ASSERT(iob->iob_flags & MDB_IOB_WRONLY);
while (nfill != 0) {
- if (iob->iob_flags & MDB_IOB_AUTOWRAP) {
+ if (IOB_AUTOWRAP(iob)) {
ASSERT(iob->iob_cols >= iob->iob_nbytes);
n = iob->iob_cols - iob->iob_nbytes;
} else {
@@ -1892,10 +1897,11 @@ mdb_iob_fill(mdb_iob_t *iob, int c, size_t nfill)
nfill -= m;
if (m == n && nfill != 0) {
- if (iob->iob_flags & MDB_IOB_AUTOWRAP)
+ if (IOB_AUTOWRAP(iob)) {
mdb_iob_nl(iob);
- else
+ } else {
mdb_iob_flush(iob);
+ }
}
}
}
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_set.c b/usr/src/cmd/mdb/common/mdb/mdb_set.c
index c1c8538219..cd8926fbcc 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_set.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_set.c
@@ -24,6 +24,10 @@
*/
/*
+ * Copyright 2017 Joyent, Inc.
+ */
+
+/*
* Support for ::set dcmd. The +/-o option processing code is provided in a
* stand-alone function so it can be used by the command-line option processing
* code in mdb_main.c. This facility provides an easy way for us to add more
@@ -165,6 +169,7 @@ mdb_set_options(const char *s, int enable)
{ "pager", opt_pager, MDB_FL_PAGER },
{ "term", opt_set_term, 0 },
+ { "autowrap", opt_set_mflags, MDB_FL_AUTOWRAP },
{ "ignoreeof", opt_set_mflags, MDB_FL_IGNEOF },
{ "repeatlast", opt_set_mflags, MDB_FL_REPLAST },
{ "latest", opt_set_mflags, MDB_FL_LATEST },
@@ -265,6 +270,13 @@ print_properties(void)
mdb_printf("%*s ", LABEL_INDENT, "debugger options:");
(void) mdb_inc_indent(LABEL_INDENT + 1);
+ /*
+ * The ::set output implicitly relies on "autowrap" being enabled, so
+ * we enable it for the duration of the command.
+ */
+ oflags = mdb.m_flags;
+ mdb.m_flags |= MDB_FL_AUTOWRAP;
+
mdb_printf("follow_exec_mode=");
switch (mdb.m_execmode) {
case MDB_EM_ASK:
@@ -295,6 +307,8 @@ print_properties(void)
if (mdb.m_flags & MDB_FL_ADB)
COMMAFLAG("adb");
+ if (oflags & MDB_FL_AUTOWRAP)
+ COMMAFLAG("autowrap");
if (mdb.m_flags & MDB_FL_IGNEOF)
COMMAFLAG("ignoreeof");
if (mdb.m_flags & MDB_FL_LMRAW)
@@ -331,6 +345,8 @@ print_properties(void)
COMMAFLAG("no-stop");
mdb_printf("\n");
(void) mdb_dec_indent(LABEL_INDENT + 1);
+
+ mdb.m_flags = oflags;
}
/*ARGSUSED*/
diff --git a/usr/src/cmd/mdb/test/options/tst.autowrap.mdb b/usr/src/cmd/mdb/test/options/tst.autowrap.mdb
new file mode 100644
index 0000000000..5c62e288d3
--- /dev/null
+++ b/usr/src/cmd/mdb/test/options/tst.autowrap.mdb
@@ -0,0 +1,8 @@
+::set +o autowrap
+::typedef -c lp32
+0::printf "Pack my box with five dozen liquor jugs. How razorback-jumping frogs can level six piqued gymnasts! Amazingly few discotheques provide jukeboxes.%d" int .
+
+::set -o autowrap
+0::printf "Pack my box with five dozen liquor jugs. How razorback-jumping frogs can level six piqued gymnasts! Amazingly few discotheques provide jukeboxes.%d" int .
+
+
diff --git a/usr/src/cmd/mdb/test/typedef/tst.cleanupstruct.ksh b/usr/src/cmd/mdb/test/typedef/tst.cleanupstruct.ksh
index 1abf7540ce..fabc7dfb57 100644
--- a/usr/src/cmd/mdb/test/typedef/tst.cleanupstruct.ksh
+++ b/usr/src/cmd/mdb/test/typedef/tst.cleanupstruct.ksh
@@ -5,7 +5,7 @@
# will fail validation. So here we go!
#
-TMPFILE="/tmp/$(mktemp mtest.XXXXXX)"
+TMPFILE="$(mktemp -p /tmp mtest.XXXXXX)"
if [[ -z "$TMPFILE" ]]; then
echo "Failed to get a temp file" 2>&1
exit 1
diff --git a/usr/src/man/man1/mdb.1 b/usr/src/man/man1/mdb.1
index f3a084d151..a6adcc8ee0 100644
--- a/usr/src/man/man1/mdb.1
+++ b/usr/src/man/man1/mdb.1
@@ -1,10 +1,10 @@
'\" te
.\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
-.\" Copyright (c) 2012, Joyent, Inc. All Rights Reserved.
+.\" Copyright (c) 2017, Joyent, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH MDB 1 "Oct 05, 2012"
+.TH MDB 1 "Apr 28, 2017"
.SH NAME
mdb \- modular debugger
.SH SYNOPSIS
@@ -3951,6 +3951,17 @@ default.
.sp
.ne 2
.na
+\fB\fBautowrap\fR\fR
+.ad
+.RS 25n
+Forces output to be autowrapped at the terminal width. When this option
+is enabled, \fBmdb\fR will autowrap output, making some attempt to inject
+newlines at word boundaries. This option is disabled by default.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fBfollow_exec_mode=\fR\fImode\fR\fR
.ad
.RS 25n