summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-12-25 11:04:40 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-25 11:05:30 +0100
commit2bd1a62ce1b834492bfdac993b3ff841c729c2fc (patch)
tree14060accfa1c4d324753c26c8e89172a5667a638 /Userland
parente815bf5d1f85fa91679bbd54b7d018a16359e6ca (diff)
downloadserenity-2bd1a62ce1b834492bfdac993b3ff841c729c2fc.zip
LibCore: Add syscall wrapper for ptrace()
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibCore/System.cpp8
-rw-r--r--Userland/Libraries/LibCore/System.h1
2 files changed, 8 insertions, 1 deletions
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 <AK/String.h>
#include <LibCore/System.h>
#include <LibSystem/syscall.h>
-#include <cstring>
#include <fcntl.h>
#include <stdarg.h>
#include <sys/ioctl.h>
@@ -107,6 +106,13 @@ ErrorOr<void> mount(int source_fd, StringView target, StringView fs_type, int fl
HANDLE_SYSCALL_RETURN_VALUE("mount", rc, {});
}
+ErrorOr<long> 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<void> 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<int> recvfd(int sockfd, int options);
ErrorOr<void> ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf);
ErrorOr<void> setgroups(Span<gid_t const>);
ErrorOr<void> mount(int source_fd, StringView target, StringView fs_type, int flags);
+ErrorOr<long> ptrace(int request, pid_t tid, void* address, void* data);
#endif
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action);