libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
process.cxx
1#include <clues/items/process.hxx>
2#include <clues/format.hxx>
3#include <clues/Tracee.hxx>
4// private
5#include <clues/private/utils.hxx>
6
7namespace clues::item {
8
9std::string WaitOptionsItem::str() const {
10 BITFLAGS_FORMAT_START(m_options);
11 BITFLAGS_ADD(WEXITED);
12 BITFLAGS_ADD(WSTOPPED);
13 BITFLAGS_ADD(WCONTINUED);
14 BITFLAGS_ADD(WNOHANG);
15 BITFLAGS_ADD(WNOWAIT);
16 BITFLAGS_ADD(__WALL);
17 BITFLAGS_ADD(__WCLONE);
18 BITFLAGS_ADD(__WNOTHREAD);
19
20 return BITFLAGS_STR();
21}
22
24 m_rusage.emplace(ResourceUsage{});
25
26 if (!proc.readStruct(asPtr(), m_rusage->raw())) {
27 m_rusage.reset();
28 }
29}
30
31std::string ResourceUsageItem::str() const {
32 if (!m_rusage)
33 return "NULL";
34
35 const auto ru = m_rusage->raw();
36
37 std::stringstream ss;
38 ss
39 << "{utime=" << format::timeval(ru.ru_utime)
40 << ", stime=" << format::timeval(ru.ru_stime)
41 << ", maxrss=" << ru.ru_maxrss
42 << ", ixrss=" << ru.ru_ixrss
43 << ", idrss=" << ru.ru_idrss
44 << ", isrss=" << ru.ru_isrss
45 << ", minflt=" << ru.ru_minflt
46 << ", majflt=" << ru.ru_majflt
47 << ", nswap=" << ru.ru_nswap
48 << ", inblock=" << ru.ru_inblock
49 << ", oublock=" << ru.ru_oublock
50 << ", msgsnd=" << ru.ru_msgsnd
51 << ", msgrcv=" << ru.ru_msgrcv
52 << ", nsignals=" << ru.ru_nsignals
53 << ", nvcsw=" << ru.ru_nvcsw
54 << ", nivcsw=" << ru.ru_nivcsw
55 << "}";
56
57 return ss.str();
58}
59
60std::string WaitStatusItem::scalarToString() const {
61 if (!m_status) {
62 return "???";
63 }
64
65 std::stringstream ss;
66
67 if (m_status->exited()) {
68 ss << "WIFEXITED && WEXITSTATUS == " << cosmos::to_integral(*m_status->status());
69 } else if (m_status->signaled()) {
70 ss << "WIFSIGNALED &&";
71 if (m_status->dumped()) {
72 ss << "WCOREDUMP &&";
73 }
74 ss << "WTERMSIG == " << format::signal(m_status->termSig()->raw(), false);
75 }
76
77 return ss.str();
78}
79
80} // end ns
Base class for traced processes.
Definition Tracee.hxx:39
bool readStruct(const ForeignPtr addr, T &out) const
Reads a system call struct from the tracee's address space into out.
Definition Tracee.hxx:221
void updateData(const Tracee &proc) override
Called upon exit of the system call to update possible out parameters.
Definition process.cxx:23
std::string str() const override
Returns a human readable string representation of the item.
Definition process.cxx:31
std::string str() const override
Returns a human readable string representation of the item.
Definition process.cxx:9