--- Gnu-Mach/ddb/db_run.c 2020/09/02 04:36:57 1.1 +++ Gnu-Mach/ddb/db_run.c 2020/09/02 04:48:22 1.1.1.4 @@ -1,25 +1,25 @@ -/* +/* * Mach Operating System * Copyright (c) 1993-1990 Carnegie Mellon University * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -28,7 +28,6 @@ * Date: 7/90 */ -#include "mach_kdb.h" #if MACH_KDB /* @@ -42,6 +41,12 @@ #include #include #include +#include +#include +#include +#include +#include + int db_run_mode; @@ -54,25 +59,13 @@ int db_last_inst_count; int db_load_count; int db_store_count; -#ifndef db_set_single_step -void db_set_task_single_step(/* db_regs_t *, task_t */);/* forward */ -#else -#define db_set_task_single_step(regs,task) db_set_single_step(regs) -#endif -#ifndef db_clear_single_step -void db_clear_task_single_step(/* db_regs_t *, task_t */); -#else -#define db_clear_task_single_step(regs,task) db_clear_single_step(regs) -#endif - boolean_t -db_stop_at_pc(is_breakpoint, task) - boolean_t *is_breakpoint; - task_t task; -{ - register db_addr_t pc; - register db_thread_breakpoint_t bkpt; - boolean_t db_cond_check(); +db_stop_at_pc( + boolean_t *is_breakpoint, + task_t task) +{ + db_addr_t pc; + db_thread_breakpoint_t bkpt; db_clear_task_single_step(DDB_REGS, task); db_clear_breakpoints(); @@ -88,7 +81,7 @@ db_stop_at_pc(is_breakpoint, task) FIXUP_PC_AFTER_BREAK pc = PC_REGS(DDB_REGS); } -#endif +#endif /* FIXUP_PC_AFTER_BREAK */ /* * Now check for a breakpoint at this address. @@ -127,7 +120,7 @@ db_stop_at_pc(is_breakpoint, task) (!inst_return(ins) || --db_call_depth != 0)) { if (db_sstep_print) { if (inst_call(ins) || inst_return(ins)) { - register int i; + int i; db_printf("[after %6d /%4d] ", db_inst_count, @@ -163,32 +156,32 @@ db_stop_at_pc(is_breakpoint, task) } void -db_restart_at_pc(watchpt, task) - boolean_t watchpt; - task_t task; +db_restart_at_pc( + boolean_t watchpt, + task_t task) { - register db_addr_t pc = PC_REGS(DDB_REGS), brpc; + db_addr_t pc = PC_REGS(DDB_REGS); if ((db_run_mode == STEP_COUNT) || (db_run_mode == STEP_RETURN) || (db_run_mode == STEP_CALLT)) { - db_expr_t ins; /* * We are about to execute this instruction, * so count it now. */ - ins = db_get_task_value(pc, sizeof(int), FALSE, task); + db_get_task_value(pc, sizeof(int), FALSE, task); db_inst_count++; db_load_count += inst_load(ins); db_store_count += inst_store(ins); #ifdef SOFTWARE_SSTEP + db_addr_t brpc; /* Account for instructions in delay slots */ - brpc = next_instr_address(pc,1,task); + brpc = next_instr_address(pc, 1, task); if ((brpc != pc) && (inst_branch(ins) || inst_call(ins))) { /* Note: this ~assumes an instruction <= sizeof(int) */ - ins = db_get_task_value(brpc, sizeof(int), FALSE, task); + db_get_task_value(brpc, sizeof(int), FALSE, task); db_inst_count++; db_load_count += inst_load(ins); db_store_count += inst_store(ins); @@ -213,9 +206,9 @@ db_restart_at_pc(watchpt, task) } void -db_single_step(regs, task) - db_regs_t *regs; - task_t task; +db_single_step( + db_regs_t *regs, + task_t task) { if (db_run_mode == STEP_CONTINUE) { db_run_mode = STEP_INVISIBLE; @@ -240,7 +233,7 @@ db_single_step(regs, task) * db_getreg_val(); return the value of a user register, * as indicated in the hardware instruction * encoding, e.g. 8 for r8 - * + * * next_instr_address(pc,bd,task) returns the address of the first * instruction following the one at "pc", * which is either in the taken path of @@ -252,14 +245,14 @@ db_single_step(regs, task) * If one of these addresses does not already have a breakpoint, * we allocate a breakpoint and save it here. * These breakpoints are deleted on return. - */ + */ db_breakpoint_t db_not_taken_bkpt = 0; db_breakpoint_t db_taken_bkpt = 0; -db_breakpoint_t +db_breakpoint_t __attribute__ ((pure)) db_find_temp_breakpoint(task, addr) - task_t task; - db_addr_t addr; + const task_t task; + db_addr_t addr; { if (db_taken_bkpt && (db_taken_bkpt->address == addr) && db_taken_bkpt->task == task) @@ -271,13 +264,13 @@ db_find_temp_breakpoint(task, addr) } void -db_set_task_single_step(regs, task) - register db_regs_t *regs; - task_t task; +db_set_task_single_step( + db_regs_t *regs, + task_t task) { db_addr_t pc = PC_REGS(regs), brpc; - register unsigned int inst; - register boolean_t unconditional; + unsigned int inst; + boolean_t unconditional; /* * User was stopped at pc, e.g. the instruction @@ -294,18 +287,18 @@ db_set_task_single_step(regs, task) db_taken_bkpt = 0; pc = next_instr_address(pc,1,task); } - + /* check if this control flow instruction is an unconditional transfer */ unconditional = inst_unconditional_flow_transfer(inst); pc = next_instr_address(pc,0,task); - /* + /* We only set the sequential breakpoint if previous instruction was not an unconditional change of flow of control. If the previous instruction is an unconditional change of flow of control, setting a breakpoint in the next sequential location may set a breakpoint in data or in another routine, - which could screw up either the program or the debugger. - (Consider, for instance, that the next sequential instruction is the + which could screw up either the program or the debugger. + (Consider, for instance, that the next sequential instruction is the start of a routine needed by the debugger.) */ if (!unconditional && db_find_breakpoint_here(task, pc) == 0) { @@ -317,8 +310,8 @@ db_set_task_single_step(regs, task) void db_clear_task_single_step(regs, task) - db_regs_t *regs; - task_t task; + const db_regs_t *regs; + task_t task; { if (db_taken_bkpt != 0) { db_delete_temp_breakpoint(task, db_taken_bkpt); @@ -342,7 +335,7 @@ db_single_step_cmd(addr, have_addr, coun db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { boolean_t print = FALSE; @@ -370,7 +363,7 @@ db_trace_until_call_cmd(addr, have_addr, db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { boolean_t print = FALSE; @@ -393,7 +386,7 @@ db_trace_until_matching_cmd(addr, have_a db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { boolean_t print = FALSE; @@ -418,7 +411,7 @@ db_continue_cmd(addr, have_addr, count, db_expr_t addr; int have_addr; db_expr_t count; - char * modif; + const char * modif; { if (modif[0] == 'c') db_run_mode = STEP_COUNT; @@ -433,9 +426,9 @@ db_continue_cmd(addr, have_addr, count, } boolean_t -db_in_single_step() +db_in_single_step(void) { return(db_run_mode != STEP_NONE && db_run_mode != STEP_CONTINUE); } -#endif MACH_KDB +#endif /* MACH_KDB */