7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright (c) 2012 by Delphix. All rights reserved.
27 * Copyright (c) 2012 Joyent, Inc. All rights reserved.
28 */
29
30 /*
31 * Modular Debugger (MDB)
32 *
33 * Refer to the white paper "A Modular Debugger for Solaris" for information
34 * on the design, features, and goals of MDB. See /shared/sac/PSARC/1999/169
35 * for copies of the paper and related documentation.
36 *
37 * This file provides the basic construction and destruction of the debugger's
38 * global state, as well as the main execution loop, mdb_run(). MDB maintains
39 * a stack of execution frames (mdb_frame_t's) that keep track of its current
40 * state, including a stack of input and output buffers, walk and memory
41 * garbage collect lists, and a list of commands (mdb_cmd_t's). As the
42 * parser consumes input, it fills in a list of commands to execute, and then
43 * invokes mdb_call(), below. A command consists of a dcmd, telling us
44 * what function to execute, and a list of arguments and other invocation-
45 * specific data. Each frame may have more than one command, kept on a list,
46 * when multiple commands are separated by | operators. New frames may be
47 * stacked on old ones by nested calls to mdb_run: this occurs when, for
1138 /*
1139 * If standard output is a pipe and there are vcbs active, we need to
1140 * flush standard out and the write-side of the pipe. The reasons for
1141 * this are explained in more detail in mdb_vcb.c.
1142 */
1143 if ((flags & DCMD_PIPE_OUT) && (vcbs != NULL)) {
1144 mdb_iob_flush(mdb.m_out);
1145 (void) mdb_iob_ctl(mdb.m_out, I_FLUSH, (void *)FLUSHW);
1146 }
1147
1148 return (status);
1149 }
1150
1151 void
1152 mdb_call_tab(mdb_idcmd_t *idcp, mdb_tab_cookie_t *mcp, uint_t flags,
1153 uintmax_t argc, mdb_arg_t *argv)
1154 {
1155 if (idcp->idc_tabp == NULL)
1156 return;
1157
1158 idcp->idc_tabp(mcp, flags, argc, argv);
1159 }
1160
1161 /*
1162 * Call an internal dcmd directly: this code is used by module API functions
1163 * that need to execute dcmds, and by mdb_call() above.
1164 */
1165 int
1166 mdb_call_idcmd(mdb_idcmd_t *idcp, uintmax_t addr, uintmax_t count,
1167 uint_t flags, mdb_argvec_t *avp, mdb_addrvec_t *adp, mdb_vcb_t *vcbs)
1168 {
1169 int is_exec = (strcmp(idcp->idc_name, "$<") == 0);
1170 mdb_arg_t *argv;
1171 int argc;
1172 uintmax_t i;
1173 int status;
1174
1175 /*
1176 * Update the values of dot and the most recent address and count
1177 * to the values of our input parameters.
1178 */
|
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright (c) 2012 by Delphix. All rights reserved.
27 * Copyright (c) 2018, Joyent, Inc.
28 */
29
30 /*
31 * Modular Debugger (MDB)
32 *
33 * Refer to the white paper "A Modular Debugger for Solaris" for information
34 * on the design, features, and goals of MDB. See /shared/sac/PSARC/1999/169
35 * for copies of the paper and related documentation.
36 *
37 * This file provides the basic construction and destruction of the debugger's
38 * global state, as well as the main execution loop, mdb_run(). MDB maintains
39 * a stack of execution frames (mdb_frame_t's) that keep track of its current
40 * state, including a stack of input and output buffers, walk and memory
41 * garbage collect lists, and a list of commands (mdb_cmd_t's). As the
42 * parser consumes input, it fills in a list of commands to execute, and then
43 * invokes mdb_call(), below. A command consists of a dcmd, telling us
44 * what function to execute, and a list of arguments and other invocation-
45 * specific data. Each frame may have more than one command, kept on a list,
46 * when multiple commands are separated by | operators. New frames may be
47 * stacked on old ones by nested calls to mdb_run: this occurs when, for
1138 /*
1139 * If standard output is a pipe and there are vcbs active, we need to
1140 * flush standard out and the write-side of the pipe. The reasons for
1141 * this are explained in more detail in mdb_vcb.c.
1142 */
1143 if ((flags & DCMD_PIPE_OUT) && (vcbs != NULL)) {
1144 mdb_iob_flush(mdb.m_out);
1145 (void) mdb_iob_ctl(mdb.m_out, I_FLUSH, (void *)FLUSHW);
1146 }
1147
1148 return (status);
1149 }
1150
1151 void
1152 mdb_call_tab(mdb_idcmd_t *idcp, mdb_tab_cookie_t *mcp, uint_t flags,
1153 uintmax_t argc, mdb_arg_t *argv)
1154 {
1155 if (idcp->idc_tabp == NULL)
1156 return;
1157
1158 (void) idcp->idc_tabp(mcp, flags, argc, argv);
1159 }
1160
1161 /*
1162 * Call an internal dcmd directly: this code is used by module API functions
1163 * that need to execute dcmds, and by mdb_call() above.
1164 */
1165 int
1166 mdb_call_idcmd(mdb_idcmd_t *idcp, uintmax_t addr, uintmax_t count,
1167 uint_t flags, mdb_argvec_t *avp, mdb_addrvec_t *adp, mdb_vcb_t *vcbs)
1168 {
1169 int is_exec = (strcmp(idcp->idc_name, "$<") == 0);
1170 mdb_arg_t *argv;
1171 int argc;
1172 uintmax_t i;
1173 int status;
1174
1175 /*
1176 * Update the values of dot and the most recent address and count
1177 * to the values of our input parameters.
1178 */
|