AsmGrader 0.0.0
Loading...
Searching...
No Matches
syscall_record.hpp
Go to the documentation of this file.
1#pragma once
2
10#include <fmt/base.h>
11
12#include <ctime>
13#include <optional>
14#include <string>
15#include <variant>
16#include <vector>
17
18namespace asmgrader {
19
22{
25 using SyscallArg = std::variant<i32, i64, u32, u64, Result<std::string>, Result<std::vector<Result<std::string>>>,
27
28 u64 num;
29 std::vector<SyscallArg> args;
30 std::optional<Expected<i64>> ret;
31
34};
35
36#include <asmgrader/common/timespec_operator_eq.hpp> // IWYU pragma: keep; To permit default comparison of `SyscallRecord::SyscallArg`
37
38} // namespace asmgrader
39
40template <>
42{
43
44 auto format(const ::asmgrader::SyscallRecord& from, format_context& ctx) const {
45 if (is_debug_format) {
46 return format_to(ctx.out(),
47 "SyscallRecord{{.num = {} [SYS_{}], .args = {}, .ret = {}, .ip = 0x{:X}, .sp = 0x{:X}}}",
48 from.num, ::asmgrader::SYSCALL_MAP.at(from.num).name(), from.args, from.ret,
49 from.instruction_pointer, from.stack_pointer);
50 }
51 UNIMPLEMENTED("Use debug format spec `{:?}` for SyscallRecord");
52 }
53};
std::variant wrapper for a partial implementation of C++23's expected type
Definition expected.hpp:34
#define UNIMPLEMENTED(msg,...)
For features that have not yet / are not planned to be implemented, so that I don't bang my head agai...
Definition logging.hpp:52
Definition asm_buffer.hpp:19
Definition debug.hpp:9
Record of a syscall for use with Tracer to keep track of which syscalls a child process invokes.
Definition syscall_record.hpp:22
std::optional< Expected< i64 > > ret
Definition syscall_record.hpp:30
u64 num
Definition syscall_record.hpp:28
std::variant< i32, i64, u32, u64, Result< std::string >, Result< std::vector< Result< std::string > > >, void *, Result< std::timespec > > SyscallArg
An arbitrary syscall argument void* is a catch-all for any pointer type.
Definition syscall_record.hpp:25
u64 stack_pointer
Definition syscall_record.hpp:33
std::vector< SyscallArg > args
Definition syscall_record.hpp:29
u64 instruction_pointer
Definition syscall_record.hpp:32
auto format(const ::asmgrader::SyscallRecord &from, format_context &ctx) const
Definition syscall_record.hpp:44