libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
io.hxx
1#pragma once
2
3// Linux
4#include <fcntl.h>
5
6// C++
7#include <optional>
8
9// cosmos
10#include <cosmos/BitMask.hxx>
11
12// clues
13#include <clues/items/fcntl.hxx>
14#include <clues/items/items.hxx>
15#include <clues/SystemCallItem.hxx>
16#include <clues/types.hxx>
17
18namespace clues::item {
19
21class CLUES_API PipeEnds :
22 public PointerOutValue {
23public: // functions
24
25 explicit PipeEnds() :
26 PointerOutValue{"pipefd", "pointer to array pipefd[2]"} {
27 }
28
29 std::string str() const override;
30
31 cosmos::FileNum readEnd() const {
32 return m_read_end;
33 }
34
35 cosmos::FileNum writeEnd() const {
36 return m_write_end;
37 }
38
40
44 bool haveEnds() const {
45 return m_read_end != cosmos::FileNum::INVALID && m_write_end != cosmos::FileNum::INVALID;
46 }
47
48protected: // functions
49
50 void reset() {
51 m_read_end = cosmos::FileNum::INVALID;
52 m_write_end = cosmos::FileNum::INVALID;
53 }
54
55 void processValue(const Tracee &) override {
56 reset();
57 }
58
59 void updateData(const Tracee &proc) override;
60
61protected: // data
62
63 cosmos::FileNum m_read_end = cosmos::FileNum::INVALID;
64 cosmos::FileNum m_write_end = cosmos::FileNum::INVALID;
65};
66
68class CLUES_API PipeFlags :
69 public ValueInParameter {
70public: // types
71
72 enum class Flag : int {
73 CLOEXEC = O_CLOEXEC,
74 DIRECT = O_DIRECT,
75 NONBLOCK = O_NONBLOCK,
76 NOTIFICATION_PIPE = O_EXCL /* this constant seems only defined in kernel headers and is just a reused O_EXCL */
77 };
78
79 using enum Flag;
80
81 using Flags = cosmos::BitMask<Flag>;
82
83public: // functions
84
85 explicit PipeFlags() :
86 ValueInParameter{"flags"} {
87 }
88
89 Flags flags() const {
90 return m_flags;
91 }
92
93 std::string str() const override;
94
95protected: // functions
96
97 void processValue(const Tracee &proc) override;
98
99protected: // data
100
101 Flags m_flags;
102};
103
104} // end ns
105
Base class for traced processes.
Definition Tracee.hxx:39
bool haveEnds() const
Returns whether valid read and write end file numbers are stored.
Definition io.hxx:44
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
Definition io.hxx:55
std::string str() const override
Returns a human readable string representation of the item.
Definition io.cxx:26
void processValue(const Tracee &proc) override
Processes the value stored in m_val acc. to the actual item type.
Definition io.cxx:60
std::string str() const override
Returns a human readable string representation of the item.
Definition io.cxx:37