summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Process.cpp8
-rw-r--r--Kernel/Process.h2
-rw-r--r--Kernel/Syscalls/ptrace.cpp4
-rw-r--r--Kernel/ThreadTracer.h4
4 files changed, 12 insertions, 6 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 0805480217..413e25e89e 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -660,9 +660,13 @@ void Process::set_tty(TTY* tty)
m_tty = tty;
}
-void Process::start_tracing_from(ProcessID tracer)
+KResult Process::start_tracing_from(ProcessID tracer)
{
- m_tracer = ThreadTracer::create(tracer);
+ auto thread_tracer = ThreadTracer::create(tracer);
+ if (!thread_tracer)
+ return ENOMEM;
+ m_tracer = move(thread_tracer);
+ return KSuccess;
}
void Process::stop_tracing()
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 59ffec5e84..94cbdccf27 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -241,7 +241,7 @@ public:
ThreadTracer* tracer() { return m_tracer.ptr(); }
bool is_traced() const { return !!m_tracer; }
- void start_tracing_from(ProcessID tracer);
+ KResult start_tracing_from(ProcessID tracer);
void stop_tracing();
void tracer_trap(Thread&, const RegisterState&);
diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp
index f380921834..1b9695f410 100644
--- a/Kernel/Syscalls/ptrace.cpp
+++ b/Kernel/Syscalls/ptrace.cpp
@@ -51,7 +51,9 @@ static KResultOr<u32> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& par
if (peer_process.tracer()) {
return EBUSY;
}
- peer_process.start_tracing_from(caller.pid());
+ auto result = peer_process.start_tracing_from(caller.pid());
+ if (result.is_error())
+ return result.error();
ScopedSpinLock lock(peer->get_lock());
if (peer->state() != Thread::State::Stopped) {
peer->send_signal(SIGSTOP, &caller);
diff --git a/Kernel/ThreadTracer.h b/Kernel/ThreadTracer.h
index ef2913edef..dad9a5f84c 100644
--- a/Kernel/ThreadTracer.h
+++ b/Kernel/ThreadTracer.h
@@ -6,8 +6,8 @@
#pragma once
-#include <AK/NonnullOwnPtr.h>
#include <AK/Optional.h>
+#include <AK/OwnPtr.h>
#include <Kernel/UnixTypes.h>
#include <LibC/sys/arch/i386/regs.h>
@@ -15,7 +15,7 @@ namespace Kernel {
class ThreadTracer {
public:
- static NonnullOwnPtr<ThreadTracer> create(ProcessID tracer) { return make<ThreadTracer>(tracer); }
+ static OwnPtr<ThreadTracer> create(ProcessID tracer) { return adopt_own_if_nonnull(new ThreadTracer(tracer)); }
ProcessID tracer_pid() const { return m_tracer_pid; }
bool has_pending_signal(u32 signal) const { return m_pending_signals & (1 << (signal - 1)); }