libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
io.cxx
1// cosmos
2#include <cosmos/formatting.hxx>
3
4// clues
5#include <clues/format.hxx>
6#include <clues/items/io.hxx>
7#include <clues/Tracee.hxx>
8// private
9#include <clues/private/utils.hxx>
10
11namespace clues::item {
12
13void PipeEnds::updateData(const Tracee &proc) {
14 int ends[2];
15
16 if (!proc.readStruct(asPtr(), ends)) {
17 // probably bad userspace address or Tracee died
18 reset();
19 return;
20 }
21
22 m_read_end = cosmos::FileNum{ends[0]};
23 m_write_end = cosmos::FileNum{ends[1]};
24}
25
26std::string PipeEnds::str() const {
27 if (haveEnds()) {
28 const auto ends_array = cosmos::sprintf("%d, %d",
29 cosmos::to_integral(m_read_end),
30 cosmos::to_integral(m_write_end));
31 return clues::format::pointer(asPtr(), ends_array);
32 } else {
33 return clues::format::pointer(asPtr());
34 }
35}
36
37std::string PipeFlags::str() const {
38 BITFLAGS_FORMAT_START(m_flags);
39
40#define O_NOTIFICATION_PIPE O_EXCL
41
42 BITFLAGS_ADD(O_CLOEXEC);
43 BITFLAGS_ADD(O_DIRECT);
44 BITFLAGS_ADD(O_NONBLOCK);
45 /*
46 * This notification pipe mechanism is a pretty weird communication
47 * mechanism towards the kernel which can be used to e.g. get
48 * information out keyring events. A bit of a misused pipe for
49 * netlink-like purposes.
50 *
51 * From the tracing POV all we could do is interpreting the messages
52 * exchanged on such a pipe, but it doesn't seem worth the effort,
53 * I've never seen it in production.
54 */
55 BITFLAGS_ADD(O_NOTIFICATION_PIPE);
56
57 return BITFLAGS_STR();
58}
59
61 m_flags = Flags{valueAs<int>()};
62}
63
64} // end ns
OTHER valueAs() const
Helper to cast the strongly typed Word m_val to other strong enum types.
Base class for traced processes.
Definition Tracee.hxx:39
bool readStruct(const ForeignPtr addr, T &out) const
Reads a system call struct from the tracee's address space into out.
Definition Tracee.hxx:221
bool haveEnds() const
Returns whether valid read and write end file numbers are stored.
Definition io.hxx:44
void updateData(const Tracee &proc) override
Called upon exit of the system call to update possible out parameters.
Definition io.cxx:13
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