libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
thread.hxx
1#pragma once
2
3// clues
4#include <clues/SystemCall.hxx>
5#include <clues/items/fs.hxx>
6#include <clues/items/futex.hxx>
7#include <clues/items/items.hxx>
8#include <clues/items/process.hxx>
9#include <clues/items/signal.hxx>
10#include <clues/items/time.hxx>
11#include <clues/sysnrs/generic.hxx>
12
13namespace clues {
14
15struct CLUES_API SetTIDAddressSystemCall :
16 public SystemCall {
17
18 SetTIDAddressSystemCall() :
19 SystemCall{SystemCallNr::SET_TID_ADDRESS},
20 address{"addr", "thread ID location"},
21 caller_tid{ItemType::RETVAL, "caller thread ID"} {
23 setParameters(address);
24 }
25
27
33
36};
37
38struct CLUES_API GetRobustListSystemCall :
39 public SystemCall {
40
41 GetRobustListSystemCall() :
42 SystemCall{SystemCallNr::GET_ROBUST_LIST},
43 thread_id{ItemType::PARAM_IN, "thread ID"},
44 list_head{"head", "pointer to robust list head"},
45 size_ptr{"sizep", "pointer to robust list head size",
47 setReturnItem(result);
48 setParameters(thread_id, list_head, size_ptr);
49 list_head.setBase(Base::HEX);
50 }
51
52 item::ThreadIDItem thread_id;
53 /*
54 * This points to `struct robust_list_head*` defined in futex.h. It
55 * could be fully modeled, but since this is so low-level and exotic I
56 * believe there is little value in this at this point.
57 */
61};
62
63struct CLUES_API SetRobustListSystemCall :
64 public SystemCall {
65
66 SetRobustListSystemCall() :
67 SystemCall{SystemCallNr::SET_ROBUST_LIST},
68 list_head{"head", "pointer to robust list head"},
69 size{"size", "robust list size"} {
70 setReturnItem(result);
71 setParameters(list_head, size);
72 }
73
75 item::SizeValue size;
77};
78
80
83struct CLUES_API FutexSystemCall :
84 public SystemCall {
85
86 FutexSystemCall() :
87 SystemCall{SystemCallNr::FUTEX},
88 futex_addr{"addr", "pointer to futex word"},
90 /*
91 * minimal default setup, the actual parameters and return
92 * values are setup in the member functions in a
93 * context-sensitive manner.
94 */
96 setParameters(futex_addr, operation);
97 }
98
99 /* fixed parameters */
100
101 // this points to a 32-bit value which is operated on
102 item::GenericPointerValue futex_addr;
103 item::FutexOperation operation;
104
105 /* context-dependent parameters */
106
108 std::optional<item::Uint32Value> value;
110 std::optional<item::Uint32Value> wake_count;
112 std::optional<item::SignalNumber> fd_sig;
114 std::optional<item::TimeSpecParameter> timeout;
116 std::optional<item::GenericPointerValue> futex2_addr;
118 std::optional<item::Uint32Value> requeue_value;
120 std::optional<item::Uint32Value> requeue_limit;
122 std::optional<item::Uint32Value> wake_count2;
124 std::optional<item::FutexWakeOperation> wake_op;
126 std::optional<item::GenericPointerValue> bitset;
127
128 /* context-dependent return values */
129
131 std::optional<item::ReturnValue> num_woken_up;
133 std::optional<item::FileDescriptor> new_fd;
135 std::optional<item::SuccessResult> result;
136
137protected: // functions
138
139 bool check2ndPass(const Tracee&) override;
140
141 void prepareNewSystemCall() override;
142
143 void updateFDTracking(const Tracee &proc) override;
144};
145
146} // end ns
void setReturnItem(SystemCallItem &ret)
Sets the return value system call item.
SystemCall(const SystemCallNr nr)
Instantiates a new SystemCall object with given properties.
Base class for traced processes.
Definition Tracee.hxx:39
The futex operation to be performed in the context of a futex system call.
Definition futex.hxx:19
A pointer to an integral data type which will be filled in by the kernel.
Definition items.hxx:209
An always-success return value.
Definition error.hxx:15
@ PARAM_IN
An input parameter to the system call.
@ RETVAL
A system call return value.
@ PARAM_IN_OUT
Both an input and output parameter.
void updateFDTracking(const Tracee &proc) override
Update file descriptor tracking.
Definition thread.cxx:132
std::optional< item::Uint32Value > wake_count2
! "val2", number of waiters at futex2_addr to wakeup (WAKE_OP).
Definition thread.hxx:122
std::optional< item::Uint32Value > requeue_limit
! "val2", upper limit on waiters to be requeued to addr2 (REQUEUE, CMP_REQUEUE, CMP_REQUEUE_PI).
Definition thread.hxx:120
std::optional< item::FileDescriptor > new_fd
! new file descriptor (CREATE_FD).
Definition thread.hxx:133
std::optional< item::FutexWakeOperation > wake_op
! instructions for how to perform the wake operation (WAKE_OP).
Definition thread.hxx:124
std::optional< item::Uint32Value > requeue_value
! "val3" used for comparison in CMP_REQUEUE, CMP_REQUEUE_PI.
Definition thread.hxx:118
std::optional< item::GenericPointerValue > bitset
! bitset to restrict wait/wakeup (FUTEX_WAIT_BITSET, FUTEX_WAKE_BITSET).
Definition thread.hxx:126
std::optional< item::Uint32Value > wake_count
! number of waiters to wake up (WAKE, REQUEUE, CMP_REQUEUE, WAKE_OP, CMD_REQUEUE_PI).
Definition thread.hxx:110
std::optional< item::Uint32Value > value
! the value expected at futex_addr (WAIT, WAIT_REQUEUE_PI).
Definition thread.hxx:108
void prepareNewSystemCall() override
Perform any necessary actions before processing a new system call entry event.
Definition thread.cxx:6
std::optional< item::TimeSpecParameter > timeout
! optional relative timeout (WAIT) or absolute timeout (WAIT_BITSET, LOCK_PI, LOCK_PI2).
Definition thread.hxx:114
std::optional< item::SuccessResult > result
! success status (all remaining operations).
Definition thread.hxx:135
std::optional< item::SignalNumber > fd_sig
! signal used for asynchronous notifications (CREATE_FD).
Definition thread.hxx:112
std::optional< item::GenericPointerValue > futex2_addr
! "uaddr2" requeue address (REQUEUE, CMP_REQUEUE, CMP_REQUEUE_PI, WAIT_REQUEUE_PI) or additional fute...
Definition thread.hxx:116
bool check2ndPass(const Tracee &) override
Check whether a second pass needs to be made processing parameters.
Definition thread.cxx:31
std::optional< item::ReturnValue > num_woken_up
! number of waiters woken up (WAKE, WAKE_OP).
Definition thread.hxx:131
item::GenericPointerValue address
location where to find a futex the kernel operates on.
Definition thread.hxx:32
item::ThreadIDItem caller_tid
This will always be the TID of the caller.
Definition thread.hxx:35