2#include <cosmos/formatting.hxx>
5#include <clues/items/futex.hxx>
6#include <clues/macros.h>
7#include <clues/private/utils.hxx>
20 auto format_op = [](
int val) -> std::string {
21 switch (val & FUTEX_CMD_MASK) {
22 CASE_ENUM_TO_STR(FUTEX_CMP_REQUEUE);
23 CASE_ENUM_TO_STR(FUTEX_CMP_REQUEUE_PI);
24 CASE_ENUM_TO_STR(FUTEX_FD);
25 CASE_ENUM_TO_STR(FUTEX_LOCK_PI);
26 CASE_ENUM_TO_STR(FUTEX_LOCK_PI2);
27 CASE_ENUM_TO_STR(FUTEX_REQUEUE);
28 CASE_ENUM_TO_STR(FUTEX_TRYLOCK_PI);
29 CASE_ENUM_TO_STR(FUTEX_UNLOCK_PI);
30 CASE_ENUM_TO_STR(FUTEX_WAIT);
31 CASE_ENUM_TO_STR(FUTEX_WAIT_BITSET);
32 CASE_ENUM_TO_STR(FUTEX_WAIT_REQUEUE_PI);
33 CASE_ENUM_TO_STR(FUTEX_WAKE);
34 CASE_ENUM_TO_STR(FUTEX_WAKE_BITSET);
35 CASE_ENUM_TO_STR(FUTEX_WAKE_OP);
36 default:
return cosmos::sprintf(
"unknown (%d)", val);
41 BITFLAGS_FORMAT_START_COMBINED(m_flags, val);
43 BITFLAGS_STREAM() << format_op(val);
45 if (!m_flags.none()) {
46 BITFLAGS_STREAM() <<
'|';
47 BITFLAGS_ADD(FUTEX_PRIVATE_FLAG);
48 BITFLAGS_ADD(FUTEX_CLOCK_REALTIME);
51 return BITFLAGS_STR();
56 m_flags = Flags{
valueAs<int>() xor cosmos::to_integral(m_cmd)};
62 switch (cosmos::to_integral(op)) {
63 CASE_ENUM_TO_STR(FUTEX_OP_SET);
64 CASE_ENUM_TO_STR(FUTEX_OP_ADD);
65 CASE_ENUM_TO_STR(FUTEX_OP_OR);
66 CASE_ENUM_TO_STR(FUTEX_OP_ANDN);
67 CASE_ENUM_TO_STR(FUTEX_OP_XOR);
68 default:
return cosmos::sprintf(
"unknown (%d)", cosmos::to_integral(op));
73 switch (cosmos::to_integral(cmp)) {
74 CASE_ENUM_TO_STR(FUTEX_OP_CMP_EQ);
75 CASE_ENUM_TO_STR(FUTEX_OP_CMP_NE);
76 CASE_ENUM_TO_STR(FUTEX_OP_CMP_LT);
77 CASE_ENUM_TO_STR(FUTEX_OP_CMP_LE);
78 CASE_ENUM_TO_STR(FUTEX_OP_CMP_GT);
79 CASE_ENUM_TO_STR(FUTEX_OP_CMP_GE);
80 default:
return cosmos::sprintf(
"unknown (%d)", cosmos::to_integral(cmp));
97 const auto op_bits = raw >> 28;
102 m_op =
Operation{op_bits & (~FUTEX_OP_OPARG_SHIFT)};
111 return cosmos::sprintf(
"{op=%s%s, cmp=%s, oparg=%u, cmparg=%u}",
112 get_label(m_op).c_str(),
114 get_label(m_comp).c_str(),
OTHER valueAs() const
Helper to cast the strongly typed Word m_val to other strong enum types.
Base class for traced processes.
std::string str() const override
Returns a human readable string representation of the item.
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
Operation
Atomic operation to be carried out on futex value.
uint32_t m_oparg
! The operation argument used in uaddr2 OP oparg.
std::string str() const override
Returns a human readable string representation of the item.
uint32_t m_cmparg
! The comparison argument used in oldval CMP cmparg.
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
bool m_shift_arg
! Whether oparg is additionally replaced by 1 << oparg.