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

The flags passed to calls like open(). More...

#include <fs.hxx>

+ Inheritance diagram for clues::item::OpenFlagsValue:

Public Member Functions

 OpenFlagsValue (const ItemType type=ItemType::PARAM_IN)
 
std::string str () const override
 Returns a human readable string representation of the item.
 
cosmos::OpenMode mode () const
 
cosmos::OpenFlags flags () 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 &) 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

cosmos::OpenMode m_mode
 
cosmos::OpenFlags m_flags
 
- 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 flags passed to calls like open().

Definition at line 75 of file fs.hxx.

Constructor & Destructor Documentation

◆ OpenFlagsValue()

clues::item::OpenFlagsValue::OpenFlagsValue ( const ItemType type = ItemType::PARAM_IN)
inlineexplicit

Definition at line 78 of file fs.hxx.

78 :
79 SystemCallItem{type, "flags", "open flags"} {
80 }
SystemCallItem(const ItemType type, const std::string_view short_name={}, const std::string_view long_name={})
Constructs a new SystemCallItem.

Member Function Documentation

◆ flags()

cosmos::OpenFlags clues::item::OpenFlagsValue::flags ( ) const
inline

Definition at line 88 of file fs.hxx.

88 {
89 return m_flags;
90 }

◆ mode()

cosmos::OpenMode clues::item::OpenFlagsValue::mode ( ) const
inline

Definition at line 84 of file fs.hxx.

84 {
85 return m_mode;
86 }

◆ processValue()

void clues::item::OpenFlagsValue::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 106 of file fs.cxx.

106 {
107 const auto raw = valueAs<int>();
108 // the access mode consists of the lower two bits
109 m_mode = cosmos::OpenMode{raw & 0x3};
110 m_flags = cosmos::OpenFlags{raw & ~0x3};
111}
OTHER valueAs() const
Helper to cast the strongly typed Word m_val to other strong enum types.

◆ str()

std::string clues::item::OpenFlagsValue::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 53 of file fs.cxx.

53 {
54 /*
55 * When compling for x86_64 then O_LARGEFILE is defined to 0, which won't work
56 * when tracing 32-bit emulation binaries. The purpose of O_LARGEFILE being
57 * defined to 0 on x86_64 is to avoid passing the bit to `open()`
58 * unnecessarily.
59 * For tracing, in the context of this compilation unit, it should be okay to
60 * redefine the value to the actual O_LARGEFILE bit to make it visible when
61 * tracing 32-bit emulation binaries.
62 * Hopefully the value is the same on other architectures as well.
63 */
64#if O_LARGEFILE == 0
65# define RESTORE_LARGEFILE
66# pragma push_macro("O_LARGEFILE")
67# undef O_LARGEFILE
68# define O_LARGEFILE 0100000
69#endif
70
71 BITFLAGS_FORMAT_START_COMBINED(m_flags, valueAs<int>());
72
73 switch (m_mode) {
74 default: BITFLAGS_STREAM() << "O_???"; break;
75 case cosmos::OpenMode::READ_ONLY: BITFLAGS_STREAM() << "O_RDONLY"; break;
76 case cosmos::OpenMode::WRITE_ONLY: BITFLAGS_STREAM() << "O_WRONLY"; break;
77 case cosmos::OpenMode::READ_WRITE: BITFLAGS_STREAM() << "O_RDWR"; break;
78 }
79
80 BITFLAGS_STREAM() << '|';
81
82 BITFLAGS_ADD(O_APPEND);
83 BITFLAGS_ADD(O_ASYNC);
84 BITFLAGS_ADD(O_CLOEXEC);
85 BITFLAGS_ADD(O_CREAT);
86 BITFLAGS_ADD(O_DIRECT);
87 BITFLAGS_ADD(O_DIRECTORY);
88 BITFLAGS_ADD(O_DSYNC);
89 BITFLAGS_ADD(O_EXCL);
90 BITFLAGS_ADD(O_LARGEFILE);
91 BITFLAGS_ADD(O_NOATIME);
92 BITFLAGS_ADD(O_NOCTTY);
93 BITFLAGS_ADD(O_NOFOLLOW);
94 BITFLAGS_ADD(O_NONBLOCK);
95 BITFLAGS_ADD(O_PATH);
96 BITFLAGS_ADD(O_SYNC);
97 BITFLAGS_ADD(O_TMPFILE);
98 BITFLAGS_ADD(O_TRUNC);
99
100 return BITFLAGS_STR();
101#ifdef RESTORE_LARGEFILE
102# pragma pop_macro("O_LARGEFILE")
103#endif
104}

Member Data Documentation

◆ m_flags

cosmos::OpenFlags clues::item::OpenFlagsValue::m_flags
protected

Definition at line 99 of file fs.hxx.

◆ m_mode

cosmos::OpenMode clues::item::OpenFlagsValue::m_mode
protected

Definition at line 98 of file fs.hxx.


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