From 2bd1a62ce1b834492bfdac993b3ff841c729c2fc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 25 Dec 2021 11:04:40 +0100 Subject: [PATCH] LibCore: Add syscall wrapper for ptrace() --- Userland/Libraries/LibCore/System.cpp | 8 +++++++- Userland/Libraries/LibCore/System.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 197995e034..5cbae05735 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -107,6 +106,13 @@ ErrorOr mount(int source_fd, StringView target, StringView fs_type, int fl HANDLE_SYSCALL_RETURN_VALUE("mount", rc, {}); } +ErrorOr ptrace(int request, pid_t tid, void* address, void* data) +{ + auto rc = ::ptrace(request, tid, address, data); + if (rc < 0) + return Error::from_syscall("ptrace"sv, -errno); + return rc; +} #endif ErrorOr sigaction(int signal, struct sigaction const* action, struct sigaction* old_action) diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index 8adef7d2f8..92609212b8 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -29,6 +29,7 @@ ErrorOr recvfd(int sockfd, int options); ErrorOr ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf); ErrorOr setgroups(Span); ErrorOr mount(int source_fd, StringView target, StringView fs_type, int flags); +ErrorOr ptrace(int request, pid_t tid, void* address, void* data); #endif ErrorOr sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);