While troubleshooting why gdb wasn't working when attempting to debug
serenity programs I noticed two things:
- The contract of serenity's `waitpid(..)` appears to be slightly
different than the generic ptrace target expects. We need to make
sure we pass `WSTOPPED`, and it can return different errno values
that we would want to re-try on.
- The contract of serenity's `ptrace(..)` implementation appears to
diverge as well, as we are expected to call `PT_ATTACH` before we
call `PT_CONTINUE`, otherwise `ptrace(..)` will just error out.
These two patches fix the behavior of wait and mourn_inferior so that
they work as expected on serenity and allow us to attach and then wait
for a process to exit while running under gdb.
This patch adds a ptrace based gdb backend, which is then enlightended
to known how to read the serenity i386 registers via ptrace.
This is just a basic implementation to get the port bootstrapped.
Stack regions can't be made volatile, which makes it impossible for
malloc to manage memory that's used for `sigaltstack()`. Let's use mmap
instead.
Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>