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

The struct sigaction used in various signal related system calls. More...

#include <signal.hxx>

+ Inheritance diagram for clues::item::SigActionParameter:

Public Member Functions

 SigActionParameter (const std::string_view short_name="sigaction", const std::string_view long_name="struct sigaction", const ItemType type=ItemType::PARAM_IN)
 
std::string str () const override
 Returns a human readable string representation of the item.
 
const std::optional< cosmos::SigAction > & action () const
 
- 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

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

Protected Attributes

std::optional< cosmos::SigAction > m_sigaction
 
- 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

The struct sigaction used in various signal related system calls.

Definition at line 75 of file signal.hxx.

Constructor & Destructor Documentation

◆ SigActionParameter()

clues::item::SigActionParameter::SigActionParameter ( const std::string_view short_name = "sigaction",
const std::string_view long_name = "struct sigaction",
const ItemType type = ItemType::PARAM_IN )
inlineexplicit

Definition at line 78 of file signal.hxx.

81 :
82 PointerValue{type, short_name, long_name} {
83 }

Member Function Documentation

◆ action()

const std::optional< cosmos::SigAction > & clues::item::SigActionParameter::action ( ) const
inline

Definition at line 87 of file signal.hxx.

87 {
88 return m_sigaction;
89 }

◆ processValue()

void clues::item::SigActionParameter::processValue ( const Tracee & )
overrideprotectedvirtual

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::SystemCallItem.

Definition at line 119 of file signal.cxx.

119 {
120
121 if (isOut() && proc.isEnterStop()) {
122 m_sigaction.reset();
123 return;
124 }
125
126 if (!m_sigaction) {
127 m_sigaction = cosmos::SigAction{};
128 }
129
130 switch (m_call->callNr()) {
131 case SystemCallNr::RT_SIGACTION: {
132 if (m_call->is32BitEmulationABI()) {
133 fetch_sigaction<kernel_sigaction32>(asPtr(), proc, m_sigaction);
134 } else {
135 fetch_sigaction<kernel_sigaction>(asPtr(), proc, m_sigaction);
136 }
137 break;
138 } case SystemCallNr::SIGACTION: {
139 fetch_sigaction<kernel_old_sigaction>(asPtr(), proc, m_sigaction);
140 break;
141 } default: {
142 m_sigaction.reset();
143 LOG_WARN("Unexpected system call encountered in SigActionParameter");
144 break;
145 }
146 }
147}
const SystemCall * m_call
The system call context this item part of.

◆ str()

std::string clues::item::SigActionParameter::str ( ) const
overridevirtual

Returns a human readable string representation of the item.

This member function should be specialized in derived classes to output the item's data in a fashion suitable for the concrete item type.

Reimplemented from clues::SystemCallItem.

Definition at line 36 of file signal.cxx.

36 {
37 if (!m_sigaction)
38 return "NULL";
39
40 const auto raw = m_sigaction->raw();
41
42 std::stringstream ss;
43
44 ss
45 << "{"
46 << "handler=";
47
48 if (m_sigaction->getFlags()[cosmos::SigAction::Flag::SIGINFO]) {
49 ss << format::pointer(ForeignPtr{reinterpret_cast<uintptr_t>(raw->sa_sigaction)});
50 } else {
51 if (raw->sa_handler == SIG_IGN)
52 ss << "SIG_IGN";
53 else if (raw->sa_handler == SIG_DFL)
54 ss << "SIG_DFL";
55 else
56 ss << format::pointer(ForeignPtr{reinterpret_cast<uintptr_t>(raw->sa_handler)});
57 }
58
59 ss << ", mask=" << format::signal_set(m_sigaction->mask()) << ", flags="
60 << format::saflags(m_sigaction->getFlags().raw()) << ", restorer="
61 << format::pointer(ForeignPtr{reinterpret_cast<uintptr_t>(raw->sa_restorer)}) << "}";
62
63 return ss.str();
64}
ForeignPtr
Strongly typed opaque pointer to tracee memory.
Definition types.hxx:140

Member Data Documentation

◆ m_sigaction

std::optional<cosmos::SigAction> clues::item::SigActionParameter::m_sigaction
protected

Definition at line 97 of file signal.hxx.


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