Fix branch handling in ddb. From Bucky Katz.

This commit is contained in:
christos 2007-01-06 16:14:44 +00:00
parent acedbdccc7
commit 897538853e
2 changed files with 16 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.40 2006/04/05 00:38:51 uwe Exp $ */
/* $NetBSD: db_interface.c,v 1.41 2007/01/06 16:14:44 christos Exp $ */
/*
* Copyright (c) 1996 Scott K. Stevens
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.40 2006/04/05 00:38:51 uwe Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.41 2007/01/06 16:14:44 christos Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -464,6 +464,10 @@ branch_taken(u_int insn, u_int pc, db_regs_t *regs)
addr = pc + 8 + (addr << 2);
db_read_bytes(addr, 4, (char *)&addr);
return (addr);
case 0x5: /* ldr pc, [reg] */
addr = db_fetch_reg((insn >> 16) & 0xf, regs);
db_read_bytes(addr, 4, (char *)&addr);
return (addr);
case 0x1: /* mov pc, reg */
addr = db_fetch_reg(insn & 0xf, regs);
return (addr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.13 2006/05/10 06:24:02 skrll Exp $ */
/* $NetBSD: db_machdep.h,v 1.14 2007/01/06 16:14:44 christos Exp $ */
/*
* Copyright (c) 1996 Scott K Stevens
@ -51,15 +51,20 @@ extern db_regs_t ddb_regs; /* register state */
#define DDB_REGS (&ddb_regs)
#ifdef __PROG26
#define PC_REGS(regs) ((db_addr_t)(regs)->tf_r15 & R15_PC)
#define PC_REGS(regs) ((regs)->tf_r15 & R15_PC)
#define PC_ADVANCE(regs) ((regs)->tf_r15 += BKPT_SIZE)
#else
#define PC_REGS(regs) ((db_addr_t)(regs)->tf_pc)
#define PC_REGS(regs) ((regs)->tf_pc)
#define PC_ADVANCE(r) ((r)->tf_r15 += BKPT_SIZE)
#endif
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#if defined(DDB)
#define BKPT_INST (KERNEL_BREAKPOINT) /* breakpoint instruction */
#else
/* breakpoint instruction if we use KGDB, this is used in db_set_temp_breakpoint() */
#define BKPT_INST (GDB5_BREAKPOINT)
#endif
#define BKPT_SIZE (INSN_SIZE) /* size of breakpoint inst */
#define BKPT_SET(inst, addr) (BKPT_INST)
@ -88,7 +93,8 @@ extern db_regs_t ddb_regs; /* register state */
/* ldr pc, [pc, reg, lsl #2]
0000000f register */
#define inst_branch(ins) (((ins) & 0x0f000000) == 0x0a000000 || \
((ins) & 0x0fdffff0) == 0x079ff100)
((ins) & 0x0fdffff0) == 0x079ff100 || \
((ins) & 0x0ff0f000) == 0x0590f000)
#define inst_load(ins) (0)
#define inst_store(ins) (0)
#define inst_unconditional_flow_transfer(ins) \