Add a BKPT_ADDR() macro which gives MD code a chance to munge a

breakpoint address before it's used. Currently a no-op on all but sh5.

This is useful on sh5, for example, to mask off the instruction
type encoding in the bottom two address bits, and makes it possible
to do "db> break $rXX" instead of manually munging the address.
This commit is contained in:
scw 2003-04-29 17:06:03 +00:00
parent 57af6bd854
commit 8c5c893bf7
15 changed files with 33 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.13 2001/04/19 17:48:47 thorpej Exp $ */
/* $NetBSD: db_machdep.h,v 1.14 2003/04/29 17:06:04 scw Exp $ */
/*
* Copyright (c) 1995 Carnegie-Mellon University.
@ -47,6 +47,7 @@ extern db_regs_t *ddb_regp; /* pointer to current register state */
#define PC_REGS(regs) ((db_addr_t)(regs)->tf_regs[FRAME_PC])
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0x00000080 /* breakpoint instruction */
#define BKPT_SIZE (4) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/* $NetBSD: db_machdep.h,v 1.2 2003/04/29 17:06:04 scw Exp $ */
/*
* Mach Operating System
@ -56,6 +56,7 @@ extern db_regs_t *ddb_regp;
#define PC_REGS(regs) ((db_addr_t)(regs)->tf_rip)
#endif
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0xcc /* breakpoint instruction */
#define BKPT_SIZE (1) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.6 2003/04/28 01:54:50 briggs Exp $ */
/* $NetBSD: db_machdep.h,v 1.7 2003/04/29 17:06:04 scw Exp $ */
/*
* Copyright (c) 1996 Scott K Stevens
@ -57,6 +57,7 @@ db_regs_t ddb_regs; /* register state */
#define PC_REGS(regs) ((db_addr_t)(regs)->tf_pc)
#endif
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST (KERNEL_BREAKPOINT) /* breakpoint instruction */
#define BKPT_SIZE (INSN_SIZE) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.1 2002/06/05 01:04:21 fredette Exp $ */
/* $NetBSD: db_machdep.h,v 1.2 2003/04/29 17:06:05 scw Exp $ */
/* $OpenBSD: db_machdep.h,v 1.5 2001/02/16 19:20:13 mickey Exp $ */
@ -60,6 +60,7 @@ typedef long kgdb_reg_t;
#define PC_REGS(regs) ((db_addr_t)(regs)->tf_iioq_head)
/* Breakpoint related definitions */
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0x00010000 /* break 0,8 */
#define BKPT_SIZE sizeof(int)
#define BKPT_SET(inst) BKPT_INST

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.20 2003/03/30 02:04:09 kristerw Exp $ */
/* $NetBSD: db_machdep.h,v 1.21 2003/04/29 17:06:05 scw Exp $ */
/*
* Mach Operating System
@ -52,6 +52,7 @@ extern db_regs_t *ddb_regp;
#define PC_REGS(regs) ((regs)->tf_eip)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0xcc /* breakpoint instruction */
#define BKPT_SIZE (1) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.23 2003/03/30 02:03:12 kristerw Exp $ */
/* $NetBSD: db_machdep.h,v 1.24 2003/04/29 17:06:05 scw Exp $ */
/*
* Mach Operating System
@ -53,6 +53,7 @@ extern db_regs_t ddb_regs; /* register state */
#define PC_REGS(regs) ((regs)->tf_pc)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0x4e4f /* breakpoint instruction */
#define BKPT_SIZE (2) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.14 2002/03/05 14:12:29 simonb Exp $ */
/* $NetBSD: db_machdep.h,v 1.15 2003/04/29 17:06:05 scw Exp $ */
/*
* Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
@ -63,6 +63,7 @@ extern db_regs_t ddb_regs; /* register state */
(regs)->f_regs[PC] += BKPT_SIZE; \
} while(0)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0x0001000D
#define BKPT_SIZE (4) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.13 2000/08/02 15:24:40 wiz Exp $ */
/* $NetBSD: db_machdep.h,v 1.14 2003/04/29 17:06:06 scw Exp $ */
/*
* Mach Operating System
@ -63,6 +63,7 @@ db_regs_t ddb_regs; /* register state */
#define PC_REGS(regs) ((db_addr_t)(regs)->tf_regs.r_pc)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0xf2 /* breakpoint instruction */
#define BKPT_SIZE (1) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,5 +1,5 @@
/* $OpenBSD: db_machdep.h,v 1.2 1997/03/21 00:48:48 niklas Exp $ */
/* $NetBSD: db_machdep.h,v 1.16 2003/03/14 06:23:48 matt Exp $ */
/* $NetBSD: db_machdep.h,v 1.17 2003/04/29 17:06:06 scw Exp $ */
/*
* Mach Operating System
@ -65,6 +65,7 @@ extern db_regs_t ddb_regs; /* register state */
#define PC_REGS(regs) (*(db_addr_t *)&(regs)->iar)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_ASM "trap" /* should match BKPT_INST */
#define BKPT_INST 0x7fe00008 /* breakpoint instruction */
#define BKPT_SIZE (4) /* size of breakpoint inst */

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.8 2002/05/09 12:24:20 uch Exp $ */
/* $NetBSD: db_machdep.h,v 1.9 2003/04/29 17:06:06 scw Exp $ */
/*
* Mach Operating System
@ -46,6 +46,7 @@ db_regs_t ddb_regs; /* register state */
#define PC_REGS(regs) ((db_addr_t)(regs)->tf_spc)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0xc3c3 /* breakpoint instruction */
#define BKPT_SIZE 2 /* size of breakpoint inst */
#define BKPT_SET(inst) BKPT_INST

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.7 2003/03/19 11:37:57 scw Exp $ */
/* $NetBSD: db_machdep.h,v 1.8 2003/04/29 17:06:06 scw Exp $ */
/*
* This is still very much experimental. There is as yet no DB support
@ -54,6 +54,7 @@ db_regs_t ddb_regs; /* register state */
#define PC_REGS(r) ((db_addr_t)(r)->tf_state.sf_spc & ~1)
#define PC_ADVANCE(r) ((r)->tf_state.sf_spc += BKPT_SIZE)
#define BKPT_ADDR(addr) ((addr) & ~3) /* ditch the instruction type bits */
#define BKPT_INST 0x6ff5fff0 /* breakpoint instruction (BRK) */
#define BKPT_SIZE 4 /* size of breakpoint inst */
#define BKPT_SET(inst) BKPT_INST

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.19 2003/01/07 16:03:03 pk Exp $ */
/* $NetBSD: db_machdep.h,v 1.20 2003/04/29 17:06:06 scw Exp $ */
/*
* Mach Operating System
@ -65,6 +65,7 @@ extern db_regs_t *ddb_regp;
(regs)->db_tf.tf_npc = n + 4; \
} while(0)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0x91d02001 /* breakpoint instruction */
#define BKPT_SIZE (4) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.13 2001/11/09 06:52:25 thorpej Exp $ */
/* $NetBSD: db_machdep.h,v 1.14 2003/04/29 17:06:06 scw Exp $ */
/*
* Mach Operating System
@ -96,6 +96,7 @@ db_regs_t ddb_regs; /* register state */
(regs)->ddb_tf.tf_npc = n + 4; \
} while(0)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0x91d02001 /* breakpoint instruction */
#define BKPT_SIZE (4) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.11 2002/05/13 20:30:12 matt Exp $ */
/* $NetBSD: db_machdep.h,v 1.12 2003/04/29 17:06:07 scw Exp $ */
/*
* Mach Operating System
@ -48,6 +48,7 @@ extern db_regs_t ddb_regs; /* register state */
#define PC_REGS(regs) ((db_addr_t)(regs)->pc)
#define BKPT_ADDR(addr) (addr) /* breakpoint address */
#define BKPT_INST 0x03 /* breakpoint instruction */
#define BKPT_SIZE (1) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_break.c,v 1.17 2002/02/15 07:33:49 simonb Exp $ */
/* $NetBSD: db_break.c,v 1.18 2003/04/29 17:06:03 scw Exp $ */
/*
* Mach Operating System
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_break.c,v 1.17 2002/02/15 07:33:49 simonb Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_break.c,v 1.18 2003/04/29 17:06:03 scw Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -103,7 +103,7 @@ db_set_breakpoint(struct vm_map *map, db_addr_t addr, int count)
}
bkpt->map = map;
bkpt->address = addr;
bkpt->address = BKPT_ADDR(addr);
bkpt->flags = 0;
bkpt->init_count = count;
bkpt->count = count;
@ -122,7 +122,7 @@ db_delete_breakpoint(struct vm_map *map, db_addr_t addr)
(bkpt = *prev) != 0;
prev = &bkpt->link) {
if (db_map_equal(bkpt->map, map) &&
(bkpt->address == addr)) {
(bkpt->address == BKPT_ADDR(addr))) {
*prev = bkpt->link;
break;
}
@ -144,7 +144,7 @@ db_find_breakpoint(struct vm_map *map, db_addr_t addr)
bkpt != 0;
bkpt = bkpt->link)
if (db_map_equal(bkpt->map, map) &&
(bkpt->address == addr))
(bkpt->address == BKPT_ADDR(addr)))
return (bkpt);
return (0);