libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
clues::item::FcntlOperation Class Reference
+ Inheritance diagram for clues::item::FcntlOperation:

Public Types

enum class  Oper : int {
  DUPFD = F_DUPFD , DUPFD_CLOEXEC = F_DUPFD_CLOEXEC , GETFD = F_GETFD , SETFD = F_SETFD ,
  GETFL = F_GETFL , SETFL = F_SETFL , GETLK = 5 , SETLK = 6 ,
  SETLKW = 7 , GETLK64 = 12 , SETLK64 = 13 , SETLKW64 = 14 ,
  OFD_SETLK = F_OFD_SETLK , OFD_SETLKW = F_OFD_SETLKW , OFD_GETLK = F_OFD_GETLK , GETOWN = F_GETOWN ,
  SETOWN = F_SETOWN , GETOWN_EX = F_GETOWN_EX , SETOWN_EX = F_SETOWN_EX , GETSIG = F_GETSIG ,
  SETSIG = F_SETSIG , SETLEASE = F_SETLEASE , GETLEASE = F_GETLEASE , NOTIFY = F_NOTIFY ,
  SETPIPE_SZ = F_SETPIPE_SZ , GETPIPE_SZ = F_GETPIPE_SZ , ADD_SEALS = F_ADD_SEALS , GET_SEALS = F_GET_SEALS ,
  GET_RW_HINT = F_GET_RW_HINT , SET_RW_HINT = F_SET_RW_HINT , GET_FILE_RW_HINT = F_GET_FILE_RW_HINT , SET_FILE_RW_HINT = F_SET_FILE_RW_HINT ,
  INVALID = std::numeric_limits<int>::max()
}
 All possible arguments for the op parameter to fcntl(2). More...
 
- Public Types inherited from clues::SystemCallItem
enum class  Flag { DEFER_FILL = 1 << 0 }
 
using Flags = cosmos::BitMask<Flag>
 

Public Member Functions

std::string str () const override
 Returns a human readable string representation of the item.
 
Oper operation () const
 
bool isLock64 () const
 Returns whether the operation is one of the LK64 operations.
 
- Public Member Functions inherited from clues::item::ValueInParameter
 ValueInParameter (const std::string_view short_name, const std::string_view long_name={})
 
- Public Member Functions inherited from clues::item::ValueParameter
 ValueParameter (const ItemType type, const std::string_view short_name, const std::string_view long_name={})
 
- 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

Oper m_op = INVALID
 
- 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

Definition at line 17 of file fcntl.hxx.

Member Enumeration Documentation

◆ Oper

enum class clues::item::FcntlOperation::Oper : int
strong

All possible arguments for the op parameter to fcntl(2).

Definition at line 26 of file fcntl.hxx.

26 : int {
27 DUPFD = F_DUPFD,
28 DUPFD_CLOEXEC = F_DUPFD_CLOEXEC,
29 GETFD = F_GETFD,
30 SETFD = F_SETFD,
31 GETFL = F_GETFL,
32 SETFL = F_SETFL,
33 /*
34 * We cannot rely on the preprocessor definitions exported by
35 * the userspace headers due to a lot of magic going on. See
36 * the implementation of the str() method and FLockParameter
37 * for more details.
38 */
39 GETLK = 5, /* F_GETLK */
40 SETLK = 6, /* F_SETLK */
41 SETLKW = 7, /* F_SETLKW */
42 GETLK64 = 12, /* F_GETLK64 */
43 SETLK64 = 13, /* F_SETLK64 */
44 SETLKW64 = 14, /* F_SETLKW64 */
45 OFD_SETLK = F_OFD_SETLK,
46 OFD_SETLKW = F_OFD_SETLKW,
47 OFD_GETLK = F_OFD_GETLK,
48 GETOWN = F_GETOWN,
49 SETOWN = F_SETOWN,
50 GETOWN_EX = F_GETOWN_EX,
51 SETOWN_EX = F_SETOWN_EX,
52 GETSIG = F_GETSIG,
53 SETSIG = F_SETSIG,
54 SETLEASE = F_SETLEASE,
55 GETLEASE = F_GETLEASE,
56 NOTIFY = F_NOTIFY,
57 SETPIPE_SZ = F_SETPIPE_SZ,
58 GETPIPE_SZ = F_GETPIPE_SZ,
59 ADD_SEALS = F_ADD_SEALS,
60 GET_SEALS = F_GET_SEALS,
61 GET_RW_HINT = F_GET_RW_HINT,
62 SET_RW_HINT = F_SET_RW_HINT,
63 GET_FILE_RW_HINT = F_GET_FILE_RW_HINT,
64 SET_FILE_RW_HINT = F_SET_FILE_RW_HINT,
65 // DUPFD is already 0, thus we need a different invalid value
66 INVALID = std::numeric_limits<int>::max()
67 };

Constructor & Destructor Documentation

◆ FcntlOperation()

clues::item::FcntlOperation::FcntlOperation ( )
inline

Definition at line 21 of file fcntl.hxx.

21 :
22 ValueInParameter{"op", "operation"} {
23 }

Member Function Documentation

◆ isLock64()

bool clues::item::FcntlOperation::isLock64 ( ) const
inline

Returns whether the operation is one of the LK64 operations.

Definition at line 80 of file fcntl.hxx.

80 {
81 return cosmos::in_list(m_op, {Oper::GETLK64, Oper::SETLK64, Oper::SETLKW64});
82 }

◆ operation()

Oper clues::item::FcntlOperation::operation ( ) const
inline

Definition at line 75 of file fcntl.hxx.

75 {
76 return m_op;
77 }

◆ processValue()

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

29 {
30 m_op = valueAs<Oper>();
31}
OTHER valueAs() const
Helper to cast the strongly typed Word m_val to other strong enum types.

◆ str()

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

33 {
34 /*
35 * the F_*LK definitions exported by userspace headers are not helpful
36 * for our tracer context at all. They have different values on 64-bit
37 * targets than on 32-bit targets without _FILE_OFFSET_BITS=64 than on
38 * 32-bit targets with the latter define. They don't relate to what
39 * happens on system call level at all.
40 *
41 * Thus get rid of the macro definitions and use our own literal
42 * constants.
43 */
44#pragma push_macro("F_GETLK")
45#pragma push_macro("F_GETLK64")
46#pragma push_macro("F_SETLK")
47#pragma push_macro("F_SETLK64")
48#pragma push_macro("F_SETLKW")
49#pragma push_macro("F_SETLKW64")
50#undef F_GETLK
51#undef F_SETLK
52#undef F_SETLKW
53#undef F_GETLK64
54#undef F_SETLK64
55#undef F_SETLKW64
56
57 constexpr int F_GETLK = cosmos::to_integral(Oper::GETLK);
58 constexpr int F_GETLK64 = cosmos::to_integral(Oper::GETLK64);
59 constexpr int F_SETLK = cosmos::to_integral(Oper::SETLK);
60 constexpr int F_SETLK64 = cosmos::to_integral(Oper::SETLK64);
61 constexpr int F_SETLKW = cosmos::to_integral(Oper::SETLKW);
62 constexpr int F_SETLKW64 = cosmos::to_integral(Oper::SETLKW64);
63
64 switch (cosmos::to_integral(m_op)) {
65 CASE_ENUM_TO_STR(F_DUPFD);
66 CASE_ENUM_TO_STR(F_DUPFD_CLOEXEC);
67 CASE_ENUM_TO_STR(F_GETFD);
68 CASE_ENUM_TO_STR(F_SETFD);
69 CASE_ENUM_TO_STR(F_GETFL);
70 CASE_ENUM_TO_STR(F_SETFL);
71 CASE_ENUM_TO_STR(F_GETLK);
72 CASE_ENUM_TO_STR(F_SETLK);
73 CASE_ENUM_TO_STR(F_SETLKW);
74 CASE_ENUM_TO_STR(F_GETLK64);
75 CASE_ENUM_TO_STR(F_SETLK64);
76 CASE_ENUM_TO_STR(F_SETLKW64);
77 CASE_ENUM_TO_STR(F_OFD_SETLK);
78 CASE_ENUM_TO_STR(F_OFD_SETLKW);
79 CASE_ENUM_TO_STR(F_OFD_GETLK);
80 CASE_ENUM_TO_STR(F_GETOWN);
81 CASE_ENUM_TO_STR(F_SETOWN);
82 CASE_ENUM_TO_STR(F_GETOWN_EX);
83 CASE_ENUM_TO_STR(F_SETOWN_EX);
84 CASE_ENUM_TO_STR(F_GETSIG);
85 CASE_ENUM_TO_STR(F_SETSIG);
86 CASE_ENUM_TO_STR(F_SETLEASE);
87 CASE_ENUM_TO_STR(F_GETLEASE);
88 CASE_ENUM_TO_STR(F_NOTIFY);
89 CASE_ENUM_TO_STR(F_SETPIPE_SZ);
90 CASE_ENUM_TO_STR(F_GETPIPE_SZ);
91 CASE_ENUM_TO_STR(F_ADD_SEALS);
92 CASE_ENUM_TO_STR(F_GET_SEALS);
93 CASE_ENUM_TO_STR(F_GET_RW_HINT);
94 CASE_ENUM_TO_STR(F_SET_RW_HINT);
95 CASE_ENUM_TO_STR(F_GET_FILE_RW_HINT);
96 CASE_ENUM_TO_STR(F_SET_FILE_RW_HINT);
97 default: return "F_???";
98 }
99#pragma pop_macro("F_GETLK")
100#pragma pop_macro("F_GETLK64")
101#pragma pop_macro("F_SETLK")
102#pragma pop_macro("F_SETLK64")
103#pragma pop_macro("F_SETLKW")
104#pragma pop_macro("F_SETLKW64")
105}

Member Data Documentation

◆ m_op

Oper clues::item::FcntlOperation::m_op = INVALID
protected

Definition at line 90 of file fcntl.hxx.


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