From 763107f26c3c3f4c8bb314a7cabc0a5548abff03 Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Mon, 8 Mar 2021 11:23:40 -0400 Subject: [PATCH] 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 --- sys/mips/include/kdb.h | 15 +++++++++++++++ sys/powerpc/include/kdb.h | 14 ++++++++++++++ sys/riscv/include/kdb.h | 14 ++++++++++++++ sys/sys/kdb.h | 6 ++++++ 4 files changed, 49 insertions(+) diff --git a/sys/mips/include/kdb.h b/sys/mips/include/kdb.h index 33e54bc5fc05..64e39e154f21 100644 --- a/sys/mips/include/kdb.h +++ b/sys/mips/include/kdb.h @@ -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_ */ diff --git a/sys/powerpc/include/kdb.h b/sys/powerpc/include/kdb.h index 74f3e390b423..78e4966eaaf0 100644 --- a/sys/powerpc/include/kdb.h +++ b/sys/powerpc/include/kdb.h @@ -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_ */ diff --git a/sys/riscv/include/kdb.h b/sys/riscv/include/kdb.h index 312cac502824..0fdff26bb432 100644 --- a/sys/riscv/include/kdb.h +++ b/sys/riscv/include/kdb.h @@ -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_ */ diff --git a/sys/sys/kdb.h b/sys/sys/kdb.h index 72eb51d57aee..746abb0ee4f4 100644 --- a/sys/sys/kdb.h +++ b/sys/sys/kdb.h @@ -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_ */