libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
mmap.hxx
1#pragma once
2
3// cosmos
4#include <cosmos/proc/mman.hxx>
5
6// clues
7#include <clues/items/items.hxx>
8
9namespace clues::item {
10
12class CLUES_API MemoryProtectionParameter :
13 public ValueInParameter {
14public: // functions
15
16 explicit MemoryProtectionParameter() :
17 ValueInParameter{"prot", "protection"} {
18 }
19
20 std::string str() const override;
21
22 auto prot() const {
23 return m_prot;
24 }
25
26protected: // functions
27
28 void processValue(const Tracee&) override {
29 m_prot = cosmos::mem::AccessFlags{valueAs<int>()};
30 }
31
32protected: // data
33
34 cosmos::mem::AccessFlags m_prot;
35};
36
38class CLUES_API MapFlagsParameter :
39 public ValueInParameter {
40public: // functions
41
42 explicit MapFlagsParameter() :
43 ValueInParameter{"flags", "memory mapping flags"} {
44 }
45
46 std::string str() const override;
47
48 cosmos::mem::MapType type() const {
49 return m_type;
50 }
51
52 cosmos::mem::MapFlags flags() const {
53 return m_flags;
54 }
55
56protected: // functions
57
58 void processValue(const Tracee&) override {
59 /*
60 * the lower three bits comprise the map type (a value, not a
61 * bit mask), the rest is a bit mask.
62 */
63 const auto raw = valueAs<int>();
64 m_flags = cosmos::mem::MapFlags{raw & ~0x3};
65 m_type = cosmos::mem::MapType{raw & 0x3};
66 }
67
68protected: // data
69
70 cosmos::mem::MapType m_type = cosmos::mem::MapType{0};
71 cosmos::mem::MapFlags m_flags;
72};
73
75class CLUES_API OldMmapArgs :
76 public PointerInValue {
77public:
78
79 explicit OldMmapArgs() :
80 PointerInValue{"args"} {
81 }
82
83 bool valid() const {
84 return m_valid;
85 }
86
87 ForeignPtr addr() const {
88 return m_addr;
89 }
90
91 size_t length() const {
92 return m_length;
93 }
94
95 size_t offset() const {
96 return m_offset;
97 }
98
99 cosmos::mem::MapType type() const {
100 return m_type;
101 }
102
103 cosmos::mem::MapFlags flags() const {
104 return m_flags;
105 }
106
107 cosmos::mem::AccessFlags prot() const {
108 return m_prot;
109 }
110
111 cosmos::FileNum fd() const {
112 return m_fd;
113 }
114
115protected: // functions
116
117 void processValue(const Tracee&) override;
118
119 std::string str() const override;
120
121protected: // data
122
123 bool m_valid = false;
124 ForeignPtr m_addr = ForeignPtr::NO_POINTER;
125 size_t m_length = 0;
126 size_t m_offset = 0;
127 cosmos::mem::MapType m_type{0};
128 cosmos::mem::MapFlags m_flags;
129 cosmos::mem::AccessFlags m_prot;
130 cosmos::FileNum m_fd;
131};
132
133} // 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
std::string str() const override
Returns a human readable string representation of the item.
Definition mmap.cxx:32
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
Definition mmap.hxx:58
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
Definition mmap.hxx:28
std::string str() const override
Returns a human readable string representation of the item.
Definition mmap.cxx:16
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
Definition mmap.cxx:73
std::string str() const override
Returns a human readable string representation of the item.
Definition mmap.cxx:93
ForeignPtr
Strongly typed opaque pointer to tracee memory.
Definition types.hxx:140