9#include <cosmos/BitMask.hxx>
10#include <cosmos/utils.hxx>
13#include <clues/types.hxx>
47 using Flags = cosmos::BitMask<Flag>;
62 const std::string_view short_name = {},
63 const std::string_view long_name = {}) :
65 m_short_name{short_name},
66 m_long_name{long_name}
69 virtual ~SystemCallItem() {}
71 auto type()
const {
return m_type; }
73 bool isIn()
const {
return m_type == ItemType::PARAM_IN; }
74 bool isOut()
const {
return m_type == ItemType::PARAM_OUT; }
75 bool isInOut()
const {
return m_type == ItemType::PARAM_IN_OUT; }
76 bool isReturnValue()
const {
return m_type == ItemType::RETVAL; }
79 void fill(
const Tracee &proc,
const Word word);
90 auto hasLongName()
const {
return !m_long_name.empty(); }
98 virtual std::string str()
const;
102 return value() == Word::ZERO;
116 template <
typename OTHER>
118 const auto baseval = cosmos::to_integral(
m_val);
119 if constexpr (std::is_enum_v<OTHER>) {
120 const auto baseret =
static_cast<typename std::underlying_type<OTHER>::type
>(baseval);
121 return OTHER{baseret};
124 if constexpr (std::is_pointer_v<OTHER>) {
125 return reinterpret_cast<OTHER
>(baseval);
128 if constexpr (!std::is_enum_v<OTHER> && !std::is_pointer_v<OTHER>) {
129 return static_cast<OTHER
>(baseval);
134 return valueAs<ForeignPtr>();
137 Flags flags()
const {
141 bool deferFill()
const {
142 return m_flags[Flag::DEFER_FILL];
198CLUES_API std::ostream& operator<<(
Base class for any kind of system call parameter or return value.
const SystemCall * m_call
The system call context this item part of.
std::string_view m_short_name
A human readable short name for the item, should be one word only.
bool isZero() const
Returns whether the parameter is set to 0 / NULL.
bool needsUpdate() const
Returns whether the item needs to be updated after the system call is finished.
void setSystemCall(const SystemCall &sc)
Sets the system call context this item is a part of.
Word value() const
Returns the currently stored raw value of the item.
virtual void processValue(const Tracee &)
Processes the value stored in m_val acc. to the actual item type.
std::string_view longName() const
Returns the friendly long name for this item, if available, else the short name.
Flags m_flags
Flags influencing the processing of the item.
OTHER valueAs() const
Helper to cast the strongly typed Word m_val to other strong enum types.
Word m_val
The raw register value for the item.
SystemCallItem(const ItemType type, const std::string_view short_name={}, const std::string_view long_name={})
Constructs a new SystemCallItem.
std::string_view m_long_name
A human readable longer name for the item.
virtual void updateData(const Tracee &t)
Called upon exit of the system call to update possible out parameters.
std::string_view shortName() const
Returns the friendly short name for this item.
const ItemType m_type
The type of item.
@ DEFER_FILL
Only fill in this item after all other items have been filled.
Access to System Call Data.
Base class for traced processes.
ItemType
Basic type of a SystemCallItem.
@ PARAM_OUT
An output parameter filled by in by the system call.
@ PARAM_IN
An input parameter to the system call.
@ RETVAL
A system call return value.
@ PARAM_IN_OUT
Both an input and output parameter.
ForeignPtr
Strongly typed opaque pointer to tracee memory.
Word
An integer that is able to hold a word for the current architecture.