libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
clues::item::FileDescOwner Class Reference

The value used with the F_GETOWN and F_SETOWN fcntl() operations. More...

#include <fcntl.hxx>

+ Inheritance diagram for clues::item::FileDescOwner:

Public Member Functions

 FileDescOwner (const ItemType type)
 
std::string str () const override
 Returns a human readable string representation of the item.
 
std::optional< cosmos::ProcessID > pid () const
 
std::optional< cosmos::ProcessGroupID > pgid () const
 
bool isPid () const
 
bool isPgid () const
 
- Public Member Functions inherited from clues::SystemCallItem
 SystemCallItem (const ItemType type, const std::string_view short_name={}, const std::string_view long_name={})
 Constructs a new SystemCallItem.
 
auto type () const
 
bool isIn () const
 
bool isOut () const
 
bool isInOut () const
 
bool isReturnValue () const
 
void fill (const Tracee &proc, const Word word)
 Fills the item from the given register data.
 
bool needsUpdate () const
 Returns whether the item needs to be updated after the system call is finished.
 
std::string_view shortName () const
 Returns the friendly short name for this item.
 
std::string_view longName () const
 Returns the friendly long name for this item, if available, else the short name.
 
auto hasLongName () const
 
bool isZero () const
 Returns whether the parameter is set to 0 / NULL.
 
Word value () const
 Returns the currently stored raw value of the item.
 
template<typename OTHER>
OTHER valueAs () const
 Helper to cast the strongly typed Word m_val to other strong enum types.
 
ForeignPtr asPtr () const
 
Flags flags () const
 
bool deferFill () const
 

Protected Member Functions

void processValue (const Tracee &proc) override
 Processes the value stored in m_val acc. to the actual item type.
 
- Protected Member Functions inherited from clues::SystemCallItem
virtual void updateData (const Tracee &t)
 Called upon exit of the system call to update possible out parameters.
 
void setSystemCall (const SystemCall &sc)
 Sets the system call context this item is a part of.
 

Protected Attributes

std::optional< cosmos::ProcessID > m_pid
 
std::optional< cosmos::ProcessGroupID > m_pgid
 
- Protected Attributes inherited from clues::SystemCallItem
const SystemCallm_call = nullptr
 The system call context this item part of.
 
const ItemType m_type
 The type of item.
 
std::string_view m_short_name
 A human readable short name for the item, should be one word only.
 
std::string_view m_long_name
 A human readable longer name for the item.
 
Word m_val
 The raw register value for the item.
 
Flags m_flags
 Flags influencing the processing of the item.
 

Additional Inherited Members

- Public Types inherited from clues::SystemCallItem
enum class  Flag { DEFER_FILL = 1 << 0 }
 
using Flags = cosmos::BitMask<Flag>
 

Detailed Description

The value used with the F_GETOWN and F_SETOWN fcntl() operations.

This can either be a PID (positive value) or a PGID (negative value). Accordingly the type contains either a cosmos::ProcessID or cosmos::ProcessGroupID.

Definition at line 153 of file fcntl.hxx.

Constructor & Destructor Documentation

◆ FileDescOwner()

clues::item::FileDescOwner::FileDescOwner ( const ItemType type)
inlineexplicit

Definition at line 157 of file fcntl.hxx.

157 :
158 SystemCallItem{type} {
159 }
SystemCallItem(const ItemType type, const std::string_view short_name={}, const std::string_view long_name={})
Constructs a new SystemCallItem.

Member Function Documentation

◆ isPgid()

bool clues::item::FileDescOwner::isPgid ( ) const
inline

Definition at line 175 of file fcntl.hxx.

175 {
176 return m_pgid.has_value();
177 }

◆ isPid()

bool clues::item::FileDescOwner::isPid ( ) const
inline

Definition at line 171 of file fcntl.hxx.

171 {
172 return m_pid.has_value();
173 }

◆ pgid()

std::optional< cosmos::ProcessGroupID > clues::item::FileDescOwner::pgid ( ) const
inline

Definition at line 167 of file fcntl.hxx.

167 {
168 return m_pgid;
169 }

◆ pid()

std::optional< cosmos::ProcessID > clues::item::FileDescOwner::pid ( ) const
inline

Definition at line 163 of file fcntl.hxx.

163 {
164 return m_pid;
165 }

◆ processValue()

void clues::item::FileDescOwner::processValue ( const Tracee & )
overrideprotectedvirtual

Processes the value stored in m_val acc. to the actual item type.

This function is called for all parameter types upon entry to a system call, and for ItemType::RETVAL upon exit from a system call.

For parameters of ItemType::PARAM_OUT this callback can be used to reset any stored data to be filled in later when updateData() is called.

Reimplemented from clues::SystemCallItem.

Definition at line 303 of file fcntl.cxx.

303 {
304 const auto pid_or_pgid = valueAs<int>();
305
306 if (pid_or_pgid >= 0) {
307 m_pgid.reset();
308 m_pid = cosmos::ProcessID{pid_or_pgid};
309 m_short_name = "pid";
310 m_long_name = "process id";
311 } else {
312 m_pid.reset();
313 m_pgid = cosmos::ProcessGroupID{-pid_or_pgid};
314 m_short_name = "pgid";
315 m_long_name = "process group id";
316 }
317}
std::string_view m_short_name
A human readable short name for the item, should be one word only.
OTHER valueAs() const
Helper to cast the strongly typed Word m_val to other strong enum types.
std::string_view m_long_name
A human readable longer name for the item.

◆ str()

std::string clues::item::FileDescOwner::str ( ) const
overridevirtual

Returns a human readable string representation of the item.

This member function should be specialized in derived classes to output the item's data in a fashion suitable for the concrete item type.

Reimplemented from clues::SystemCallItem.

Definition at line 319 of file fcntl.cxx.

319 {
320 if (m_pid)
321 return std::to_string(cosmos::to_integral(*m_pid));
322 else
323 return std::to_string(cosmos::to_integral(*m_pgid));
324}

Member Data Documentation

◆ m_pgid

std::optional<cosmos::ProcessGroupID> clues::item::FileDescOwner::m_pgid
protected

Definition at line 186 of file fcntl.hxx.

◆ m_pid

std::optional<cosmos::ProcessID> clues::item::FileDescOwner::m_pid
protected

Definition at line 185 of file fcntl.hxx.


The documentation for this class was generated from the following files: