Hello,
My purpose is to understand how macOS works.
Here is what i've done: I have wrote a c program on a M1 CPU with this lines:
printf("Before breakpoint\n");
asm volatile("brk #0");
printf("After breakpoint\n");
When i run this program with lldb, a breakpoint is hit on the second line. So i suppose lldb is writing a "brk #0" instruction when we put a breakpoint manually.
I can't continue to next line with lldb "c" command. PC stays on the brk instruction. I need to manually set PC to next instruction in lldb.
Now, what i want to do is to create my own debugger. (I want to understand how lldb works).
I have managed to ptrace the target program and i was able to catch an event with waitpid when "brk #0" is hit. But i don't know how i can increase PC value and continue execution because i can't do this on Silicon CPU:
ptrace(PTRACE_GETREGS, child_pid, NULL, &regs);
ptrace(PTRACE_SETREGS, child_pid, NULL, &regs);
kill(child_pid, SIGCONT);
So my question is: How does lldb managed to change ARM64 registers of a remote process ?
Thanks