diff options
author | FalseHonesty <thefalsehonesty@gmail.com> | 2021-04-15 12:34:51 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-18 17:02:40 +0200 |
commit | 3123ffb19d55686809a74f4b4899e4f4bd7157e7 (patch) | |
tree | 4b8c108d9dcff1f0e1708526443757447965ff7e /Userland/Libraries/LibC/sys | |
parent | 97a4c627cba98a0fb496621b7b805cfb7d5ffe55 (diff) | |
download | serenity-3123ffb19d55686809a74f4b4899e4f4bd7157e7.zip |
Kernel: Add ptrace commands for reading/writing the debug registers
This adds PT_PEEKDEBUG and PT_POKEDEBUG to allow for reading/writing
the debug registers, and updates the Kernel's debug handler to read the
new information from the debug status register.
Diffstat (limited to 'Userland/Libraries/LibC/sys')
-rw-r--r-- | Userland/Libraries/LibC/sys/ptrace.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibC/sys/ptrace.h | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibC/sys/ptrace.cpp b/Userland/Libraries/LibC/sys/ptrace.cpp index b53bb48465..0fb623f42e 100644 --- a/Userland/Libraries/LibC/sys/ptrace.cpp +++ b/Userland/Libraries/LibC/sys/ptrace.cpp @@ -40,7 +40,8 @@ int ptrace(int request, pid_t tid, void* addr, int data) u32 out_data; Syscall::SC_ptrace_peek_params peek_params; - if (request == PT_PEEK) { + auto is_peek_type = request == PT_PEEK || request == PT_PEEKDEBUG; + if (is_peek_type) { peek_params.address = reinterpret_cast<u32*>(addr); peek_params.out_data = &out_data; addr = &peek_params; @@ -54,7 +55,7 @@ int ptrace(int request, pid_t tid, void* addr, int data) }; int rc = syscall(SC_ptrace, ¶ms); - if (request == PT_PEEK) { + if (is_peek_type) { if (rc < 0) { errno = -rc; return -1; diff --git a/Userland/Libraries/LibC/sys/ptrace.h b/Userland/Libraries/LibC/sys/ptrace.h index edb45aeec9..ad5de3fb6e 100644 --- a/Userland/Libraries/LibC/sys/ptrace.h +++ b/Userland/Libraries/LibC/sys/ptrace.h @@ -39,6 +39,8 @@ __BEGIN_DECLS #define PT_PEEK 7 #define PT_POKE 8 #define PT_SETREGS 9 +#define PT_POKEDEBUG 10 +#define PT_PEEKDEBUG 11 // FIXME: PID/TID ISSUE // Affects the entirety of LibDebug and Userland/strace.cpp. |