diff --git a/cpukit/libdebugger/rtems-debugger-target.c b/cpukit/libdebugger/rtems-debugger-target.c index 992295ff6d..edf7e99835 100644 --- a/cpukit/libdebugger/rtems-debugger-target.c +++ b/cpukit/libdebugger/rtems-debugger-target.c @@ -601,14 +601,6 @@ rtems_debugger_target_exception_thread_resume(rtems_debugger_thread* thread) } } -int -rtems_debugger_target_start_memory_access(void) -{ - rtems_debugger_target* target = rtems_debugger->target; - target->memory_access = true; - return setjmp(target->access_return); -} - void rtems_debugger_target_end_memory_access(void) { diff --git a/cpukit/libdebugger/rtems-debugger-target.h b/cpukit/libdebugger/rtems-debugger-target.h index 55289fb1eb..40ea7e04d9 100644 --- a/cpukit/libdebugger/rtems-debugger-target.h +++ b/cpukit/libdebugger/rtems-debugger-target.h @@ -284,8 +284,20 @@ extern int rtems_debugger_target_cache_sync(rtems_debugger_target_swbreak* swbre /** * Start a target memory access. If 0 is return the access can proceed and if * -1 is return the access has failed. + * + * The call to setjmp() must not reside inside a stack frame relative to the + * expected location of the possible failure. If the debugger is already + * executing in exception context and setjmp is called with its own stack frame, + * that stack frame will be released before the failure. The failure causes an + * exception which will continue using the same stack and is highly likely to + * overwrite stack information which is critical for the debugger to continue + * execution. */ -extern int rtems_debugger_target_start_memory_access(void); +#define rtems_debugger_target_start_memory_access() \ + ({ \ + rtems_debugger->target->memory_access = true, \ + setjmp(rtems_debugger->target->access_return); \ + }) /** * End a target memory access.