Deleted Added
full compact
db_run.c (273006) db_run.c (283088)
1/*-
2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the

--- 19 unchanged lines hidden (view full) ---

28 * Date: 7/90
29 */
30
31/*
32 * Commands to run process.
33 */
34
35#include <sys/cdefs.h>
1/*-
2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the

--- 19 unchanged lines hidden (view full) ---

28 * Date: 7/90
29 */
30
31/*
32 * Commands to run process.
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/ddb/db_run.c 273006 2014-10-12 18:01:52Z pfg $");
36__FBSDID("$FreeBSD: head/sys/ddb/db_run.c 283088 2015-05-18 22:27:46Z pfg $");
37
38#include <sys/param.h>
39#include <sys/kdb.h>
40#include <sys/proc.h>
41
42#include <machine/kdb.h>
43#include <machine/pcb.h>
44

--- 37 unchanged lines hidden (view full) ---

82{
83 register db_addr_t pc;
84 register db_breakpoint_t bkpt;
85
86 pc = PC_REGS();
87#ifdef SOFTWARE_SSTEP
88 if ((db_not_taken_bkpt != 0 && pc == db_not_taken_bkpt->address)
89 || (db_taken_bkpt != 0 && pc == db_taken_bkpt->address))
37
38#include <sys/param.h>
39#include <sys/kdb.h>
40#include <sys/proc.h>
41
42#include <machine/kdb.h>
43#include <machine/pcb.h>
44

--- 37 unchanged lines hidden (view full) ---

82{
83 register db_addr_t pc;
84 register db_breakpoint_t bkpt;
85
86 pc = PC_REGS();
87#ifdef SOFTWARE_SSTEP
88 if ((db_not_taken_bkpt != 0 && pc == db_not_taken_bkpt->address)
89 || (db_taken_bkpt != 0 && pc == db_taken_bkpt->address))
90 *is_breakpoint = FALSE;
90 *is_breakpoint = false;
91#endif
92
93 db_clear_single_step();
94 db_clear_breakpoints();
95 db_clear_watchpoints();
96
97#ifdef FIXUP_PC_AFTER_BREAK
98 if (*is_breakpoint) {

--- 8 unchanged lines hidden (view full) ---

107
108 /*
109 * Now check for a breakpoint at this address.
110 */
111 bkpt = db_find_breakpoint_here(pc);
112 if (bkpt) {
113 if (--bkpt->count == 0) {
114 bkpt->count = bkpt->init_count;
91#endif
92
93 db_clear_single_step();
94 db_clear_breakpoints();
95 db_clear_watchpoints();
96
97#ifdef FIXUP_PC_AFTER_BREAK
98 if (*is_breakpoint) {

--- 8 unchanged lines hidden (view full) ---

107
108 /*
109 * Now check for a breakpoint at this address.
110 */
111 bkpt = db_find_breakpoint_here(pc);
112 if (bkpt) {
113 if (--bkpt->count == 0) {
114 bkpt->count = bkpt->init_count;
115 *is_breakpoint = TRUE;
116 return (TRUE); /* stop here */
115 *is_breakpoint = true;
116 return (true); /* stop here */
117 }
118 } else if (*is_breakpoint) {
119#ifdef BKPT_SKIP
120 BKPT_SKIP;
121#endif
122 }
123
117 }
118 } else if (*is_breakpoint) {
119#ifdef BKPT_SKIP
120 BKPT_SKIP;
121#endif
122 }
123
124 *is_breakpoint = FALSE;
124 *is_breakpoint = false;
125
126 if (db_run_mode == STEP_INVISIBLE) {
127 db_run_mode = STEP_CONTINUE;
125
126 if (db_run_mode == STEP_INVISIBLE) {
127 db_run_mode = STEP_CONTINUE;
128 return (FALSE); /* continue */
128 return (false); /* continue */
129 }
130 if (db_run_mode == STEP_COUNT) {
129 }
130 if (db_run_mode == STEP_COUNT) {
131 return (FALSE); /* continue */
131 return (false); /* continue */
132 }
133 if (db_run_mode == STEP_ONCE) {
134 if (--db_loop_count > 0) {
135 if (db_sstep_print) {
136 db_printf("\t\t");
137 db_print_loc_and_inst(pc);
138 db_printf("\n");
139 }
132 }
133 if (db_run_mode == STEP_ONCE) {
134 if (--db_loop_count > 0) {
135 if (db_sstep_print) {
136 db_printf("\t\t");
137 db_print_loc_and_inst(pc);
138 db_printf("\n");
139 }
140 return (FALSE); /* continue */
140 return (false); /* continue */
141 }
142 }
143 if (db_run_mode == STEP_RETURN) {
144 /* continue until matching return */
145 db_expr_t ins;
146
141 }
142 }
143 if (db_run_mode == STEP_RETURN) {
144 /* continue until matching return */
145 db_expr_t ins;
146
147 ins = db_get_value(pc, sizeof(int), FALSE);
147 ins = db_get_value(pc, sizeof(int), false);
148 if (!inst_trap_return(ins) &&
149 (!inst_return(ins) || --db_call_depth != 0)) {
150 if (db_sstep_print) {
151 if (inst_call(ins) || inst_return(ins)) {
152 register int i;
153
154 db_printf("[after %6d] ", db_inst_count);
155 for (i = db_call_depth; --i > 0; )
156 db_printf(" ");
157 db_print_loc_and_inst(pc);
158 db_printf("\n");
159 }
160 }
161 if (inst_call(ins))
162 db_call_depth++;
148 if (!inst_trap_return(ins) &&
149 (!inst_return(ins) || --db_call_depth != 0)) {
150 if (db_sstep_print) {
151 if (inst_call(ins) || inst_return(ins)) {
152 register int i;
153
154 db_printf("[after %6d] ", db_inst_count);
155 for (i = db_call_depth; --i > 0; )
156 db_printf(" ");
157 db_print_loc_and_inst(pc);
158 db_printf("\n");
159 }
160 }
161 if (inst_call(ins))
162 db_call_depth++;
163 return (FALSE); /* continue */
163 return (false); /* continue */
164 }
165 }
166 if (db_run_mode == STEP_CALLT) {
167 /* continue until call or return */
168 db_expr_t ins;
169
164 }
165 }
166 if (db_run_mode == STEP_CALLT) {
167 /* continue until call or return */
168 db_expr_t ins;
169
170 ins = db_get_value(pc, sizeof(int), FALSE);
170 ins = db_get_value(pc, sizeof(int), false);
171 if (!inst_call(ins) &&
172 !inst_return(ins) &&
173 !inst_trap_return(ins)) {
171 if (!inst_call(ins) &&
172 !inst_return(ins) &&
173 !inst_trap_return(ins)) {
174 return (FALSE); /* continue */
174 return (false); /* continue */
175 }
176 }
177 db_run_mode = STEP_NONE;
175 }
176 }
177 db_run_mode = STEP_NONE;
178 return (TRUE);
178 return (true);
179}
180
181void
182db_restart_at_pc(boolean_t watchpt)
183{
184 register db_addr_t pc = PC_REGS();
185
186 if ((db_run_mode == STEP_COUNT) ||
187 (db_run_mode == STEP_RETURN) ||
188 (db_run_mode == STEP_CALLT)) {
189 /*
190 * We are about to execute this instruction,
191 * so count it now.
192 */
193#ifdef SOFTWARE_SSTEP
194 db_expr_t ins =
195#endif
179}
180
181void
182db_restart_at_pc(boolean_t watchpt)
183{
184 register db_addr_t pc = PC_REGS();
185
186 if ((db_run_mode == STEP_COUNT) ||
187 (db_run_mode == STEP_RETURN) ||
188 (db_run_mode == STEP_CALLT)) {
189 /*
190 * We are about to execute this instruction,
191 * so count it now.
192 */
193#ifdef SOFTWARE_SSTEP
194 db_expr_t ins =
195#endif
196 db_get_value(pc, sizeof(int), FALSE);
196 db_get_value(pc, sizeof(int), false);
197 db_inst_count++;
198 db_load_count += inst_load(ins);
199 db_store_count += inst_store(ins);
200#ifdef SOFTWARE_SSTEP
201 /* XXX works on mips, but... */
202 if (inst_branch(ins) || inst_call(ins)) {
203 ins = db_get_value(next_instr_address(pc,1),
197 db_inst_count++;
198 db_load_count += inst_load(ins);
199 db_store_count += inst_store(ins);
200#ifdef SOFTWARE_SSTEP
201 /* XXX works on mips, but... */
202 if (inst_branch(ins) || inst_call(ins)) {
203 ins = db_get_value(next_instr_address(pc,1),
204 sizeof(int), FALSE);
204 sizeof(int), false);
205 db_inst_count++;
206 db_load_count += inst_load(ins);
207 db_store_count += inst_store(ins);
208 }
209#endif /* SOFTWARE_SSTEP */
210 }
211
212 if (db_run_mode == STEP_CONTINUE) {

--- 48 unchanged lines hidden (view full) ---

261{
262 db_addr_t pc = PC_REGS(), brpc;
263 unsigned inst;
264
265 /*
266 * User was stopped at pc, e.g. the instruction
267 * at pc was not executed.
268 */
205 db_inst_count++;
206 db_load_count += inst_load(ins);
207 db_store_count += inst_store(ins);
208 }
209#endif /* SOFTWARE_SSTEP */
210 }
211
212 if (db_run_mode == STEP_CONTINUE) {

--- 48 unchanged lines hidden (view full) ---

261{
262 db_addr_t pc = PC_REGS(), brpc;
263 unsigned inst;
264
265 /*
266 * User was stopped at pc, e.g. the instruction
267 * at pc was not executed.
268 */
269 inst = db_get_value(pc, sizeof(int), FALSE);
269 inst = db_get_value(pc, sizeof(int), false);
270 if (inst_branch(inst) || inst_call(inst) || inst_return(inst)) {
271 brpc = branch_taken(inst, pc);
272 if (brpc != pc) { /* self-branches are hopeless */
273 db_taken_bkpt = db_set_temp_breakpoint(brpc);
274 }
275 pc = next_instr_address(pc, 1);
276 }
277 pc = next_instr_address(pc, 0);

--- 22 unchanged lines hidden (view full) ---

300/*ARGSUSED*/
301void
302db_single_step_cmd(addr, have_addr, count, modif)
303 db_expr_t addr;
304 boolean_t have_addr;
305 db_expr_t count;
306 char * modif;
307{
270 if (inst_branch(inst) || inst_call(inst) || inst_return(inst)) {
271 brpc = branch_taken(inst, pc);
272 if (brpc != pc) { /* self-branches are hopeless */
273 db_taken_bkpt = db_set_temp_breakpoint(brpc);
274 }
275 pc = next_instr_address(pc, 1);
276 }
277 pc = next_instr_address(pc, 0);

--- 22 unchanged lines hidden (view full) ---

300/*ARGSUSED*/
301void
302db_single_step_cmd(addr, have_addr, count, modif)
303 db_expr_t addr;
304 boolean_t have_addr;
305 db_expr_t count;
306 char * modif;
307{
308 boolean_t print = FALSE;
308 boolean_t print = false;
309
310 if (count == -1)
311 count = 1;
312
313 if (modif[0] == 'p')
309
310 if (count == -1)
311 count = 1;
312
313 if (modif[0] == 'p')
314 print = TRUE;
314 print = true;
315
316 db_run_mode = STEP_ONCE;
317 db_loop_count = count;
318 db_sstep_print = print;
319 db_inst_count = 0;
320 db_load_count = 0;
321 db_store_count = 0;
322
323 db_cmd_loop_done = 1;
324}
325
326/* trace and print until call/return */
327/*ARGSUSED*/
328void
329db_trace_until_call_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
330 char *modif)
331{
315
316 db_run_mode = STEP_ONCE;
317 db_loop_count = count;
318 db_sstep_print = print;
319 db_inst_count = 0;
320 db_load_count = 0;
321 db_store_count = 0;
322
323 db_cmd_loop_done = 1;
324}
325
326/* trace and print until call/return */
327/*ARGSUSED*/
328void
329db_trace_until_call_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
330 char *modif)
331{
332 boolean_t print = FALSE;
332 boolean_t print = false;
333
334 if (modif[0] == 'p')
333
334 if (modif[0] == 'p')
335 print = TRUE;
335 print = true;
336
337 db_run_mode = STEP_CALLT;
338 db_sstep_print = print;
339 db_inst_count = 0;
340 db_load_count = 0;
341 db_store_count = 0;
342
343 db_cmd_loop_done = 1;
344}
345
346/*ARGSUSED*/
347void
348db_trace_until_matching_cmd(db_expr_t addr, boolean_t have_addr,
349 db_expr_t count, char *modif)
350{
336
337 db_run_mode = STEP_CALLT;
338 db_sstep_print = print;
339 db_inst_count = 0;
340 db_load_count = 0;
341 db_store_count = 0;
342
343 db_cmd_loop_done = 1;
344}
345
346/*ARGSUSED*/
347void
348db_trace_until_matching_cmd(db_expr_t addr, boolean_t have_addr,
349 db_expr_t count, char *modif)
350{
351 boolean_t print = FALSE;
351 boolean_t print = false;
352
353 if (modif[0] == 'p')
352
353 if (modif[0] == 'p')
354 print = TRUE;
354 print = true;
355
356 db_run_mode = STEP_RETURN;
357 db_call_depth = 1;
358 db_sstep_print = print;
359 db_inst_count = 0;
360 db_load_count = 0;
361 db_store_count = 0;
362

--- 19 unchanged lines hidden ---
355
356 db_run_mode = STEP_RETURN;
357 db_call_depth = 1;
358 db_sstep_print = print;
359 db_inst_count = 0;
360 db_load_count = 0;
361 db_store_count = 0;
362

--- 19 unchanged lines hidden ---