libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
clues::item::WaitStatusItem Class Reference

Pointer to an int containing wait() status result data. More...

#include <process.hxx>

+ Inheritance diagram for clues::item::WaitStatusItem:

Public Member Functions

const std::optional< cosmos::WaitStatus > & status () const
 
- Public Member Functions inherited from clues::item::PointerToScalar< int >
 PointerToScalar (const std::string_view short_name, const std::string_view long_name={}, const ItemType type=ItemType::PARAM_OUT)
 
ForeignPtr pointer () const
 
std::optional< int > value () const
 
std::string str () const override
 Returns a human readable string representation of the item.
 
void setBase (const Base base)
 
- Public Member Functions inherited from clues::item::PointerValue
 PointerValue (const ItemType type, const std::string_view short_name, const std::string_view long_name)
 
- Public Member Functions inherited from clues::SystemCallItem
 SystemCallItem (const ItemType type, const std::string_view short_name={}, const std::string_view long_name={})
 Constructs a new SystemCallItem.
 
auto type () const
 
bool isIn () const
 
bool isOut () const
 
bool isInOut () const
 
bool isReturnValue () const
 
void fill (const Tracee &proc, const Word word)
 Fills the item from the given register data.
 
bool needsUpdate () const
 Returns whether the item needs to be updated after the system call is finished.
 
std::string_view shortName () const
 Returns the friendly short name for this item.
 
std::string_view longName () const
 Returns the friendly long name for this item, if available, else the short name.
 
auto hasLongName () const
 
bool isZero () const
 Returns whether the parameter is set to 0 / NULL.
 
Word value () const
 Returns the currently stored raw value of the item.
 
template<typename OTHER>
OTHER valueAs () const
 Helper to cast the strongly typed Word m_val to other strong enum types.
 
ForeignPtr asPtr () const
 
Flags flags () const
 
bool deferFill () const
 

Protected Member Functions

std::string scalarToString () const override
 
void processValue (const Tracee &tracee) override
 Processes the value stored in m_val acc. to the actual item type.
 
void updateData (const Tracee &tracee) override
 Called upon exit of the system call to update possible out parameters.
 
- Protected Member Functions inherited from clues::item::PointerToScalar< int >
void fetchValue (const Tracee &tracee)
 
- Protected Member Functions inherited from clues::SystemCallItem
void setSystemCall (const SystemCall &sc)
 Sets the system call context this item is a part of.
 

Protected Attributes

std::optional< cosmos::WaitStatus > m_status
 
- Protected Attributes inherited from clues::item::PointerToScalar< int >
ForeignPtr m_ptr
 
std::optional< int > m_val
 
Base m_base
 
- Protected Attributes inherited from clues::SystemCallItem
const SystemCallm_call = nullptr
 The system call context this item part of.
 
const ItemType m_type
 The type of item.
 
std::string_view m_short_name
 A human readable short name for the item, should be one word only.
 
std::string_view m_long_name
 A human readable longer name for the item.
 
Word m_val
 The raw register value for the item.
 
Flags m_flags
 Flags influencing the processing of the item.
 

Additional Inherited Members

- Public Types inherited from clues::SystemCallItem
enum class  Flag { DEFER_FILL = 1 << 0 }
 
using Flags = cosmos::BitMask<Flag>
 

Detailed Description

Pointer to an int containing wait() status result data.

Definition at line 153 of file process.hxx.

Constructor & Destructor Documentation

◆ WaitStatusItem()

clues::item::WaitStatusItem::WaitStatusItem ( )
inlineexplicit

Definition at line 157 of file process.hxx.

157 :
158 PointerToScalar{"wstatus", "wait status"} {
159 }

Member Function Documentation

◆ processValue()

void clues::item::WaitStatusItem::processValue ( const Tracee & tracee)
inlineoverrideprotectedvirtual

Processes the value stored in m_val acc. to the actual item type.

This function is called for all parameter types upon entry to a system call, and for ItemType::RETVAL upon exit from a system call.

For parameters of ItemType::PARAM_OUT this callback can be used to reset any stored data to be filled in later when updateData() is called.

Reimplemented from clues::item::PointerToScalar< int >.

Definition at line 169 of file process.hxx.

169 {
170 m_status.reset();
172 }
void processValue(const Tracee &tracee) override
Processes the value stored in m_val acc. to the actual item type.
Definition items.hxx:235

◆ scalarToString()

std::string clues::item::WaitStatusItem::scalarToString ( ) const
overrideprotectedvirtual

Reimplemented from clues::item::PointerToScalar< int >.

Definition at line 60 of file process.cxx.

60 {
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}

◆ status()

const std::optional< cosmos::WaitStatus > & clues::item::WaitStatusItem::status ( ) const
inline

Definition at line 161 of file process.hxx.

161 {
162 return m_status;
163 }

◆ updateData()

void clues::item::WaitStatusItem::updateData ( const Tracee & tracee)
inlineoverrideprotectedvirtual

Called upon exit of the system call to update possible out parameters.

This function is called for parameters of ItemType::PARAM_OUT and ItemType::PARAM_IN_OUT upon system call exit to update the data from the values returned from the system call.

The default implementation calls processValue() to allow to share the same data processing code for input and output for item types that support both.

This function is called regardless of system call success or error, so it can happen that there is no valid data returned by the kernel or pointers in userspace are broken. Implementations should take this into consideration when operating on the data.

Reimplemented from clues::item::PointerToScalar< int >.

Definition at line 174 of file process.hxx.

174 {
176 if (m_val) {
177 m_status = cosmos::WaitStatus{*m_val};
178 }
179 }
Word m_val
The raw register value for the item.
void updateData(const Tracee &tracee) override
Called upon exit of the system call to update possible out parameters.
Definition items.hxx:245

Member Data Documentation

◆ m_status

std::optional<cosmos::WaitStatus> clues::item::WaitStatusItem::m_status
protected

Definition at line 183 of file process.hxx.


The documentation for this class was generated from the following files: