Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Mar 2021 15:06:19 GMT
From:      Mitchell Horne <mhorne@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 5a2933d0bf9f - main - arm: implement kdb watchpoint functions
Message-ID:  <202103291506.12TF6Juv044341@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=5a2933d0bf9fb0018349b67a39fa85cbb3740779

commit 5a2933d0bf9fb0018349b67a39fa85cbb3740779
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2021-03-04 00:14:42 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2021-03-29 15:05:44 +0000

    arm: implement kdb watchpoint functions
    
    Implement wrappers around the existing debug_monitor interface, to be
    consumed by MI kernel debugger code.
    
    For now, the various db_printf() calls in this code remain. In the
    future, they could be converted to printf() or removed altogether, to
    properly decouple the DDB and GDB options.
    
    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/arm/arm/debug_monitor.c | 37 ++++++++++++++++++++++++++++++++++---
 sys/arm/include/kdb.h       |  2 ++
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/sys/arm/arm/debug_monitor.c b/sys/arm/arm/debug_monitor.c
index ddf3e8e67b25..55b5f70b2397 100644
--- a/sys/arm/arm/debug_monitor.c
+++ b/sys/arm/arm/debug_monitor.c
@@ -326,6 +326,35 @@ kdb_cpu_clear_singlestep(void)
 	}
 }
 
+int
+kdb_cpu_set_watchpoint(vm_offset_t addr, size_t size, int access)
+{
+	enum dbg_access_t dbg_access;
+
+	switch (access) {
+	case KDB_DBG_ACCESS_R:
+		dbg_access = HW_WATCHPOINT_R;
+		break;
+	case KDB_DBG_ACCESS_W:
+		dbg_access = HW_WATCHPOINT_W;
+		break;
+	case KDB_DBG_ACCESS_RW:
+		dbg_access = HW_WATCHPOINT_RW;
+		break;
+	default:
+		return (EINVAL);
+	}
+
+	return (dbg_setup_watchpoint(addr, size, (enum dbg_access_t)access));
+}
+
+int
+kdb_cpu_clr_watchpoint(vm_offset_t addr, size_t size)
+{
+
+	return (dbg_remove_watchpoint(addr, size));
+}
+
 int
 dbg_setup_watchpoint(db_expr_t addr, db_expr_t size, enum dbg_access_t access)
 {
@@ -624,7 +653,7 @@ dbg_setup_xpoint(struct dbg_wb_conf *conf)
 		if (i == ~0U) {
 			db_printf("Can not find slot for %s, max %d slots supported\n",
 			    typestr, dbg_watchpoint_num);
-			return (ENXIO);
+			return (EBUSY);
 		}
 	}
 
@@ -645,7 +674,8 @@ dbg_setup_xpoint(struct dbg_wb_conf *conf)
 		cr_size = DBG_WB_CTRL_LEN_8;
 		break;
 	default:
-		db_printf("Unsupported address size for %s\n", typestr);
+		db_printf("Unsupported address size for %s: %zu\n", typestr,
+		    conf->size);
 		return (EINVAL);
 	}
 
@@ -667,7 +697,8 @@ dbg_setup_xpoint(struct dbg_wb_conf *conf)
 			cr_access = DBG_WB_CTRL_LOAD | DBG_WB_CTRL_STORE;
 			break;
 		default:
-			db_printf("Unsupported exception level for %s\n", typestr);
+			db_printf("Unsupported access type for %s: %d\n",
+			    typestr, conf->access);
 			return (EINVAL);
 		}
 
diff --git a/sys/arm/include/kdb.h b/sys/arm/include/kdb.h
index 42677499ed78..728bf211dc62 100644
--- a/sys/arm/include/kdb.h
+++ b/sys/arm/include/kdb.h
@@ -41,6 +41,8 @@
 extern void kdb_cpu_clear_singlestep(void);
 extern void kdb_cpu_set_singlestep(void);
 boolean_t kdb_cpu_pc_is_singlestep(db_addr_t);
+int kdb_cpu_set_watchpoint(vm_offset_t addr, size_t size, int access);
+int kdb_cpu_clr_watchpoint(vm_offset_t addr, size_t size);
 
 static __inline void
 kdb_cpu_sync_icache(unsigned char *addr, size_t size)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103291506.12TF6Juv044341>