diff options
author | Matt Hunter <m@lfurio.us> | 2025-08-13 01:04:57 -0400 |
---|---|---|
committer | Matt Hunter <m@lfurio.us> | 2025-09-07 06:41:16 -0400 |
commit | 4ea8ea650a1d81cf6362e1485d2fdce2617d8d8e (patch) | |
tree | 65cddd4d36a4264141f6c8dca1a8a9e91076cc17 /arch/arm-singlestep.h | |
parent | f9c7b14383a99ecc0a1e8266467804647acfaa3e (diff) | |
download | misplays-4ea8ea650a1d81cf6362e1485d2fdce2617d8d8e.tar.gz misplays-4ea8ea650a1d81cf6362e1485d2fdce2617d8d8e.zip |
Add architecture-specific single step support
ARM 32-bit is the first platform added to misplays which lacks
underlying hardware support for single step traps - so the kernel does
not implement PTRACE_SINGLESTEP in this case.
We will work around this in a similar way as gdb does and how the kernel
used to do it until 2011. arm_singlestep() implements logic which
disassembles the program's current instruction and analyzes it to
determine all possible next locations - eg: the next instruction in
memory, or the jump target of a branch instruction, etc. This logic is
dynamically dispatched by the debugger core if an ARM build is running
in 32-bit mode.
arm_singlestep() uses breakpoints to stop execution at it's computed
next locations. However, misplays is currently very careful about
controling the use of breakpoints in order to avoid issues with thread
single steps - so a new flag (called "step") is added to breakpoints to
enable the debugger to selectively install this subset of breakpoints
for each thread's single step action, and more or less keep treating
thread free-run as normal. install_breakpoints() is updated to take a
"step" parameter to control which set of breakpoints is installed at any
given time.
resume_threads() is updated to perform this new single step dynamic
dispatch, and manage the installation of step breakpoints.
add_breakpoint() is also given a "step" parameter. This initializes the
flag for the new breakpoint, but crucially is used to sort the new
breakpoint into the process breakpoint list. Since step breakpoints
will always be installed first, prioritize them in the list so that
uninstall_breakpoints() doesn't corrupt memory when it runs the list
backward to remove them.
Signed-off-by: Matt Hunter <m@lfurio.us>
Diffstat (limited to 'arch/arm-singlestep.h')
-rw-r--r-- | arch/arm-singlestep.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/arm-singlestep.h b/arch/arm-singlestep.h new file mode 100644 index 0000000..263b188 --- /dev/null +++ b/arch/arm-singlestep.h @@ -0,0 +1,5 @@ +#pragma once + +#include "debugger.h" + +extern int arm_singlestep(struct thread *th); |