[PATCH v1 2/5] cpukit/libdebugger: Add pure swbreak capability

Kinsey Moore kinsey.moore at oarcorp.com
Tue Feb 15 20:38:45 UTC 2022


Add a capability that allows for implementations that operate purely
using software breaks. Due to this implementation method, software
breaks must not be restored until just before returning control to the
thread itself and will be handled by the implementation through thread
switch and interrupt hooks.
---
 cpukit/libdebugger/rtems-debugger-target.h  | 14 +++++++++++---
 cpukit/libdebugger/rtems-debugger-threads.c |  4 +++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/cpukit/libdebugger/rtems-debugger-target.h b/cpukit/libdebugger/rtems-debugger-target.h
index 1e132fb28c..7836f93bd6 100644
--- a/cpukit/libdebugger/rtems-debugger-target.h
+++ b/cpukit/libdebugger/rtems-debugger-target.h
@@ -49,9 +49,17 @@ extern "C" {
 /**
  * Target capabilities mask.
  */
-#define RTEMS_DEBUGGER_TARGET_CAP_SWBREAK   (1 << 0)
-#define RTEMS_DEBUGGER_TARGET_CAP_HWBREAK   (1 << 1)
-#define RTEMS_DEBUGGER_TARGET_CAP_HWWATCH   (1 << 2)
+#define RTEMS_DEBUGGER_TARGET_CAP_SWBREAK      (1 << 0)
+#define RTEMS_DEBUGGER_TARGET_CAP_HWBREAK      (1 << 1)
+#define RTEMS_DEBUGGER_TARGET_CAP_HWWATCH      (1 << 2)
+/*
+ * This target capability indicates that the target implementation uses a pure
+ * software break implementation which must not allow breakpoints to be
+ * inserted before the actual switch to the thread, be it in interrupt context
+ * or otherwise. Such implementations must necessarily implement a thread
+ * switch hook and interrupt hooks to handle these situations.
+ */
+#define RTEMS_DEBUGGER_TARGET_CAP_PURE_SWBREAK (1 << 3)
 
 /**
  * Types of hardware breakpoints.
diff --git a/cpukit/libdebugger/rtems-debugger-threads.c b/cpukit/libdebugger/rtems-debugger-threads.c
index c628c0250e..841199bfe3 100644
--- a/cpukit/libdebugger/rtems-debugger-threads.c
+++ b/cpukit/libdebugger/rtems-debugger-threads.c
@@ -355,9 +355,11 @@ rtems_debugger_thread_system_resume(bool detaching)
   current = rtems_debugger_thread_current(threads);
   if (current != NULL) {
     size_t i;
+    rtems_debugger_target* target = rtems_debugger->target;
     if (rtems_debugger_verbose())
       rtems_debugger_printf("rtems-db: sys:    : resuming\n");
-    if (!detaching) {
+    if (!detaching
+      && (target->capabilities & RTEMS_DEBUGGER_TARGET_CAP_PURE_SWBREAK) == 0) {
       r = rtems_debugger_target_swbreak_insert();
       if (r == 0)
         r = rtems_debugger_target_hwbreak_insert();
-- 
2.30.2



More information about the devel mailing list