Introduce kdb-level watchpoint functions

This basically mirrors what already exists in ddb, but provides a
slightly improved interface. It allows the caller to specify the
watchpoint access type, and returns more specific error codes to
differentiate failure cases.

This will be used to support hardware watchpoints in gdb(4).

Stubs are provided for architectures lacking hardware watchpoint logic
(mips, powerpc, riscv), while other architectures are added individually
in follow-up commits.

Reviewed by:	jhb, kib, markj
MFC after:	3 weeks
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D29155
This commit is contained in:
Mitchell Horne 2021-03-08 11:23:40 -04:00
parent 21d0c01226
commit 763107f26c
4 changed files with 49 additions and 0 deletions

View File

@ -55,4 +55,19 @@ static __inline void
kdb_cpu_sync_icache(unsigned char *addr, size_t size)
{
}
static __inline int
kdb_cpu_set_watchpoint(vm_offset_t addr, vm_size_t size, int access)
{
return (ENXIO);
}
static __inline int
kdb_cpu_clr_watchpoint(vm_offset_t addr, vm_size_t size)
{
return (0);
}
#endif /* _MACHINE_KDB_H_ */

View File

@ -54,4 +54,18 @@ kdb_cpu_trap(int vector, int _)
{
}
static __inline int
kdb_cpu_set_watchpoint(vm_offset_t addr, vm_size_t size, int access)
{
return (ENXIO);
}
static __inline int
kdb_cpu_clr_watchpoint(vm_offset_t addr, vm_size_t size)
{
return (0);
}
#endif /* _MACHINE_KDB_H_ */

View File

@ -59,4 +59,18 @@ kdb_cpu_trap(int type, int code)
{
}
static __inline int
kdb_cpu_set_watchpoint(vm_offset_t addr, vm_size_t size, int access)
{
return (ENXIO);
}
static __inline int
kdb_cpu_clr_watchpoint(vm_offset_t addr, vm_size_t size)
{
return (0);
}
#endif /* _MACHINE_KDB_H_ */

View File

@ -127,4 +127,10 @@ extern const char * volatile kdb_why;
#define KDB_REQ_PANIC 2 /* User requested a panic */
#define KDB_REQ_REBOOT 3 /* User requested a clean reboot */
/* Debug breakpoint/watchpoint access types */
#define KDB_DBG_ACCESS_EXEC 0
#define KDB_DBG_ACCESS_R 1
#define KDB_DBG_ACCESS_W 2
#define KDB_DBG_ACCESS_RW 3
#endif /* !_SYS_KDB_H_ */