11#include <cosmos/error/RuntimeError.hxx>
12#include <cosmos/proc/ptrace.hxx>
15#include <clues/ErrnoResult.hxx>
16#include <clues/items/error.hxx>
17#include <clues/sysnrs/fwd.hxx>
18#include <clues/types.hxx>
19#include <clues/utils.hxx>
32using SystemCallPtr = std::shared_ptr<SystemCall>;
48 friend std::ostream& ::operator<<(std::ostream&,
const SystemCall&);
95 SystemCallItemPtr
result()
const {
return hasResultValue() ?
m_return :
nullptr; }
99 bool hasOutParameter()
const;
101 bool hasResultValue()
const {
102 return m_error == std::nullopt;
105 bool hasErrorCode()
const {
106 return !hasResultValue();
114 bool is32BitEmulationABI()
const {
122 static const char* name(
const SystemCallNr nr);
125 static bool validNr(
const SystemCallNr nr);
154 if (!ret.isReturnValue()) {
155 throw cosmos::RuntimeError{
"added non-return-value as return item"};
159 void addParameters() {}
161 template <
typename T,
typename... Targs>
162 void addParameters(T &par, Targs& ...rest) {
163 par.setSystemCall(*
this);
164 m_pars.push_back(&par);
165 addParameters(rest...);
168 template <
typename... Targs>
169 void setParameters(Targs& ...args) {
171 addParameters(args...);
209 void dropFD(
const Tracee &proc,
const cosmos::FileNum num);
Extended ptrace system call state information.
Base class for any kind of system call parameter or return value.
Access to System Call Data.
SystemCallItemPtr m_return
The return value of the system call.
std::string_view name() const
Returns the system call's human readable name.
void setReturnItem(SystemCallItem &ret)
Sets the return value system call item.
const SystemCallInfo * m_info
Current system call info during entry/exit processing, nullptr otherwise.
ABI abi() const
Returns the system call ABi seen during system call entry.
const ParameterVector & parameters() const
Access to the parameters associated with this system call.
size_t numPars() const
Returns the number of parameters for this system call.
virtual void prepareNewSystemCall()
Perform any necessary actions before processing a new system call entry event.
const std::string_view m_name
The basic name of the system call.
const SystemCallInfo * currentInfo() const
Access the current SystemCallInfo if currently processing syscall entry/exit.
SystemCallItemPtr result() const
Access to the return value parameter associated with this system call.
std::optional< ErrnoResult > error() const
Access to the errno result seen for this system call.
SystemCall(const SystemCallNr nr)
Instantiates a new SystemCall object with given properties.
SystemCallNr callNr() const
Returns the system call table number for this system call.
std::optional< ErrnoResult > m_error
If the system call fails, this is the error code.
std::vector< SystemCallItemPtr > ParameterVector
Vector of the parameters required for a system call.
ABI m_abi
The current system call ABI which is in effect.
ParameterVector m_pars
The array of system call parameters, if any.
SystemCallNr m_nr
The raw system call number of the system call.
virtual void updateFDTracking(const Tracee &proc)
Update file descriptor tracking.
virtual bool check2ndPass(const Tracee &)
Check whether a second pass needs to be made processing parameters.
Base class for traced processes.
SystemCallPtr create_syscall(const SystemCallNr nr)
Creates a dynamically allocated SystemCall instance for the given system call number.
constexpr ABI get_default_abi()
Returns the default ABI for this system.
SystemCallNr
Abstract system call number usable across architectures and ABIs.
Contextual information about a file descriptor in a Tracee.