version 1.29, 2007/02/22 04:38:06 |
version 1.30, 2007/02/22 06:41:01 |
Line 103 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
Line 103 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
* really a breakpoint so that we don't skip over the real instruction. |
* really a breakpoint so that we don't skip over the real instruction. |
*/ |
*/ |
if (db_taken_bkpt.address == pc || db_not_taken_bkpt.address == pc) |
if (db_taken_bkpt.address == pc || db_not_taken_bkpt.address == pc) |
*is_breakpoint = FALSE; |
*is_breakpoint = false; |
#endif /* SOFTWARE_SSTEP */ |
#endif /* SOFTWARE_SSTEP */ |
|
|
db_clear_single_step(regs); |
db_clear_single_step(regs); |
Line 117 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
Line 117 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
if (bkpt) { |
if (bkpt) { |
if (--bkpt->count == 0) { |
if (--bkpt->count == 0) { |
bkpt->count = bkpt->init_count; |
bkpt->count = bkpt->init_count; |
*is_breakpoint = TRUE; |
*is_breakpoint = true; |
return (TRUE); /* stop here */ |
return (true); /* stop here */ |
} |
} |
} else if (*is_breakpoint) { |
} else if (*is_breakpoint) { |
#ifdef PC_ADVANCE |
#ifdef PC_ADVANCE |
Line 128 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
Line 128 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
#endif |
#endif |
} |
} |
|
|
*is_breakpoint = FALSE; |
*is_breakpoint = false; |
|
|
if (db_run_mode == STEP_INVISIBLE) { |
if (db_run_mode == STEP_INVISIBLE) { |
db_run_mode = STEP_CONTINUE; |
db_run_mode = STEP_CONTINUE; |
return (FALSE); /* continue */ |
return (false); /* continue */ |
} |
} |
if (db_run_mode == STEP_COUNT) { |
if (db_run_mode == STEP_COUNT) { |
return (FALSE); /* continue */ |
return (false); /* continue */ |
} |
} |
if (db_run_mode == STEP_ONCE) { |
if (db_run_mode == STEP_ONCE) { |
if (--db_loop_count > 0) { |
if (--db_loop_count > 0) { |
Line 144 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
Line 144 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
db_print_loc_and_inst(pc); |
db_print_loc_and_inst(pc); |
db_printf("\n"); |
db_printf("\n"); |
} |
} |
return (FALSE); /* continue */ |
return (false); /* continue */ |
} |
} |
} |
} |
if (db_run_mode == STEP_RETURN) { |
if (db_run_mode == STEP_RETURN) { |
db_expr_t ins = db_get_value(pc, sizeof(int), FALSE); |
db_expr_t ins = db_get_value(pc, sizeof(int), false); |
|
|
/* continue until matching return */ |
/* continue until matching return */ |
|
|
Line 168 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
Line 168 db_stop_at_pc(db_regs_t *regs, bool *is_ |
|
} |
} |
if (inst_call(ins)) |
if (inst_call(ins)) |
db_call_depth++; |
db_call_depth++; |
return (FALSE); /* continue */ |
return (false); /* continue */ |
} |
} |
} |
} |
if (db_run_mode == STEP_CALLT) { |
if (db_run_mode == STEP_CALLT) { |
db_expr_t ins = db_get_value(pc, sizeof(int), FALSE); |
db_expr_t ins = db_get_value(pc, sizeof(int), false); |
|
|
/* continue until call or return */ |
/* continue until call or return */ |
|
|
if (!inst_call(ins) && |
if (!inst_call(ins) && |
!inst_return(ins) && |
!inst_return(ins) && |
!inst_trap_return(ins)) { |
!inst_trap_return(ins)) { |
return (FALSE); /* continue */ |
return (false); /* continue */ |
} |
} |
} |
} |
db_run_mode = STEP_NONE; |
db_run_mode = STEP_NONE; |
return (TRUE); |
return (true); |
} |
} |
|
|
void |
void |
Line 203 db_restart_at_pc(db_regs_t *regs, bool w |
|
Line 203 db_restart_at_pc(db_regs_t *regs, bool w |
|
* We are about to execute this instruction, |
* We are about to execute this instruction, |
* so count it now. |
* so count it now. |
*/ |
*/ |
ins = db_get_value(pc, sizeof(int), FALSE); |
ins = db_get_value(pc, sizeof(int), false); |
db_inst_count++; |
db_inst_count++; |
db_load_count += inst_load(ins); |
db_load_count += inst_load(ins); |
db_store_count += inst_store(ins); |
db_store_count += inst_store(ins); |
Line 212 db_restart_at_pc(db_regs_t *regs, bool w |
|
Line 212 db_restart_at_pc(db_regs_t *regs, bool w |
|
/* |
/* |
* Account for instructions in delay slots. |
* Account for instructions in delay slots. |
*/ |
*/ |
brpc = next_instr_address(pc, TRUE); |
brpc = next_instr_address(pc, true); |
if ((brpc != pc) && |
if ((brpc != pc) && |
(inst_branch(ins) || inst_call(ins) || inst_return(ins))) { |
(inst_branch(ins) || inst_call(ins) || inst_return(ins))) { |
ins = db_get_value(brpc, sizeof(int), FALSE); |
ins = db_get_value(brpc, sizeof(int), false); |
db_inst_count++; |
db_inst_count++; |
db_load_count += inst_load(ins); |
db_load_count += inst_load(ins); |
db_store_count += inst_store(ins); |
db_store_count += inst_store(ins); |
|
|
db_single_step_cmd(db_expr_t addr, bool have_addr, |
db_single_step_cmd(db_expr_t addr, bool have_addr, |
db_expr_t count, const char *modif) |
db_expr_t count, const char *modif) |
{ |
{ |
bool print = FALSE; |
bool print = false; |
|
|
if (count == -1) |
if (count == -1) |
count = 1; |
count = 1; |
|
|
if (modif[0] == 'p') |
if (modif[0] == 'p') |
print = TRUE; |
print = true; |
|
|
db_run_mode = STEP_ONCE; |
db_run_mode = STEP_ONCE; |
db_loop_count = count; |
db_loop_count = count; |
|
|
db_trace_until_call_cmd(db_expr_t addr, bool have_addr, |
db_trace_until_call_cmd(db_expr_t addr, bool have_addr, |
db_expr_t count, const char *modif) |
db_expr_t count, const char *modif) |
{ |
{ |
bool print = FALSE; |
bool print = false; |
|
|
if (modif[0] == 'p') |
if (modif[0] == 'p') |
print = TRUE; |
print = true; |
|
|
db_run_mode = STEP_CALLT; |
db_run_mode = STEP_CALLT; |
db_sstep_print = print; |
db_sstep_print = print; |
|
|
db_trace_until_matching_cmd(db_expr_t addr, bool have_addr, |
db_trace_until_matching_cmd(db_expr_t addr, bool have_addr, |
db_expr_t count, const char *modif) |
db_expr_t count, const char *modif) |
{ |
{ |
bool print = FALSE; |
bool print = false; |
|
|
if (modif[0] == 'p') |
if (modif[0] == 'p') |
print = TRUE; |
print = true; |
|
|
db_run_mode = STEP_RETURN; |
db_run_mode = STEP_RETURN; |
db_call_depth = 1; |
db_call_depth = 1; |
Line 343 db_continue_cmd(db_expr_t addr, bool hav |
|
Line 343 db_continue_cmd(db_expr_t addr, bool hav |
|
* |
* |
* bool inst_branch(int inst) |
* bool inst_branch(int inst) |
* bool inst_call(int inst) |
* bool inst_call(int inst) |
* returns TRUE if the instruction might branch |
* returns true if the instruction might branch |
* |
* |
* bool inst_unconditional_flow_transfer(int inst) |
* bool inst_unconditional_flow_transfer(int inst) |
* returns TRUE if the instruction is an unconditional |
* returns true if the instruction is an unconditional |
* transter of flow (i.e. unconditional branch) |
* transter of flow (i.e. unconditional branch) |
* |
* |
* db_addr_t branch_taken(int inst, db_addr_t pc, db_regs_t *regs) |
* db_addr_t branch_taken(int inst, db_addr_t pc, db_regs_t *regs) |
Line 355 db_continue_cmd(db_expr_t addr, bool hav |
|
Line 355 db_continue_cmd(db_expr_t addr, bool hav |
|
* db_addr_t next_instr_address(db_addr_t pc, bool bd) |
* db_addr_t next_instr_address(db_addr_t pc, bool bd) |
* returns the address of the first instruction following the |
* returns the address of the first instruction following the |
* one at "pc", which is either in the taken path of the branch |
* one at "pc", which is either in the taken path of the branch |
* (bd == TRUE) or not. This is for machines (e.g. mips) with |
* (bd == true) or not. This is for machines (e.g. mips) with |
* branch delays. |
* branch delays. |
* |
* |
* A single-step may involve at most 2 breakpoints - |
* A single-step may involve at most 2 breakpoints - |
Line 381 db_set_single_step(db_regs_t *regs) |
|
Line 381 db_set_single_step(db_regs_t *regs) |
|
* User was stopped at pc, e.g. the instruction |
* User was stopped at pc, e.g. the instruction |
* at pc was not executed. |
* at pc was not executed. |
*/ |
*/ |
inst = db_get_value(pc, sizeof(int), FALSE); |
inst = db_get_value(pc, sizeof(int), false); |
if (inst_branch(inst) || inst_call(inst) || inst_return(inst)) { |
if (inst_branch(inst) || inst_call(inst) || inst_return(inst)) { |
brpc = branch_taken(inst, pc, regs); |
brpc = branch_taken(inst, pc, regs); |
if (brpc != pc) { /* self-branches are hopeless */ |
if (brpc != pc) { /* self-branches are hopeless */ |
db_set_temp_breakpoint(&db_taken_bkpt, brpc); |
db_set_temp_breakpoint(&db_taken_bkpt, brpc); |
} else |
} else |
db_taken_bkpt.address = 0; |
db_taken_bkpt.address = 0; |
pc = next_instr_address(pc, TRUE); |
pc = next_instr_address(pc, true); |
} |
} |
|
|
/* |
/* |
Line 397 db_set_single_step(db_regs_t *regs) |
|
Line 397 db_set_single_step(db_regs_t *regs) |
|
*/ |
*/ |
unconditional = inst_unconditional_flow_transfer(inst); |
unconditional = inst_unconditional_flow_transfer(inst); |
|
|
pc = next_instr_address(pc, FALSE); |
pc = next_instr_address(pc, false); |
|
|
/* |
/* |
* We only set the sequential breakpoint if previous |
* We only set the sequential breakpoint if previous |
Line 415 db_set_single_step(db_regs_t *regs) |
|
Line 415 db_set_single_step(db_regs_t *regs) |
|
* in the same place even if the MD code would otherwise |
* in the same place even if the MD code would otherwise |
* have us do so. |
* have us do so. |
*/ |
*/ |
if (unconditional == FALSE && |
if (unconditional == false && |
db_find_breakpoint_here(pc) == 0 && |
db_find_breakpoint_here(pc) == 0 && |
pc != brpc) |
pc != brpc) |
db_set_temp_breakpoint(&db_not_taken_bkpt, pc); |
db_set_temp_breakpoint(&db_not_taken_bkpt, pc); |
Line 444 db_set_temp_breakpoint(db_breakpoint_t b |
|
Line 444 db_set_temp_breakpoint(db_breakpoint_t b |
|
bkpt->init_count = 1; |
bkpt->init_count = 1; |
bkpt->count = 1; |
bkpt->count = 1; |
|
|
bkpt->bkpt_inst = db_get_value(bkpt->address, BKPT_SIZE, FALSE); |
bkpt->bkpt_inst = db_get_value(bkpt->address, BKPT_SIZE, false); |
db_put_value(bkpt->address, BKPT_SIZE, |
db_put_value(bkpt->address, BKPT_SIZE, |
BKPT_SET(bkpt->bkpt_inst, bkpt->address)); |
BKPT_SET(bkpt->bkpt_inst, bkpt->address)); |
} |
} |