From 4ea8ea650a1d81cf6362e1485d2fdce2617d8d8e Mon Sep 17 00:00:00 2001 From: Matt Hunter Date: Wed, 13 Aug 2025 01:04:57 -0400 Subject: 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 --- misplays.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'misplays.c') diff --git a/misplays.c b/misplays.c index 6c9a189..20da6bb 100644 --- a/misplays.c +++ b/misplays.c @@ -402,7 +402,7 @@ int main(int argc, char **argv) { t++; } unsigned long address = strtoul(t, NULL, 0); - struct breakpoint *b = add_breakpoint(th->proc, address); + struct breakpoint *b = add_breakpoint(th->proc, address, 0); b->enabled = en; b->tid = tid; break; -- cgit v1.2.3