libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
time.hxx
1#pragma once
2
3// C++
4#include <optional>
5
6// cosmos
7#include <cosmos/time/types.hxx>
8
9// clues
10#include <clues/items/items.hxx>
11#include <clues/SystemCallItem.hxx>
12
13namespace clues::item {
14
16class CLUES_API TimeSpecParameter :
17 public SystemCallItem {
18public: // functions
19 explicit TimeSpecParameter(
20 const std::string_view short_name,
21 const std::string_view long_name = {},
22 const ItemType type = ItemType::PARAM_IN,
23 const bool remain_semantics = false) :
24 SystemCallItem{type, short_name, long_name},
25 m_remain_semantics{remain_semantics} {
26 }
27
28 std::string str() const override;
29
30 const std::optional<struct timespec>& spec() const {
31 return m_timespec;
32 }
33
34protected: // functions
35
36 void processValue(const Tracee &proc) override {
37 if (this->isOut())
38 m_timespec.reset();
39 else
40 fetch(proc);
41 }
42
43 void updateData(const Tracee &proc) override;
44
45 void fetch(const Tracee &proc);
46
48 bool needTime32Conversion() const;
49
50protected: // data
51
52 std::optional<struct timespec> m_timespec;
53 bool m_remain_semantics = false;
54};
55
56class CLUES_API ClockID :
57 public ValueInParameter {
58public: // functions
59 explicit ClockID() :
60 ValueInParameter{"clockid", "clock identifier"} {
61 }
62
63 std::string str() const override;
64
65 auto type() const { return m_type; }
66
67protected: // functions
68
69 void processValue(const Tracee&) override {
71 }
72
73protected: // data
74
75 cosmos::ClockType m_type = cosmos::ClockType::INVALID;
76};
77
78class CLUES_API ClockNanoSleepFlags :
79 public ValueInParameter {
80public: // types
81
82 enum class Flag : int {
83 ABSTIME = TIMER_ABSTIME
84 };
85
86 using Flags = cosmos::BitMask<Flag>;
87
88public: // functions
89
90 explicit ClockNanoSleepFlags() :
91 ValueInParameter{"flags", "clock sleep flags"} {
92 }
93
94 std::string str() const override;
95
96 auto flags() const {
97 return m_flags;
98 }
99
100protected: // functions
101
102 void processValue(const Tracee&) override {
103 m_flags = Flags{valueAs<int>()};
104 }
105
106protected: // data
107
108 Flags m_flags;
109};
110
111} // end ns
OTHER valueAs() const
Helper to cast the strongly typed Word m_val to other strong enum types.
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
std::string str() const override
Returns a human readable string representation of the item.
Definition time.cxx:92
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
Definition time.hxx:69
std::string str() const override
Returns a human readable string representation of the item.
Definition time.cxx:107
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
Definition time.hxx:102
void processValue(const Tracee &proc) override
Processes the value stored in m_val acc. to the actual item type.
Definition time.hxx:36
std::string str() const override
Returns a human readable string representation of the item.
Definition time.cxx:79
ItemType
Basic type of a SystemCallItem.
@ PARAM_IN
An input parameter to the system call.