[rtems commit] libdebugger: Work around assert when using _Thread_Executing.

Chris Johns chrisj at rtems.org
Sat Apr 15 00:44:27 UTC 2017


Module:    rtems
Branch:    master
Commit:    b53ad4615a16f65119e40f7084f9bacd88dc42cd
Changeset: http://git.rtems.org/rtems/commit/?id=b53ad4615a16f65119e40f7084f9bacd88dc42cd

Author:    Chris Johns <chrisj at rtems.org>
Date:      Fri Apr 14 17:12:44 2017 +1000

libdebugger: Work around assert when using _Thread_Executing.

Using _Thread_Executing with RTEMS_DEBUG results in an `assert` if
the server accesses invalid memory.

Updates #2993.

---

 cpukit/libdebugger/rtems-debugger-arm.c    | 3 ++-
 cpukit/libdebugger/rtems-debugger-target.c | 7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/cpukit/libdebugger/rtems-debugger-arm.c b/cpukit/libdebugger/rtems-debugger-arm.c
index 8126c14..200d758 100644
--- a/cpukit/libdebugger/rtems-debugger-arm.c
+++ b/cpukit/libdebugger/rtems-debugger-arm.c
@@ -717,7 +717,8 @@ target_exception(CPU_Exception_frame* frame)
     "mov  r3, #0\n"                                                     \
     "str  r3, [r2]\n"                 /* clear the FPU frame pointer */ \
     EXCEPTION_ENTRY_FPU(frame_fpu_size)                                 \
-    "msr  cpsr, r1\n"                        /* restore the irq mask */ \
+    "bic  r1, r1, %[psr_i]\n"        /* clear irq mask, debug checks */ \
+    "msr  cpsr, r1\n"       /* restore the state with irq mask clear */ \
     ASM_THUMB_MODE                                                      \
     : ARM_SWITCH_REG_ASM,                                               \
       [o_frame] "=r" (_frame)                                           \
diff --git a/cpukit/libdebugger/rtems-debugger-target.c b/cpukit/libdebugger/rtems-debugger-target.c
index cd15654..65b8784 100644
--- a/cpukit/libdebugger/rtems-debugger-target.c
+++ b/cpukit/libdebugger/rtems-debugger-target.c
@@ -284,7 +284,12 @@ rtems_debugger_target_exception(CPU_Exception_frame* frame)
 
   if (!rtems_interrupt_is_in_progress()) {
     rtems_debugger_threads*              threads = rtems_debugger->threads;
-    Thread_Control*                      thread = _Thread_Executing;
+    #if USE_THREAD_EXECUTING
+     Thread_Control*                     thread = _Thread_Executing;
+    #else
+     const Per_CPU_Control*              cpu = _Per_CPU_Get_snapshot();
+     Thread_Control*                     thread = _Per_CPU_Get_executing(cpu);
+    #endif
     rtems_id*                            excludes;
     const rtems_id                       tid = thread->Object.id;
     DB_UINT                              pc;



More information about the vc mailing list