Mercurial > illumos > git > illumos-omnios
changeset 21432:2fc7af213dcd
11186 mdb's output autowrapping should be optional -- and disabled
Reviewed by: Dave Pacheco <dap@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Dan McDonald <danmcd@joyent.com>
author | Bryan Cantrill <bryan@joyent.com> |
---|---|
date | Mon, 03 Jun 2019 13:19:23 +0000 |
parents | 2a556bd9a733 |
children | 416a814ef27e |
files | usr/src/cmd/mdb/common/mdb/mdb.h usr/src/cmd/mdb/common/mdb/mdb_io.c usr/src/cmd/mdb/common/mdb/mdb_set.c usr/src/cmd/mdb/test/options/tst.autowrap.mdb usr/src/cmd/mdb/test/typedef/tst.cleanupstruct.ksh usr/src/man/man1/mdb.1 |
diffstat | 6 files changed, 74 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/mdb/common/mdb/mdb.h Thu Mar 07 22:25:58 2019 +0000 +++ b/usr/src/cmd/mdb/common/mdb/mdb.h Mon Jun 03 13:19:23 2019 +0000 @@ -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 @@ #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 */
--- a/usr/src/cmd/mdb/common/mdb/mdb_io.c Thu Mar 07 22:25:58 2019 +0000 +++ b/usr/src/cmd/mdb/common/mdb/mdb_io.c Mon Jun 03 13:19:23 2019 +0000 @@ -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 @@ #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 @@ 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)) @@ -1809,7 +1813,7 @@ * 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 { @@ -1827,10 +1831,11 @@ 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); + } } } } @@ -1876,7 +1881,7 @@ 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 { @@ -1893,10 +1898,11 @@ 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); + } } } }
--- a/usr/src/cmd/mdb/common/mdb/mdb_set.c Thu Mar 07 22:25:58 2019 +0000 +++ b/usr/src/cmd/mdb/common/mdb/mdb_set.c Mon Jun 03 13:19:23 2019 +0000 @@ -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 @@ { "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 @@ 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 @@ 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 @@ COMMAFLAG("no-stop"); mdb_printf("\n"); (void) mdb_dec_indent(LABEL_INDENT + 1); + + mdb.m_flags = oflags; } /*ARGSUSED*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usr/src/cmd/mdb/test/options/tst.autowrap.mdb Mon Jun 03 13:19:23 2019 +0000 @@ -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 . + +
--- a/usr/src/cmd/mdb/test/typedef/tst.cleanupstruct.ksh Thu Mar 07 22:25:58 2019 +0000 +++ b/usr/src/cmd/mdb/test/typedef/tst.cleanupstruct.ksh Mon Jun 03 13:19:23 2019 +0000 @@ -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
--- a/usr/src/man/man1/mdb.1 Thu Mar 07 22:25:58 2019 +0000 +++ b/usr/src/man/man1/mdb.1 Mon Jun 03 13:19:23 2019 +0000 @@ -1,6 +1,6 @@ '\" 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. .\" Copyright (c) 2014, 2017 by Delphix. 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. @@ -3931,6 +3931,17 @@ .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