AsmGrader 0.0.0
Loading...
Searching...
No Matches
traced_subprocess.hpp
Go to the documentation of this file.
1#pragma once
2
8
9#include <chrono>
10#include <functional>
11#include <optional>
12
13namespace asmgrader {
14
17{
18public:
20
21 ~TracedSubprocess() override;
22
23 Tracer& get_tracer() { return tracer_; }
24
25 const Tracer& get_tracer() const { return tracer_; }
26
29
31 Result<RunResult> run_until(const std::function<bool(SyscallRecord)>& pred);
32
34 Result<int> wait_for_exit(std::chrono::microseconds timeout) override;
35
36 std::optional<int> get_exit_code() const { return tracer_.get_exit_code(); }
37
38private:
39 Result<void> init_child() final;
40 Result<void> init_parent() final;
41
42 Tracer tracer_;
43};
44
45} // namespace asmgrader
std::variant wrapper for a partial implementation of C++23's expected type
Definition expected.hpp:34
Definition subprocess.hpp:21
int wait_for_exit()
Definition subprocess.cpp:57
A subprocess managed by a tracer.
Definition traced_subprocess.hpp:17
Result< RunResult > run()
Definition traced_subprocess.cpp:53
const Tracer & get_tracer() const
Definition traced_subprocess.hpp:25
Result< RunResult > run_until(const std::function< bool(SyscallRecord)> &pred)
Definition traced_subprocess.cpp:57
~TracedSubprocess() override
Definition traced_subprocess.cpp:17
std::optional< int > get_exit_code() const
Definition traced_subprocess.hpp:36
Tracer & get_tracer()
Definition traced_subprocess.hpp:23
A lightweight wrapper of ptrace(2)
Definition tracer.hpp:49
std::optional< int > get_exit_code() const
Obtain the process exit code, or nullopt if the process has not yet exited.
Definition tracer.hpp:91
Definition asm_buffer.hpp:20
Record of a syscall for use with Tracer to keep track of which syscalls a child process invokes.
Definition syscall_record.hpp:22