libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
limits.hxx
1#pragma once
2
3// Linux
4#include <sys/resource.h>
5
6// C++
7#include <limits>
8#include <optional>
9
10// cosmos
11#include <cosmos/proc/limits.hxx>
12
13// clues
14#include <clues/items/items.hxx>
15
16namespace clues::item {
17
19class CLUES_API ResourceType :
20 public ValueInParameter {
21public: // functions
22 explicit ResourceType() :
23 ValueInParameter{"resource", "resource type"} {
24 }
25
26 std::string str() const override;
27
28 cosmos::LimitType type() const {
29 return m_limit;
30 }
31
32protected: // functions
33
34 void processValue(const Tracee &proc) override;
35
36protected: // data
37
38 cosmos::LimitType m_limit = cosmos::LimitType{std::numeric_limits<int>::max()};
39};
40
41class CLUES_API ResourceLimit :
42 public PointerValue {
43public: // functions
44 explicit ResourceLimit(const ItemType type, const std::string_view name = {}) :
45 PointerValue{type, name.empty() ? "limit" : name, ""} {
46 }
47
48 std::string str() const override;
49
50 std::optional<cosmos::LimitSpec> limit() const {
51 return m_limit;
52 }
53
54protected: // functions
55
56 void updateData(const Tracee &proc) override;
57
58 void processValue(const Tracee &proc) override {
59 if (isOut()) {
60 m_limit.reset();
61 } else {
62 // the same logic on input as on output
63 return updateData(proc);
64 }
65 }
66
68
73 bool isCompatSyscall() const;
74
75protected: // data
76
77 std::optional<cosmos::LimitSpec> m_limit;
78};
79
80} // end ns
Base class for traced processes.
Definition Tracee.hxx:39
std::string str() const override
Returns a human readable string representation of the item.
Definition limits.cxx:42
void updateData(const Tracee &proc) override
Called upon exit of the system call to update possible out parameters.
Definition limits.cxx:55
void processValue(const Tracee &proc) override
Processes the value stored in m_val acc. to the actual item type.
Definition limits.hxx:58
void processValue(const Tracee &proc) override
Processes the value stored in m_val acc. to the actual item type.
Definition limits.cxx:38
std::string str() const override
Returns a human readable string representation of the item.
Definition limits.cxx:16
ItemType
Basic type of a SystemCallItem.