db_run.c (116176) | db_run.c (131952) |
---|---|
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 116176 2003-06-10 22:09:23Z obrien $"); | 36__FBSDID("$FreeBSD: head/sys/ddb/db_run.c 131952 2004-07-10 23:47:20Z marcel $"); |
37 38#include <sys/param.h> | 37 38#include <sys/param.h> |
39#include <sys/kdb.h> |
|
39 | 40 |
41#include <machine/kdb.h> 42#include <machine/pcb.h> 43 |
|
40#include <vm/vm.h> 41 42#include <ddb/ddb.h> 43#include <ddb/db_break.h> 44#include <ddb/db_access.h> 45 46static int db_run_mode; 47#define STEP_NONE 0 --- 8 unchanged lines hidden (view full) --- 56static int db_loop_count; 57static int db_call_depth; 58 59int db_inst_count; 60int db_load_count; 61int db_store_count; 62 63#ifndef db_set_single_step | 44#include <vm/vm.h> 45 46#include <ddb/ddb.h> 47#include <ddb/db_break.h> 48#include <ddb/db_access.h> 49 50static int db_run_mode; 51#define STEP_NONE 0 --- 8 unchanged lines hidden (view full) --- 60static int db_loop_count; 61static int db_call_depth; 62 63int db_inst_count; 64int db_load_count; 65int db_store_count; 66 67#ifndef db_set_single_step |
64extern void db_set_single_step(db_regs_t *regs); | 68void db_set_single_step(void); |
65#endif 66#ifndef db_clear_single_step | 69#endif 70#ifndef db_clear_single_step |
67extern void db_clear_single_step(db_regs_t *regs); | 71void db_clear_single_step(void); |
68#endif 69 | 72#endif 73 |
70#ifdef notused 71static void db_single_step(db_regs_t *regs); 72#endif 73 | |
74boolean_t 75db_stop_at_pc(is_breakpoint) 76 boolean_t *is_breakpoint; 77{ 78 register db_addr_t pc; 79 register db_breakpoint_t bkpt; 80 | 74boolean_t 75db_stop_at_pc(is_breakpoint) 76 boolean_t *is_breakpoint; 77{ 78 register db_addr_t pc; 79 register db_breakpoint_t bkpt; 80 |
81 db_clear_single_step(DDB_REGS); | 81 db_clear_single_step(); |
82 db_clear_breakpoints(); 83 db_clear_watchpoints(); | 82 db_clear_breakpoints(); 83 db_clear_watchpoints(); |
84 pc = PC_REGS(DDB_REGS); | 84 pc = PC_REGS(); |
85 86#ifdef FIXUP_PC_AFTER_BREAK 87 if (*is_breakpoint) { 88 /* 89 * Breakpoint trap. Fix up the PC if the 90 * machine requires it. 91 */ 92 FIXUP_PC_AFTER_BREAK | 85 86#ifdef FIXUP_PC_AFTER_BREAK 87 if (*is_breakpoint) { 88 /* 89 * Breakpoint trap. Fix up the PC if the 90 * machine requires it. 91 */ 92 FIXUP_PC_AFTER_BREAK |
93 pc = PC_REGS(DDB_REGS); | 93 pc = PC_REGS(); |
94 } 95#endif 96 97 /* 98 * Now check for a breakpoint at this address. 99 */ 100 bkpt = db_find_breakpoint_here(pc); 101 if (bkpt) { --- 64 unchanged lines hidden (view full) --- 166 db_run_mode = STEP_NONE; 167 return (TRUE); 168} 169 170void 171db_restart_at_pc(watchpt) 172 boolean_t watchpt; 173{ | 94 } 95#endif 96 97 /* 98 * Now check for a breakpoint at this address. 99 */ 100 bkpt = db_find_breakpoint_here(pc); 101 if (bkpt) { --- 64 unchanged lines hidden (view full) --- 166 db_run_mode = STEP_NONE; 167 return (TRUE); 168} 169 170void 171db_restart_at_pc(watchpt) 172 boolean_t watchpt; 173{ |
174 register db_addr_t pc = PC_REGS(DDB_REGS); | 174 register db_addr_t pc = PC_REGS(); |
175 176 if ((db_run_mode == STEP_COUNT) || 177 (db_run_mode == STEP_RETURN) || 178 (db_run_mode == STEP_CALLT)) { 179 db_expr_t ins; 180 181 /* 182 * We are about to execute this instruction, --- 17 unchanged lines hidden (view full) --- 200 } 201 202 if (db_run_mode == STEP_CONTINUE) { 203 if (watchpt || db_find_breakpoint_here(pc)) { 204 /* 205 * Step over breakpoint/watchpoint. 206 */ 207 db_run_mode = STEP_INVISIBLE; | 175 176 if ((db_run_mode == STEP_COUNT) || 177 (db_run_mode == STEP_RETURN) || 178 (db_run_mode == STEP_CALLT)) { 179 db_expr_t ins; 180 181 /* 182 * We are about to execute this instruction, --- 17 unchanged lines hidden (view full) --- 200 } 201 202 if (db_run_mode == STEP_CONTINUE) { 203 if (watchpt || db_find_breakpoint_here(pc)) { 204 /* 205 * Step over breakpoint/watchpoint. 206 */ 207 db_run_mode = STEP_INVISIBLE; |
208 db_set_single_step(DDB_REGS); | 208 db_set_single_step(); |
209 } else { 210 db_set_breakpoints(); 211 db_set_watchpoints(); 212 } 213 } else { | 209 } else { 210 db_set_breakpoints(); 211 db_set_watchpoints(); 212 } 213 } else { |
214 db_set_single_step(DDB_REGS); | 214 db_set_single_step(); |
215 } 216} 217 | 215 } 216} 217 |
218#ifdef notused 219static void 220db_single_step(regs) 221 db_regs_t *regs; 222{ 223 if (db_run_mode == STEP_CONTINUE) { 224 db_run_mode = STEP_INVISIBLE; 225 db_set_single_step(regs); 226 } 227} 228#endif 229 | |
230#ifdef SOFTWARE_SSTEP 231/* 232 * Software implementation of single-stepping. 233 * If your machine does not have a trace mode 234 * similar to the vax or sun ones you can use 235 * this implementation, done for the mips. 236 * Just define the above conditional and provide 237 * the functions/macros defined below. --- 18 unchanged lines hidden (view full) --- 256 * If one of these addresses does not already have a breakpoint, 257 * we allocate a breakpoint and save it here. 258 * These breakpoints are deleted on return. 259 */ 260db_breakpoint_t db_not_taken_bkpt = 0; 261db_breakpoint_t db_taken_bkpt = 0; 262 263void | 218#ifdef SOFTWARE_SSTEP 219/* 220 * Software implementation of single-stepping. 221 * If your machine does not have a trace mode 222 * similar to the vax or sun ones you can use 223 * this implementation, done for the mips. 224 * Just define the above conditional and provide 225 * the functions/macros defined below. --- 18 unchanged lines hidden (view full) --- 244 * If one of these addresses does not already have a breakpoint, 245 * we allocate a breakpoint and save it here. 246 * These breakpoints are deleted on return. 247 */ 248db_breakpoint_t db_not_taken_bkpt = 0; 249db_breakpoint_t db_taken_bkpt = 0; 250 251void |
264db_set_single_step(regs) 265 register db_regs_t *regs; | 252db_set_single_step(void) |
266{ | 253{ |
267 db_addr_t pc = PC_REGS(regs), brpc; 268 unsigned inst; | 254 db_addr_t pc = PC_REGS(), brpc; 255 unsigned inst; |
269 270 /* 271 * User was stopped at pc, e.g. the instruction 272 * at pc was not executed. 273 */ 274 inst = db_get_value(pc, sizeof(int), FALSE); 275 if (inst_branch(inst) || inst_call(inst)) { | 256 257 /* 258 * User was stopped at pc, e.g. the instruction 259 * at pc was not executed. 260 */ 261 inst = db_get_value(pc, sizeof(int), FALSE); 262 if (inst_branch(inst) || inst_call(inst)) { |
276 brpc = branch_taken(inst, pc, regs); 277 if (brpc != pc) { /* self-branches are hopeless */ 278 db_taken_bkpt = db_set_temp_breakpoint(brpc); 279 } 280 pc = next_instr_address(pc,1); | 263 brpc = branch_taken(inst, pc); 264 if (brpc != pc) { /* self-branches are hopeless */ 265 db_taken_bkpt = db_set_temp_breakpoint(brpc); 266 } 267 pc = next_instr_address(pc, 1); |
281 } | 268 } |
282 pc = next_instr_address(pc,0); | 269 pc = next_instr_address(pc, 0); |
283 db_not_taken_bkpt = db_set_temp_breakpoint(pc); 284} 285 286void | 270 db_not_taken_bkpt = db_set_temp_breakpoint(pc); 271} 272 273void |
287db_clear_single_step(regs) 288 db_regs_t *regs; | 274db_clear_single_step(void) |
289{ 290 291 if (db_not_taken_bkpt != 0) { | 275{ 276 277 if (db_not_taken_bkpt != 0) { |
292 db_delete_temp_breakpoint(db_not_taken_bkpt); 293 db_not_taken_bkpt = 0; | 278 db_delete_temp_breakpoint(db_not_taken_bkpt); 279 db_not_taken_bkpt = 0; |
294 } 295 if (db_taken_bkpt != 0) { | 280 } 281 if (db_taken_bkpt != 0) { |
296 db_delete_temp_breakpoint(db_taken_bkpt); 297 db_taken_bkpt = 0; | 282 db_delete_temp_breakpoint(db_taken_bkpt); 283 db_taken_bkpt = 0; |
298 } 299} 300 301#endif /* SOFTWARE_SSTEP */ 302 303extern int db_cmd_loop_done; 304 305/* single-step */ --- 91 unchanged lines hidden --- | 284 } 285} 286 287#endif /* SOFTWARE_SSTEP */ 288 289extern int db_cmd_loop_done; 290 291/* single-step */ --- 91 unchanged lines hidden --- |