libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
clone.hxx
1#pragma once
2
3// C++
4#include <optional>
5
6// cosmos
7#include <cosmos/proc/clone.hxx>
8
9// clues
10#include <clues/SystemCallItem.hxx>
11
12namespace clues::item {
13
14class CLUES_API CloneFlagsValue :
15 public SystemCallItem {
16public: // functions
17
18 explicit CloneFlagsValue() :
19 SystemCallItem{ItemType::PARAM_IN, "flags", "clone flags"} {
20 }
21
22 std::string str() const override;
23
24 cosmos::CloneFlags flags() const {
25 return m_flags;
26 }
27
28 std::optional<cosmos::SignalNr> exitSignal() const {
29 return exit_signal;
30 }
31
32protected: // functions
33
34 void processValue(const Tracee&) override;
35
36protected: // data
37
38 cosmos::CloneFlags m_flags;
40 std::optional<cosmos::SignalNr> exit_signal;
41};
42
44class CLUES_API CloneArgs :
45 public SystemCallItem {
46public: // functions
47
48 explicit CloneArgs() :
49 SystemCallItem{ItemType::PARAM_IN_OUT, "cl_args", "clone arguments"} {
50
51 }
52
54
60 const std::optional<cosmos::CloneArgs>& args() const {
61 return m_args;
62 }
63
65
69 cosmos::FileNum pidfd() const {
70 return m_pidfd;
71 }
72
74
79 cosmos::FileNum cgroup2fd() const {
80 return m_cgroup2_fd;
81 }
82
84
89 cosmos::ThreadID tid() const {
90 return m_child_tid;
91 }
92
93 std::string str() const override;
94
95 void processValue(const Tracee&) override;
96
97 void updateData(const Tracee &proc) override;
98
99protected: // functions
100
101 bool verifySize() const;
102
103 void resetArgs();
104
105protected: // data
106
107 std::optional<cosmos::CloneArgs> m_args;
108 cosmos::FileNum m_pidfd = cosmos::FileNum::INVALID;
109 cosmos::FileNum m_cgroup2_fd = cosmos::FileNum::INVALID;
110 cosmos::ThreadID m_child_tid = cosmos::ThreadID::INVALID;
111 std::vector<cosmos::ThreadID> m_tid_array;
112};
113
114} // end ns
SystemCallItem(const ItemType type, const std::string_view short_name={}, const std::string_view long_name={})
Constructs a new SystemCallItem.
Base class for traced processes.
Definition Tracee.hxx:39
cosmos::FileNum cgroup2fd() const
Return the cgroup2 file descriptor for the child to be placed in.
Definition clone.hxx:79
cosmos::FileNum pidfd() const
Return the newly created PIDFD.
Definition clone.hxx:69
cosmos::ThreadID tid() const
Return the new child's ThreadID stored in parent's memory.
Definition clone.hxx:89
const std::optional< cosmos::CloneArgs > & args() const
Returns an optional containing the cosmos::CloneArgs structure, if available.
Definition clone.hxx:60
std::optional< cosmos::SignalNr > exit_signal
For clone() 1/2 this contains the child exit signal, which is additionally encoded in the flags.
Definition clone.hxx:40
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
Definition clone.cxx:59
std::string str() const override
Returns a human readable string representation of the item.
Definition clone.cxx:55
@ PARAM_IN
An input parameter to the system call.
@ PARAM_IN_OUT
Both an input and output parameter.