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

The read/write hint value used with R/W hint operations in the fcntl() system call. More...

#include <fcntl.hxx>

+ Inheritance diagram for clues::item::ReadWriteHint:

Public Types

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

Public Member Functions

 ReadWriteHint (const ItemType type)
 
Hint hint () const
 
std::string str () const override
 Returns a human readable string representation of the item.
 
- 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

Hint m_hint = Hint::LIFE_NOT_SET
 
- 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.
 

Detailed Description

The read/write hint value used with R/W hint operations in the fcntl() system call.

The fcntl() data type used for this is an uint64_t*. For some reason a 64-bit wide integer has been selected here, for which the usual int values do not provide enough space on 32-bit platforms. Probably for this reason both GET and SET operations operate on pointers to uint64_t passed in a second fcntl() argument.

Definition at line 308 of file fcntl.hxx.

Member Typedef Documentation

◆ Hint

using clues::item::ReadWriteHint::Hint = cosmos::FileDescriptor::ReadWriteHint

Definition at line 312 of file fcntl.hxx.

Constructor & Destructor Documentation

◆ ReadWriteHint()

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

Definition at line 316 of file fcntl.hxx.

316 :
317 SystemCallItem{type, "rw_hint", "read/write lifetime hint"} {
318 }
SystemCallItem(const ItemType type, const std::string_view short_name={}, const std::string_view long_name={})
Constructs a new SystemCallItem.

Member Function Documentation

◆ hint()

Hint clues::item::ReadWriteHint::hint ( ) const
inline

Definition at line 320 of file fcntl.hxx.

320 {
321 return m_hint;
322 }

◆ processValue()

void clues::item::ReadWriteHint::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 395 of file fcntl.cxx.

395 {
396 /*
397 * this is used for both input and output parameter variants
398 */
399 uint64_t native_hint;
400 if (proc.readStruct(asPtr(), native_hint)) {
401 m_hint = Hint{native_hint};
402 } else {
403 m_hint = Hint::LIFE_NOT_SET;
404 }
405}

◆ str()

std::string clues::item::ReadWriteHint::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 407 of file fcntl.cxx.

407 {
408 switch (cosmos::to_integral(m_hint)) {
409 CASE_ENUM_TO_STR(RWH_WRITE_LIFE_NOT_SET);
410 CASE_ENUM_TO_STR(RWH_WRITE_LIFE_NONE);
411 CASE_ENUM_TO_STR(RWH_WRITE_LIFE_SHORT);
412 CASE_ENUM_TO_STR(RWH_WRITE_LIFE_MEDIUM);
413 CASE_ENUM_TO_STR(RWH_WRITE_LIFE_LONG);
414 CASE_ENUM_TO_STR(RWH_WRITE_LIFE_EXTREME);
415 default: return "???";
416 }
417}

Member Data Documentation

◆ m_hint

Hint clues::item::ReadWriteHint::m_hint = Hint::LIFE_NOT_SET
protected

Definition at line 332 of file fcntl.hxx.


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