xref: /freebsd/sys/ddb/db_run.c (revision 1e24fd3bd9bc17a36017ef1fdbc8bf6a5631c084)
1dd3cb568SWarner Losh /*-
25b81b6b3SRodney W. Grimes  * Mach Operating System
35b81b6b3SRodney W. Grimes  * Copyright (c) 1991,1990 Carnegie Mellon University
45b81b6b3SRodney W. Grimes  * All Rights Reserved.
55b81b6b3SRodney W. Grimes  *
65b81b6b3SRodney W. Grimes  * Permission to use, copy, modify and distribute this software and its
75b81b6b3SRodney W. Grimes  * documentation is hereby granted, provided that both the copyright
85b81b6b3SRodney W. Grimes  * notice and this permission notice appear in all copies of the
95b81b6b3SRodney W. Grimes  * software, derivative works or modified versions, and any portions
105b81b6b3SRodney W. Grimes  * thereof, and that both notices appear in supporting documentation.
115b81b6b3SRodney W. Grimes  *
125b81b6b3SRodney W. Grimes  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
135b81b6b3SRodney W. Grimes  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
145b81b6b3SRodney W. Grimes  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
155b81b6b3SRodney W. Grimes  *
165b81b6b3SRodney W. Grimes  * Carnegie Mellon requests users of this software to return to
175b81b6b3SRodney W. Grimes  *
185b81b6b3SRodney W. Grimes  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
195b81b6b3SRodney W. Grimes  *  School of Computer Science
205b81b6b3SRodney W. Grimes  *  Carnegie Mellon University
215b81b6b3SRodney W. Grimes  *  Pittsburgh PA 15213-3890
225b81b6b3SRodney W. Grimes  *
235b81b6b3SRodney W. Grimes  * any improvements or extensions that they make and grant Carnegie the
245b81b6b3SRodney W. Grimes  * rights to redistribute these changes.
255b81b6b3SRodney W. Grimes  */
265b81b6b3SRodney W. Grimes /*
275b81b6b3SRodney W. Grimes  * 	Author: David B. Golub, Carnegie Mellon University
285b81b6b3SRodney W. Grimes  *	Date:	7/90
295b81b6b3SRodney W. Grimes  */
305b81b6b3SRodney W. Grimes 
315b81b6b3SRodney W. Grimes /*
325b81b6b3SRodney W. Grimes  * Commands to run process.
335b81b6b3SRodney W. Grimes  */
34753960f7SDavid E. O'Brien 
35753960f7SDavid E. O'Brien #include <sys/cdefs.h>
36753960f7SDavid E. O'Brien __FBSDID("$FreeBSD$");
37753960f7SDavid E. O'Brien 
38f540b106SGarrett Wollman #include <sys/param.h>
3937224cd3SMarcel Moolenaar #include <sys/kdb.h>
4020984f2fSPeter Wemm #include <sys/proc.h>
4137224cd3SMarcel Moolenaar 
4237224cd3SMarcel Moolenaar #include <machine/kdb.h>
4337224cd3SMarcel Moolenaar #include <machine/pcb.h>
445b81b6b3SRodney W. Grimes 
455ccbc3ccSBruce Evans #include <vm/vm.h>
465ccbc3ccSBruce Evans 
475ccbc3ccSBruce Evans #include <ddb/ddb.h>
485b81b6b3SRodney W. Grimes #include <ddb/db_break.h>
495b81b6b3SRodney W. Grimes #include <ddb/db_access.h>
505b81b6b3SRodney W. Grimes 
515b81b6b3SRodney W. Grimes #define	STEP_ONCE	1
525b81b6b3SRodney W. Grimes #define	STEP_RETURN	2
535b81b6b3SRodney W. Grimes #define	STEP_CALLT	3
545b81b6b3SRodney W. Grimes #define	STEP_CONTINUE	4
555b81b6b3SRodney W. Grimes #define	STEP_INVISIBLE	5
565b81b6b3SRodney W. Grimes #define	STEP_COUNT	6
57*1e24fd3bSBruce Evans static int	db_run_mode = STEP_CONTINUE;
585b81b6b3SRodney W. Grimes 
59bd20334cSBruce Evans static bool		db_sstep_multiple;
60cd508278SPedro F. Giffuni static bool		db_sstep_print;
6125eb640dSPoul-Henning Kamp static int		db_loop_count;
6225eb640dSPoul-Henning Kamp static int		db_call_depth;
635b81b6b3SRodney W. Grimes 
645b81b6b3SRodney W. Grimes int		db_inst_count;
655b81b6b3SRodney W. Grimes int		db_load_count;
665b81b6b3SRodney W. Grimes int		db_store_count;
675b81b6b3SRodney W. Grimes 
68cdf23c19SZbigniew Bodek #ifdef SOFTWARE_SSTEP
69cdf23c19SZbigniew Bodek db_breakpoint_t	db_not_taken_bkpt = 0;
70cdf23c19SZbigniew Bodek db_breakpoint_t	db_taken_bkpt = 0;
71cdf23c19SZbigniew Bodek #endif
72cdf23c19SZbigniew Bodek 
735b81b6b3SRodney W. Grimes #ifndef db_set_single_step
7437224cd3SMarcel Moolenaar void db_set_single_step(void);
755b81b6b3SRodney W. Grimes #endif
765b81b6b3SRodney W. Grimes #ifndef db_clear_single_step
7737224cd3SMarcel Moolenaar void db_clear_single_step(void);
78f73a856dSPoul-Henning Kamp #endif
79cdf23c19SZbigniew Bodek #ifndef db_pc_is_singlestep
80cdf23c19SZbigniew Bodek static bool
81cdf23c19SZbigniew Bodek db_pc_is_singlestep(db_addr_t pc)
82cdf23c19SZbigniew Bodek {
8375f88c7cSOlivier Houchard #ifdef SOFTWARE_SSTEP
84cdf23c19SZbigniew Bodek 	if ((db_not_taken_bkpt != 0 && pc == db_not_taken_bkpt->address)
85cdf23c19SZbigniew Bodek 	    || (db_taken_bkpt != 0 && pc == db_taken_bkpt->address))
86cdf23c19SZbigniew Bodek 		return (true);
87cdf23c19SZbigniew Bodek #endif
88cdf23c19SZbigniew Bodek 	return (false);
89cdf23c19SZbigniew Bodek }
9075f88c7cSOlivier Houchard #endif
9175f88c7cSOlivier Houchard 
92cd508278SPedro F. Giffuni bool
935c48342fSBruce Evans db_stop_at_pc(int type, int code, bool *is_breakpoint, bool *is_watchpoint)
945b81b6b3SRodney W. Grimes {
950a95ab74SPedro F. Giffuni 	db_addr_t	pc;
960a95ab74SPedro F. Giffuni 	db_breakpoint_t bkpt;
975b81b6b3SRodney W. Grimes 
985c48342fSBruce Evans 	*is_breakpoint = IS_BREAKPOINT_TRAP(type, code);
995c48342fSBruce Evans 	*is_watchpoint = IS_WATCHPOINT_TRAP(type, code);
10075f88c7cSOlivier Houchard 	pc = PC_REGS();
101cdf23c19SZbigniew Bodek 	if (db_pc_is_singlestep(pc))
1022b490bc7SPedro F. Giffuni 		*is_breakpoint = false;
10375f88c7cSOlivier Houchard 
10437224cd3SMarcel Moolenaar 	db_clear_single_step();
1055b81b6b3SRodney W. Grimes 	db_clear_breakpoints();
1065b81b6b3SRodney W. Grimes 	db_clear_watchpoints();
1075b81b6b3SRodney W. Grimes 
1085b81b6b3SRodney W. Grimes #ifdef	FIXUP_PC_AFTER_BREAK
1095b81b6b3SRodney W. Grimes 	if (*is_breakpoint) {
1105b81b6b3SRodney W. Grimes 	    /*
1115b81b6b3SRodney W. Grimes 	     * Breakpoint trap.  Fix up the PC if the
1125b81b6b3SRodney W. Grimes 	     * machine requires it.
1135b81b6b3SRodney W. Grimes 	     */
1145b81b6b3SRodney W. Grimes 	    FIXUP_PC_AFTER_BREAK
11537224cd3SMarcel Moolenaar 	    pc = PC_REGS();
1165b81b6b3SRodney W. Grimes 	}
1175b81b6b3SRodney W. Grimes #endif
1185b81b6b3SRodney W. Grimes 
1195b81b6b3SRodney W. Grimes 	/*
1205b81b6b3SRodney W. Grimes 	 * Now check for a breakpoint at this address.
1215b81b6b3SRodney W. Grimes 	 */
1225b81b6b3SRodney W. Grimes 	bkpt = db_find_breakpoint_here(pc);
1235b81b6b3SRodney W. Grimes 	if (bkpt) {
1245b81b6b3SRodney W. Grimes 	    if (--bkpt->count == 0) {
1255b81b6b3SRodney W. Grimes 		bkpt->count = bkpt->init_count;
1262b490bc7SPedro F. Giffuni 		*is_breakpoint = true;
1272b490bc7SPedro F. Giffuni 		return (true);	/* stop here */
1285b81b6b3SRodney W. Grimes 	    }
12910c458ccSBruce Evans 	    return (false);	/* continue the countdown */
1305b81b6b3SRodney W. Grimes 	} else if (*is_breakpoint) {
1313a0b4f25SDoug Rabson #ifdef BKPT_SKIP
1323a0b4f25SDoug Rabson 		BKPT_SKIP;
133ecbb00a2SDoug Rabson #endif
1345b81b6b3SRodney W. Grimes 	}
1355b81b6b3SRodney W. Grimes 
136bd20334cSBruce Evans 	*is_breakpoint = false;	/* might be a breakpoint, but not ours */
137bd20334cSBruce Evans 
138bd20334cSBruce Evans 	/*
139bd20334cSBruce Evans 	 * If stepping, then abort if the trap type is unexpected.
140bd20334cSBruce Evans 	 * Breakpoints owned by us are expected and were handled above.
141bd20334cSBruce Evans 	 * Single-steps are expected and are handled below.  All others
142bd20334cSBruce Evans 	 * are unexpected.
143bd20334cSBruce Evans 	 *
144bd20334cSBruce Evans 	 * If the MD layer doesn't tell us when it is stepping, use the
145bd20334cSBruce Evans 	 * bad historical default that all unexepected traps.
146bd20334cSBruce Evans 	 */
147bd20334cSBruce Evans #ifndef IS_SSTEP_TRAP
148bd20334cSBruce Evans #define	IS_SSTEP_TRAP(type, code)	true
149bd20334cSBruce Evans #endif
150bd20334cSBruce Evans 	if (db_run_mode != STEP_CONTINUE && !IS_SSTEP_TRAP(type, code)) {
151bd20334cSBruce Evans 	    printf("Stepping aborted\n");
152bd20334cSBruce Evans 	    return (true);
153bd20334cSBruce Evans 	}
1545b81b6b3SRodney W. Grimes 
1555b81b6b3SRodney W. Grimes 	if (db_run_mode == STEP_INVISIBLE) {
1565b81b6b3SRodney W. Grimes 	    db_run_mode = STEP_CONTINUE;
1572b490bc7SPedro F. Giffuni 	    return (false);	/* continue */
1585b81b6b3SRodney W. Grimes 	}
1595b81b6b3SRodney W. Grimes 	if (db_run_mode == STEP_COUNT) {
1602b490bc7SPedro F. Giffuni 	    return (false); /* continue */
1615b81b6b3SRodney W. Grimes 	}
1625b81b6b3SRodney W. Grimes 	if (db_run_mode == STEP_ONCE) {
1635b81b6b3SRodney W. Grimes 	    if (--db_loop_count > 0) {
1645b81b6b3SRodney W. Grimes 		if (db_sstep_print) {
1655b81b6b3SRodney W. Grimes 		    db_printf("\t\t");
1665b81b6b3SRodney W. Grimes 		    db_print_loc_and_inst(pc);
1675b81b6b3SRodney W. Grimes 		}
1682b490bc7SPedro F. Giffuni 		return (false);	/* continue */
1695b81b6b3SRodney W. Grimes 	    }
1705b81b6b3SRodney W. Grimes 	}
1715b81b6b3SRodney W. Grimes 	if (db_run_mode == STEP_RETURN) {
1725b81b6b3SRodney W. Grimes 	    /* continue until matching return */
17353b3e912SMaxime Henrion 	    db_expr_t ins;
1745b81b6b3SRodney W. Grimes 
1752b490bc7SPedro F. Giffuni 	    ins = db_get_value(pc, sizeof(int), false);
1765b81b6b3SRodney W. Grimes 	    if (!inst_trap_return(ins) &&
1775b81b6b3SRodney W. Grimes 		(!inst_return(ins) || --db_call_depth != 0)) {
1785b81b6b3SRodney W. Grimes 		if (db_sstep_print) {
1795b81b6b3SRodney W. Grimes 		    if (inst_call(ins) || inst_return(ins)) {
1800a95ab74SPedro F. Giffuni 			int i;
1815b81b6b3SRodney W. Grimes 
1825b81b6b3SRodney W. Grimes 			db_printf("[after %6d]     ", db_inst_count);
1835b81b6b3SRodney W. Grimes 			for (i = db_call_depth; --i > 0; )
1845b81b6b3SRodney W. Grimes 			    db_printf("  ");
1855b81b6b3SRodney W. Grimes 			db_print_loc_and_inst(pc);
1865b81b6b3SRodney W. Grimes 		    }
1875b81b6b3SRodney W. Grimes 		}
1885b81b6b3SRodney W. Grimes 		if (inst_call(ins))
1895b81b6b3SRodney W. Grimes 		    db_call_depth++;
1902b490bc7SPedro F. Giffuni 		return (false);	/* continue */
1915b81b6b3SRodney W. Grimes 	    }
1925b81b6b3SRodney W. Grimes 	}
1935b81b6b3SRodney W. Grimes 	if (db_run_mode == STEP_CALLT) {
1945b81b6b3SRodney W. Grimes 	    /* continue until call or return */
19553b3e912SMaxime Henrion 	    db_expr_t ins;
1965b81b6b3SRodney W. Grimes 
1972b490bc7SPedro F. Giffuni 	    ins = db_get_value(pc, sizeof(int), false);
1985b81b6b3SRodney W. Grimes 	    if (!inst_call(ins) &&
1995b81b6b3SRodney W. Grimes 		!inst_return(ins) &&
2005b81b6b3SRodney W. Grimes 		!inst_trap_return(ins)) {
2012b490bc7SPedro F. Giffuni 		return (false);	/* continue */
2025b81b6b3SRodney W. Grimes 	    }
2035b81b6b3SRodney W. Grimes 	}
2042b490bc7SPedro F. Giffuni 	return (true);
2055b81b6b3SRodney W. Grimes }
2065b81b6b3SRodney W. Grimes 
2075b81b6b3SRodney W. Grimes void
208cd508278SPedro F. Giffuni db_restart_at_pc(bool watchpt)
2095b81b6b3SRodney W. Grimes {
2100a95ab74SPedro F. Giffuni 	db_addr_t	pc = PC_REGS();
2115b81b6b3SRodney W. Grimes 
2125b81b6b3SRodney W. Grimes 	if ((db_run_mode == STEP_COUNT) ||
213bd20334cSBruce Evans 	    ((db_run_mode == STEP_ONCE) && db_sstep_multiple) ||
2145b81b6b3SRodney W. Grimes 	    (db_run_mode == STEP_RETURN) ||
2155b81b6b3SRodney W. Grimes 	    (db_run_mode == STEP_CALLT)) {
2165b81b6b3SRodney W. Grimes 	    /*
2175b81b6b3SRodney W. Grimes 	     * We are about to execute this instruction,
2185b81b6b3SRodney W. Grimes 	     * so count it now.
2195b81b6b3SRodney W. Grimes 	     */
220c6cb86ccSWarner Losh #ifdef	SOFTWARE_SSTEP
221c6cb86ccSWarner Losh 	    db_expr_t		ins =
222c6cb86ccSWarner Losh #endif
2232b490bc7SPedro F. Giffuni 	    db_get_value(pc, sizeof(int), false);
2245b81b6b3SRodney W. Grimes 	    db_inst_count++;
2255b81b6b3SRodney W. Grimes 	    db_load_count += inst_load(ins);
2265b81b6b3SRodney W. Grimes 	    db_store_count += inst_store(ins);
2275b81b6b3SRodney W. Grimes #ifdef	SOFTWARE_SSTEP
2285b81b6b3SRodney W. Grimes 	    /* XXX works on mips, but... */
2295b81b6b3SRodney W. Grimes 	    if (inst_branch(ins) || inst_call(ins)) {
2305b81b6b3SRodney W. Grimes 		ins = db_get_value(next_instr_address(pc,1),
2312b490bc7SPedro F. Giffuni 				   sizeof(int), false);
2325b81b6b3SRodney W. Grimes 		db_inst_count++;
2335b81b6b3SRodney W. Grimes 		db_load_count += inst_load(ins);
2345b81b6b3SRodney W. Grimes 		db_store_count += inst_store(ins);
2355b81b6b3SRodney W. Grimes 	    }
23668016904SDavid E. O'Brien #endif	/* SOFTWARE_SSTEP */
2375b81b6b3SRodney W. Grimes 	}
2385b81b6b3SRodney W. Grimes 
2395b81b6b3SRodney W. Grimes 	if (db_run_mode == STEP_CONTINUE) {
2405b81b6b3SRodney W. Grimes 	    if (watchpt || db_find_breakpoint_here(pc)) {
2415b81b6b3SRodney W. Grimes 		/*
2425b81b6b3SRodney W. Grimes 		 * Step over breakpoint/watchpoint.
2435b81b6b3SRodney W. Grimes 		 */
2445b81b6b3SRodney W. Grimes 		db_run_mode = STEP_INVISIBLE;
24537224cd3SMarcel Moolenaar 		db_set_single_step();
2465b81b6b3SRodney W. Grimes 	    } else {
2475b81b6b3SRodney W. Grimes 		db_set_breakpoints();
2485b81b6b3SRodney W. Grimes 		db_set_watchpoints();
2495b81b6b3SRodney W. Grimes 	    }
2505b81b6b3SRodney W. Grimes 	} else {
25137224cd3SMarcel Moolenaar 	    db_set_single_step();
2525b81b6b3SRodney W. Grimes 	}
2535b81b6b3SRodney W. Grimes }
2545b81b6b3SRodney W. Grimes 
2555b81b6b3SRodney W. Grimes #ifdef	SOFTWARE_SSTEP
2565b81b6b3SRodney W. Grimes /*
2575b81b6b3SRodney W. Grimes  *	Software implementation of single-stepping.
2585b81b6b3SRodney W. Grimes  *	If your machine does not have a trace mode
2595b81b6b3SRodney W. Grimes  *	similar to the vax or sun ones you can use
2605b81b6b3SRodney W. Grimes  *	this implementation, done for the mips.
2615b81b6b3SRodney W. Grimes  *	Just define the above conditional and provide
2625b81b6b3SRodney W. Grimes  *	the functions/macros defined below.
2635b81b6b3SRodney W. Grimes  *
264cd508278SPedro F. Giffuni  * extern bool
2655b81b6b3SRodney W. Grimes  *	inst_branch(),		returns true if the instruction might branch
2665b81b6b3SRodney W. Grimes  * extern unsigned
2675b81b6b3SRodney W. Grimes  *	branch_taken(),		return the address the instruction might
2685b81b6b3SRodney W. Grimes  *				branch to
2695b81b6b3SRodney W. Grimes  *	db_getreg_val();	return the value of a user register,
2705b81b6b3SRodney W. Grimes  *				as indicated in the hardware instruction
2715b81b6b3SRodney W. Grimes  *				encoding, e.g. 8 for r8
2725b81b6b3SRodney W. Grimes  *
2735b81b6b3SRodney W. Grimes  * next_instr_address(pc,bd)	returns the address of the first
2745b81b6b3SRodney W. Grimes  *				instruction following the one at "pc",
2755b81b6b3SRodney W. Grimes  *				which is either in the taken path of
2765b81b6b3SRodney W. Grimes  *				the branch (bd==1) or not.  This is
2775b81b6b3SRodney W. Grimes  *				for machines (mips) with branch delays.
2785b81b6b3SRodney W. Grimes  *
2795b81b6b3SRodney W. Grimes  *	A single-step may involve at most 2 breakpoints -
2805b81b6b3SRodney W. Grimes  *	one for branch-not-taken and one for branch taken.
2815b81b6b3SRodney W. Grimes  *	If one of these addresses does not already have a breakpoint,
2825b81b6b3SRodney W. Grimes  *	we allocate a breakpoint and save it here.
2835b81b6b3SRodney W. Grimes  *	These breakpoints are deleted on return.
2845b81b6b3SRodney W. Grimes  */
2855b81b6b3SRodney W. Grimes 
2865b81b6b3SRodney W. Grimes void
28737224cd3SMarcel Moolenaar db_set_single_step(void)
2885b81b6b3SRodney W. Grimes {
28937224cd3SMarcel Moolenaar 	db_addr_t pc = PC_REGS(), brpc;
2907045d394SDoug Rabson 	unsigned inst;
2915b81b6b3SRodney W. Grimes 
2925b81b6b3SRodney W. Grimes 	/*
2935b81b6b3SRodney W. Grimes 	 *	User was stopped at pc, e.g. the instruction
2945b81b6b3SRodney W. Grimes 	 *	at pc was not executed.
2955b81b6b3SRodney W. Grimes 	 */
2962b490bc7SPedro F. Giffuni 	inst = db_get_value(pc, sizeof(int), false);
29708cfba5dSOlivier Houchard 	if (inst_branch(inst) || inst_call(inst) || inst_return(inst)) {
29837224cd3SMarcel Moolenaar 		brpc = branch_taken(inst, pc);
2995b81b6b3SRodney W. Grimes 		if (brpc != pc) {	/* self-branches are hopeless */
3005b81b6b3SRodney W. Grimes 			db_taken_bkpt = db_set_temp_breakpoint(brpc);
3015b81b6b3SRodney W. Grimes 		}
3025b81b6b3SRodney W. Grimes 		pc = next_instr_address(pc, 1);
3035b81b6b3SRodney W. Grimes 	}
3045b81b6b3SRodney W. Grimes 	pc = next_instr_address(pc, 0);
3055b81b6b3SRodney W. Grimes 	db_not_taken_bkpt = db_set_temp_breakpoint(pc);
3065b81b6b3SRodney W. Grimes }
3075b81b6b3SRodney W. Grimes 
3085b81b6b3SRodney W. Grimes void
30937224cd3SMarcel Moolenaar db_clear_single_step(void)
3105b81b6b3SRodney W. Grimes {
3115b81b6b3SRodney W. Grimes 
3125b81b6b3SRodney W. Grimes 	if (db_not_taken_bkpt != 0) {
3135b81b6b3SRodney W. Grimes 		db_delete_temp_breakpoint(db_not_taken_bkpt);
3145b81b6b3SRodney W. Grimes 		db_not_taken_bkpt = 0;
3155b81b6b3SRodney W. Grimes 	}
31646e5fdffSDoug Rabson 	if (db_taken_bkpt != 0) {
31746e5fdffSDoug Rabson 		db_delete_temp_breakpoint(db_taken_bkpt);
31846e5fdffSDoug Rabson 		db_taken_bkpt = 0;
31946e5fdffSDoug Rabson 	}
3205b81b6b3SRodney W. Grimes }
3215b81b6b3SRodney W. Grimes 
32268016904SDavid E. O'Brien #endif	/* SOFTWARE_SSTEP */
3235b81b6b3SRodney W. Grimes 
3245b81b6b3SRodney W. Grimes extern int	db_cmd_loop_done;
3255b81b6b3SRodney W. Grimes 
3265b81b6b3SRodney W. Grimes /* single-step */
3275b81b6b3SRodney W. Grimes /*ARGSUSED*/
3285b81b6b3SRodney W. Grimes void
329cd508278SPedro F. Giffuni db_single_step_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
3305b81b6b3SRodney W. Grimes {
331cd508278SPedro F. Giffuni 	bool		print = false;
3325b81b6b3SRodney W. Grimes 
3335b81b6b3SRodney W. Grimes 	if (count == -1)
3345b81b6b3SRodney W. Grimes 	    count = 1;
3355b81b6b3SRodney W. Grimes 
3365b81b6b3SRodney W. Grimes 	if (modif[0] == 'p')
3372b490bc7SPedro F. Giffuni 	    print = true;
3385b81b6b3SRodney W. Grimes 
3395b81b6b3SRodney W. Grimes 	db_run_mode = STEP_ONCE;
3405b81b6b3SRodney W. Grimes 	db_loop_count = count;
341bd20334cSBruce Evans 	db_sstep_multiple = (count != 1);
3425b81b6b3SRodney W. Grimes 	db_sstep_print = print;
3435b81b6b3SRodney W. Grimes 	db_inst_count = 0;
3445b81b6b3SRodney W. Grimes 	db_load_count = 0;
3455b81b6b3SRodney W. Grimes 	db_store_count = 0;
3465b81b6b3SRodney W. Grimes 
3475b81b6b3SRodney W. Grimes 	db_cmd_loop_done = 1;
3485b81b6b3SRodney W. Grimes }
3495b81b6b3SRodney W. Grimes 
3505b81b6b3SRodney W. Grimes /* trace and print until call/return */
3515b81b6b3SRodney W. Grimes /*ARGSUSED*/
3525b81b6b3SRodney W. Grimes void
353cd508278SPedro F. Giffuni db_trace_until_call_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
354a41dd031SPedro F. Giffuni     char *modif)
3555b81b6b3SRodney W. Grimes {
356cd508278SPedro F. Giffuni 	bool	print = false;
3575b81b6b3SRodney W. Grimes 
3585b81b6b3SRodney W. Grimes 	if (modif[0] == 'p')
3592b490bc7SPedro F. Giffuni 	    print = true;
3605b81b6b3SRodney W. Grimes 
3615b81b6b3SRodney W. Grimes 	db_run_mode = STEP_CALLT;
3625b81b6b3SRodney W. Grimes 	db_sstep_print = print;
3635b81b6b3SRodney W. Grimes 	db_inst_count = 0;
3645b81b6b3SRodney W. Grimes 	db_load_count = 0;
3655b81b6b3SRodney W. Grimes 	db_store_count = 0;
3665b81b6b3SRodney W. Grimes 
3675b81b6b3SRodney W. Grimes 	db_cmd_loop_done = 1;
3685b81b6b3SRodney W. Grimes }
3695b81b6b3SRodney W. Grimes 
3705b81b6b3SRodney W. Grimes /*ARGSUSED*/
3715b81b6b3SRodney W. Grimes void
372cd508278SPedro F. Giffuni db_trace_until_matching_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
373cd508278SPedro F. Giffuni     char *modif)
3745b81b6b3SRodney W. Grimes {
375cd508278SPedro F. Giffuni 	bool	print = false;
3765b81b6b3SRodney W. Grimes 
3775b81b6b3SRodney W. Grimes 	if (modif[0] == 'p')
3782b490bc7SPedro F. Giffuni 	    print = true;
3795b81b6b3SRodney W. Grimes 
3805b81b6b3SRodney W. Grimes 	db_run_mode = STEP_RETURN;
3815b81b6b3SRodney W. Grimes 	db_call_depth = 1;
3825b81b6b3SRodney W. Grimes 	db_sstep_print = print;
3835b81b6b3SRodney W. Grimes 	db_inst_count = 0;
3845b81b6b3SRodney W. Grimes 	db_load_count = 0;
3855b81b6b3SRodney W. Grimes 	db_store_count = 0;
3865b81b6b3SRodney W. Grimes 
3875b81b6b3SRodney W. Grimes 	db_cmd_loop_done = 1;
3885b81b6b3SRodney W. Grimes }
3895b81b6b3SRodney W. Grimes 
3905b81b6b3SRodney W. Grimes /* continue */
3915b81b6b3SRodney W. Grimes /*ARGSUSED*/
3925b81b6b3SRodney W. Grimes void
393cd508278SPedro F. Giffuni db_continue_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
3945b81b6b3SRodney W. Grimes {
3955b81b6b3SRodney W. Grimes 	if (modif[0] == 'c')
3965b81b6b3SRodney W. Grimes 	    db_run_mode = STEP_COUNT;
3975b81b6b3SRodney W. Grimes 	else
3985b81b6b3SRodney W. Grimes 	    db_run_mode = STEP_CONTINUE;
3995b81b6b3SRodney W. Grimes 	db_inst_count = 0;
4005b81b6b3SRodney W. Grimes 	db_load_count = 0;
4015b81b6b3SRodney W. Grimes 	db_store_count = 0;
4025b81b6b3SRodney W. Grimes 
4035b81b6b3SRodney W. Grimes 	db_cmd_loop_done = 1;
4045b81b6b3SRodney W. Grimes }
405