Commit Graph

12 Commits

Author SHA1 Message Date
Kinsey Moore
3d8b56f10c cpukit/libdebugger: Prevent hang on memory access
When memory is accessed by the remote debugging client, the access is
sandboxed with setjmp/longjmp and appropriate exception handlers to
prevent the attempted access from causing a failure of the debugger or
otherwise altering execution. The existing implementation works as
expected when the context executing the memory access and the exception
context resulting from a failed access do not share a stack.

In the case of AArch64, a failed access when the debugger is already in
exception context causes a re-entry into exception context where the
machine state is pushed onto the same stack that was in use where the
exception occurred. When setjmp is called inside a stack frame and the
exception occurs outside that stack frame, the stack frame is unwound
before the exception occurs and the exception entry overwrites the area
previously occupied by the stack frame housing the setjmp and corrupting
the link register that is stored there. After restoration of state using
longjmp(), this corrupted link register information is loaded from the
stack frame and undesired behavior occurs.

In the instance of this bug that was encountered, the corrupted link
register contained an unaligned pointer which caused an unending cascade
of prefetch abort exceptions presenting as a hard hang.

Closes #5273
2025-06-18 13:53:35 -05:00
Chris Johns
53a62631ac libdebugger/target: Add support for backend code writters
The call lets backends support special methods of writing code.

Updates #5098
2024-08-07 05:09:38 +00:00
Chris Johns
6a367f4689 libdebugger/target: Move global stepping variables in to the target data
Updates #5098
2024-08-07 05:09:38 +00:00
Kinsey Moore
16d40ce7ff cpukit/libdebugger: Avoid cascade for interrupts
This updates behavior of libdebugger to handle debug exceptions in
interrupt context by temporarily removing a software breakpoint,
stepping, and then resuming afterward.
2022-02-23 08:35:45 -06:00
Kinsey Moore
924993a4bc cpukit/libdebugger: Avoid missed swbreak removal
It is possible to remove software breaks without actually restoring the
original instruction to memory. When this happens, the original
instruction is lost. This ensures that the original instruction is
restored when a software break is removed.
2022-02-23 08:35:45 -06:00
Kinsey Moore
102261043a cpukit/libdebugger: Use uintptr_t for pointers
Use uintptr_t instead of DB_UINT when the variable in question describes
a pointer.
2021-11-01 08:38:59 -05:00
Stephen Clark
9b088157ed rtems-debugger: Fixed pointer types to work on 32 and 64 bit architectures
Using 32bit types like uint32_t for pointers creates issues on 64 bit
architectures like AArch64. Replaced occurrences of these with
uintptr_t, which will work for both 32 and 64 bit architectures. Added
hex_decode_addr function to rtems-debugger.
2021-10-27 13:25:30 -05:00
Ryan Long
3f4cdd8589 rtems-debugger-target.c: Fix Dereference before null check (CID #1468682)
CID 1468682: swbreaks is assigned a value dereferenced from target before
it has been verified that target is not null.

Closes #4240.
2021-02-12 17:13:16 -06:00
Chris Johns
2c09b71faf libdebugger: Use an offset table to format GDB g packets.
Adding support for a register offset table lets FPU registers
be supported if added to the backend.

Closes #3733.
2019-04-09 15:02:24 +10:00
Chris Johns
b2353ed924 libdebugger: Fixes to debugging, ARM support, locking, and gcc-7.1 warnings.
- Add `printk` support to aid multi-core debugging.
- Add lock trace to aid lock debugging.
- Fixes to gcc-7.1 warnings.
- Fixes from ticket #2879.
- Add verbose command controls.
- Change using the RTEMS sys/lock.h API to manage exception threads.
- ARM hardware breakpoint fixes. Support for SMP stepping
  is not implemented, this requires use of the context id
  register.

Closes #2879.
2017-08-15 11:39:22 +10:00
Chris Johns
b53ad4615a 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.
2017-04-15 08:18:25 +10:00
Chris Johns
a0d4e9933c cpukit: Add libdebugger, a remote debugger agent for GDB. 2016-11-29 08:50:40 +11:00