2002-02-15 10:33:48 +03:00
|
|
|
/* $NetBSD: db_run.c,v 1.22 2002/02/15 07:33:52 simonb Exp $ */
|
1994-06-29 10:29:24 +04:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
/*
|
1993-03-21 12:45:37 +03:00
|
|
|
* Mach Operating System
|
1997-06-26 05:18:11 +04:00
|
|
|
* Copyright (c) 1993-1990 Carnegie Mellon University
|
1993-03-21 12:45:37 +03:00
|
|
|
* All Rights Reserved.
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* 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.
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1999-04-13 00:38:17 +04:00
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
1993-03-21 12:45:37 +03:00
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
|
|
|
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* Carnegie Mellon requests users of this software to return to
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
2002-02-15 10:33:48 +03:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
1993-05-20 07:39:04 +04:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* Author: David B. Golub, Carnegie Mellon University
|
|
|
|
* Date: 7/90
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Commands to run process.
|
|
|
|
*/
|
1998-07-05 02:18:13 +04:00
|
|
|
|
2001-11-13 01:54:03 +03:00
|
|
|
#include <sys/cdefs.h>
|
2002-02-15 10:33:48 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: db_run.c,v 1.22 2002/02/15 07:33:52 simonb Exp $");
|
2001-11-13 01:54:03 +03:00
|
|
|
|
1998-07-05 02:18:13 +04:00
|
|
|
#include "opt_ddb.h"
|
|
|
|
|
1994-10-09 11:29:55 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
|
|
|
#include <machine/db_machdep.h>
|
|
|
|
|
1994-10-09 11:19:29 +03:00
|
|
|
#include <ddb/db_run.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <ddb/db_access.h>
|
1998-04-03 23:45:12 +04:00
|
|
|
#include <ddb/db_break.h>
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
int db_inst_count;
|
|
|
|
int db_load_count;
|
|
|
|
int db_store_count;
|
|
|
|
|
1998-04-03 23:45:12 +04:00
|
|
|
#ifdef SOFTWARE_SSTEP
|
2002-02-15 10:33:48 +03:00
|
|
|
static void db_set_temp_breakpoint(db_breakpoint_t, db_addr_t);
|
|
|
|
static void db_delete_temp_breakpoint(db_breakpoint_t);
|
1998-04-03 23:45:12 +04:00
|
|
|
static struct db_breakpoint db_not_taken_bkpt;
|
|
|
|
static struct db_breakpoint db_taken_bkpt;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(DDB)
|
|
|
|
#include <ddb/db_lex.h>
|
1996-02-05 04:56:47 +03:00
|
|
|
#include <ddb/db_watch.h>
|
|
|
|
#include <ddb/db_output.h>
|
|
|
|
#include <ddb/db_sym.h>
|
|
|
|
#include <ddb/db_extern.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
static int db_run_mode;
|
1993-03-21 12:45:37 +03:00
|
|
|
#define STEP_NONE 0
|
|
|
|
#define STEP_ONCE 1
|
|
|
|
#define STEP_RETURN 2
|
|
|
|
#define STEP_CALLT 3
|
|
|
|
#define STEP_CONTINUE 4
|
|
|
|
#define STEP_INVISIBLE 5
|
|
|
|
#define STEP_COUNT 6
|
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
static boolean_t db_sstep_print;
|
|
|
|
static int db_loop_count;
|
|
|
|
static int db_call_depth;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
boolean_t
|
2002-02-15 10:33:48 +03:00
|
|
|
db_stop_at_pc(db_regs_t *regs, boolean_t *is_breakpoint)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-03-30 15:31:26 +04:00
|
|
|
db_addr_t pc;
|
|
|
|
db_breakpoint_t bkpt;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-12-11 02:09:31 +03:00
|
|
|
pc = PC_REGS(regs);
|
|
|
|
|
1999-04-21 04:00:06 +04:00
|
|
|
#ifdef FIXUP_PC_AFTER_BREAK
|
|
|
|
if (*is_breakpoint) {
|
|
|
|
/*
|
|
|
|
* Breakpoint trap. Regardless if we treat this as a
|
|
|
|
* real breakpoint (e.g. software single-step), fix up the PC.
|
|
|
|
*/
|
|
|
|
FIXUP_PC_AFTER_BREAK(regs);
|
|
|
|
pc = PC_REGS(regs);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1997-12-11 02:09:31 +03:00
|
|
|
#ifdef SOFTWARE_SSTEP
|
|
|
|
/*
|
1999-04-21 04:00:06 +04:00
|
|
|
* If we stopped at one of the single-step breakpoints, say it's not
|
|
|
|
* really a breakpoint so that we don't skip over the real instruction.
|
1997-12-11 02:09:31 +03:00
|
|
|
*/
|
1998-04-03 23:45:12 +04:00
|
|
|
if (db_taken_bkpt.address == pc || db_not_taken_bkpt.address == pc)
|
1997-12-11 02:09:31 +03:00
|
|
|
*is_breakpoint = FALSE;
|
1999-04-21 04:00:06 +04:00
|
|
|
#endif /* SOFTWARE_SSTEP */
|
1997-12-11 02:09:31 +03:00
|
|
|
|
1994-10-09 11:19:29 +03:00
|
|
|
db_clear_single_step(regs);
|
1993-03-21 12:45:37 +03:00
|
|
|
db_clear_breakpoints();
|
|
|
|
db_clear_watchpoints();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now check for a breakpoint at this address.
|
|
|
|
*/
|
|
|
|
bkpt = db_find_breakpoint_here(pc);
|
|
|
|
if (bkpt) {
|
2002-02-15 10:33:48 +03:00
|
|
|
if (--bkpt->count == 0) {
|
|
|
|
bkpt->count = bkpt->init_count;
|
|
|
|
*is_breakpoint = TRUE;
|
|
|
|
return (TRUE); /* stop here */
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
} else if (*is_breakpoint) {
|
1997-09-10 23:37:31 +04:00
|
|
|
#ifdef PC_ADVANCE
|
|
|
|
PC_ADVANCE(regs);
|
|
|
|
#else
|
1994-10-09 11:19:29 +03:00
|
|
|
PC_REGS(regs) += BKPT_SIZE;
|
1997-09-10 23:37:31 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2002-02-15 10:33:48 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
*is_breakpoint = FALSE;
|
|
|
|
|
|
|
|
if (db_run_mode == STEP_INVISIBLE) {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_run_mode = STEP_CONTINUE;
|
|
|
|
return (FALSE); /* continue */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
if (db_run_mode == STEP_COUNT) {
|
2002-02-15 10:33:48 +03:00
|
|
|
return (FALSE); /* continue */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
if (db_run_mode == STEP_ONCE) {
|
2002-02-15 10:33:48 +03:00
|
|
|
if (--db_loop_count > 0) {
|
|
|
|
if (db_sstep_print) {
|
|
|
|
db_printf("\t\t");
|
|
|
|
db_print_loc_and_inst(pc);
|
|
|
|
db_printf("\n");
|
|
|
|
}
|
|
|
|
return (FALSE); /* continue */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (db_run_mode == STEP_RETURN) {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_expr_t ins = db_get_value(pc, sizeof(int), FALSE);
|
|
|
|
|
|
|
|
/* continue until matching return */
|
|
|
|
|
|
|
|
if (!inst_trap_return(ins) &&
|
|
|
|
(!inst_return(ins) || --db_call_depth != 0)) {
|
|
|
|
if (db_sstep_print) {
|
|
|
|
if (inst_call(ins) || inst_return(ins)) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
db_printf("[after %6d] ",
|
|
|
|
db_inst_count);
|
|
|
|
for (i = db_call_depth; --i > 0; )
|
|
|
|
db_printf(" ");
|
|
|
|
db_print_loc_and_inst(pc);
|
|
|
|
db_printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (inst_call(ins))
|
|
|
|
db_call_depth++;
|
|
|
|
return (FALSE); /* continue */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (db_run_mode == STEP_CALLT) {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_expr_t ins = db_get_value(pc, sizeof(int), FALSE);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
/* continue until call or return */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
if (!inst_call(ins) &&
|
|
|
|
!inst_return(ins) &&
|
|
|
|
!inst_trap_return(ins)) {
|
|
|
|
return (FALSE); /* continue */
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
db_run_mode = STEP_NONE;
|
|
|
|
return (TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_restart_at_pc(db_regs_t *regs, boolean_t watchpt)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-03-30 15:31:26 +04:00
|
|
|
db_addr_t pc = PC_REGS(regs);
|
2002-02-15 10:33:48 +03:00
|
|
|
#ifdef SOFTWARE_SSTEP
|
|
|
|
db_addr_t brpc;
|
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if ((db_run_mode == STEP_COUNT) ||
|
|
|
|
(db_run_mode == STEP_RETURN) ||
|
|
|
|
(db_run_mode == STEP_CALLT)) {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_expr_t ins;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2002-02-15 10:33:48 +03:00
|
|
|
/*
|
|
|
|
* We are about to execute this instruction,
|
|
|
|
* so count it now.
|
|
|
|
*/
|
|
|
|
ins = db_get_value(pc, sizeof(int), FALSE);
|
|
|
|
db_inst_count++;
|
|
|
|
db_load_count += inst_load(ins);
|
|
|
|
db_store_count += inst_store(ins);
|
1997-06-26 05:18:11 +04:00
|
|
|
|
|
|
|
#ifdef SOFTWARE_SSTEP
|
2002-02-15 10:33:48 +03:00
|
|
|
/*
|
|
|
|
* Account for instructions in delay slots.
|
|
|
|
*/
|
1997-06-26 05:18:11 +04:00
|
|
|
brpc = next_instr_address(pc, TRUE);
|
1998-11-25 09:38:03 +03:00
|
|
|
if ((brpc != pc) &&
|
|
|
|
(inst_branch(ins) || inst_call(ins) || inst_return(ins))) {
|
2002-02-15 10:33:48 +03:00
|
|
|
ins = db_get_value(brpc, sizeof(int), FALSE);
|
|
|
|
db_inst_count++;
|
|
|
|
db_load_count += inst_load(ins);
|
|
|
|
db_store_count += inst_store(ins);
|
1997-06-26 05:18:11 +04:00
|
|
|
}
|
1997-02-03 22:57:41 +03:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (db_run_mode == STEP_CONTINUE) {
|
2002-02-15 10:33:48 +03:00
|
|
|
if (watchpt || db_find_breakpoint_here(pc)) {
|
|
|
|
/*
|
|
|
|
* Step over breakpoint/watchpoint.
|
|
|
|
*/
|
|
|
|
db_run_mode = STEP_INVISIBLE;
|
|
|
|
db_set_single_step(regs);
|
|
|
|
} else {
|
|
|
|
db_set_breakpoints();
|
|
|
|
db_set_watchpoints();
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
} else {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_set_single_step(regs);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_single_step(db_regs_t *regs)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
if (db_run_mode == STEP_CONTINUE) {
|
2002-02-15 10:33:48 +03:00
|
|
|
db_run_mode = STEP_INVISIBLE;
|
|
|
|
db_set_single_step(regs);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-03 23:45:12 +04:00
|
|
|
/* single-step */
|
|
|
|
/*ARGSUSED*/
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_single_step_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
|
1998-04-03 23:45:12 +04:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
boolean_t print = FALSE;
|
1998-04-03 23:45:12 +04:00
|
|
|
|
|
|
|
if (count == -1)
|
2002-02-15 10:33:48 +03:00
|
|
|
count = 1;
|
1998-04-03 23:45:12 +04:00
|
|
|
|
|
|
|
if (modif[0] == 'p')
|
2002-02-15 10:33:48 +03:00
|
|
|
print = TRUE;
|
1998-04-03 23:45:12 +04:00
|
|
|
|
|
|
|
db_run_mode = STEP_ONCE;
|
|
|
|
db_loop_count = count;
|
|
|
|
db_sstep_print = print;
|
|
|
|
db_inst_count = 0;
|
|
|
|
db_load_count = 0;
|
|
|
|
db_store_count = 0;
|
|
|
|
|
|
|
|
db_cmd_loop_done = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* trace and print until call/return */
|
|
|
|
/*ARGSUSED*/
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_trace_until_call_cmd(db_expr_t addr, int have_addr, db_expr_t count,
|
|
|
|
char *modif)
|
1998-04-03 23:45:12 +04:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
boolean_t print = FALSE;
|
1998-04-03 23:45:12 +04:00
|
|
|
|
|
|
|
if (modif[0] == 'p')
|
2002-02-15 10:33:48 +03:00
|
|
|
print = TRUE;
|
1998-04-03 23:45:12 +04:00
|
|
|
|
|
|
|
db_run_mode = STEP_CALLT;
|
|
|
|
db_sstep_print = print;
|
|
|
|
db_inst_count = 0;
|
|
|
|
db_load_count = 0;
|
|
|
|
db_store_count = 0;
|
|
|
|
|
|
|
|
db_cmd_loop_done = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_trace_until_matching_cmd(db_expr_t addr, int have_addr, db_expr_t count,
|
|
|
|
char *modif)
|
1998-04-03 23:45:12 +04:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
boolean_t print = FALSE;
|
1998-04-03 23:45:12 +04:00
|
|
|
|
|
|
|
if (modif[0] == 'p')
|
2002-02-15 10:33:48 +03:00
|
|
|
print = TRUE;
|
1998-04-03 23:45:12 +04:00
|
|
|
|
|
|
|
db_run_mode = STEP_RETURN;
|
|
|
|
db_call_depth = 1;
|
|
|
|
db_sstep_print = print;
|
|
|
|
db_inst_count = 0;
|
|
|
|
db_load_count = 0;
|
|
|
|
db_store_count = 0;
|
|
|
|
|
|
|
|
db_cmd_loop_done = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* continue */
|
|
|
|
/*ARGSUSED*/
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_continue_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
|
1998-04-03 23:45:12 +04:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
|
1998-04-03 23:45:12 +04:00
|
|
|
if (modif[0] == 'c')
|
2002-02-15 10:33:48 +03:00
|
|
|
db_run_mode = STEP_COUNT;
|
1998-04-03 23:45:12 +04:00
|
|
|
else
|
2002-02-15 10:33:48 +03:00
|
|
|
db_run_mode = STEP_CONTINUE;
|
1998-04-03 23:45:12 +04:00
|
|
|
db_inst_count = 0;
|
|
|
|
db_load_count = 0;
|
|
|
|
db_store_count = 0;
|
|
|
|
|
|
|
|
db_cmd_loop_done = 1;
|
|
|
|
}
|
|
|
|
#endif /* DDB */
|
|
|
|
|
1997-06-26 05:18:11 +04:00
|
|
|
#ifdef SOFTWARE_SSTEP
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Software implementation of single-stepping.
|
|
|
|
* If your machine does not have a trace mode
|
|
|
|
* similar to the vax or sun ones you can use
|
|
|
|
* this implementation, done for the mips.
|
|
|
|
* Just define the above conditional and provide
|
|
|
|
* the functions/macros defined below.
|
|
|
|
*
|
1997-06-26 05:18:11 +04:00
|
|
|
* boolean_t inst_branch(int inst)
|
|
|
|
* boolean_t inst_call(int inst)
|
|
|
|
* returns TRUE if the instruction might branch
|
|
|
|
*
|
|
|
|
* boolean_t inst_unconditional_flow_transfer(int inst)
|
|
|
|
* returns TRUE if the instruction is an unconditional
|
|
|
|
* transter of flow (i.e. unconditional branch)
|
|
|
|
*
|
|
|
|
* db_addr_t branch_taken(int inst, db_addr_t pc, db_regs_t *regs)
|
|
|
|
* returns the target address of the branch
|
|
|
|
*
|
|
|
|
* db_addr_t next_instr_address(db_addr_t pc, boolean_t bd)
|
|
|
|
* returns the address of the first instruction following the
|
|
|
|
* 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
|
|
|
|
* branch delays.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* A single-step may involve at most 2 breakpoints -
|
|
|
|
* one for branch-not-taken and one for branch taken.
|
|
|
|
* 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.
|
2002-02-15 10:33:48 +03:00
|
|
|
*/
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1998-04-03 23:45:12 +04:00
|
|
|
#if !defined(DDB)
|
|
|
|
/* XXX - don't check for existing breakpoints in KGDB-only case */
|
|
|
|
#define db_find_breakpoint_here(pc) (0)
|
|
|
|
#endif
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_set_single_step(db_regs_t *regs)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-12-11 02:09:31 +03:00
|
|
|
db_addr_t pc = PC_REGS(regs), brpc = pc;
|
1997-06-26 05:18:11 +04:00
|
|
|
boolean_t unconditional;
|
|
|
|
unsigned int inst;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* User was stopped at pc, e.g. the instruction
|
|
|
|
* at pc was not executed.
|
|
|
|
*/
|
|
|
|
inst = db_get_value(pc, sizeof(int), FALSE);
|
1998-11-25 09:38:03 +03:00
|
|
|
if (inst_branch(inst) || inst_call(inst) || inst_return(inst)) {
|
1997-06-26 05:18:11 +04:00
|
|
|
brpc = branch_taken(inst, pc, regs);
|
|
|
|
if (brpc != pc) { /* self-branches are hopeless */
|
1998-04-03 23:45:12 +04:00
|
|
|
db_set_temp_breakpoint(&db_taken_bkpt, brpc);
|
1997-06-26 05:18:11 +04:00
|
|
|
} else
|
1998-04-03 23:45:12 +04:00
|
|
|
db_taken_bkpt.address = 0;
|
1997-06-26 05:18:11 +04:00
|
|
|
pc = next_instr_address(pc, TRUE);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-06-26 05:18:11 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if this control flow instruction is an
|
|
|
|
* unconditional transfer.
|
|
|
|
*/
|
|
|
|
unconditional = inst_unconditional_flow_transfer(inst);
|
|
|
|
|
|
|
|
pc = next_instr_address(pc, FALSE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We only set the sequential breakpoint if previous
|
|
|
|
* instruction was not an unconditional change of flow
|
|
|
|
* control. If the previous instruction is an
|
|
|
|
* unconditional change of flow control, setting a
|
|
|
|
* breakpoint in the next sequential location may set
|
|
|
|
* a breakpoint in data or in another routine, which
|
|
|
|
* could screw up in either the program or the debugger.
|
|
|
|
* (Consider, for instance, that the next sequential
|
|
|
|
* instruction is the start of a routine needed by the
|
|
|
|
* debugger.)
|
1997-12-11 02:09:31 +03:00
|
|
|
*
|
|
|
|
* Also, don't set both the taken and not-taken breakpoints
|
|
|
|
* in the same place even if the MD code would otherwise
|
|
|
|
* have us do so.
|
1997-06-26 05:18:11 +04:00
|
|
|
*/
|
1997-12-11 02:09:31 +03:00
|
|
|
if (unconditional == FALSE &&
|
|
|
|
db_find_breakpoint_here(pc) == 0 &&
|
|
|
|
pc != brpc)
|
1998-04-03 23:45:12 +04:00
|
|
|
db_set_temp_breakpoint(&db_not_taken_bkpt, pc);
|
1997-06-26 05:18:11 +04:00
|
|
|
else
|
1998-04-03 23:45:12 +04:00
|
|
|
db_not_taken_bkpt.address = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_clear_single_step(db_regs_t *regs)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
1998-04-03 23:45:12 +04:00
|
|
|
if (db_taken_bkpt.address != 0)
|
|
|
|
db_delete_temp_breakpoint(&db_taken_bkpt);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1998-04-03 23:45:12 +04:00
|
|
|
if (db_not_taken_bkpt.address != 0)
|
|
|
|
db_delete_temp_breakpoint(&db_not_taken_bkpt);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_set_temp_breakpoint(db_breakpoint_t bkpt, db_addr_t addr)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
|
1998-04-03 23:45:12 +04:00
|
|
|
bkpt->map = NULL;
|
|
|
|
bkpt->address = addr;
|
|
|
|
/* bkpt->flags = BKPT_TEMP; - this is not used */
|
|
|
|
bkpt->init_count = 1;
|
|
|
|
bkpt->count = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1998-04-03 23:45:12 +04:00
|
|
|
bkpt->bkpt_inst = db_get_value(bkpt->address, BKPT_SIZE, FALSE);
|
|
|
|
db_put_value(bkpt->address, BKPT_SIZE, BKPT_SET(bkpt->bkpt_inst));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-02-15 10:33:48 +03:00
|
|
|
db_delete_temp_breakpoint(db_breakpoint_t bkpt)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2002-02-15 10:33:48 +03:00
|
|
|
|
1998-04-03 23:45:12 +04:00
|
|
|
db_put_value(bkpt->address, BKPT_SIZE, bkpt->bkpt_inst);
|
|
|
|
bkpt->address = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1998-04-03 23:45:12 +04:00
|
|
|
#endif /* SOFTWARE_SSTEP */
|