libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
clues::RegisterSet< abi > Class Template Reference

Holds a set of registers for the given ABI. More...

#include <RegisterSet.hxx>

Public Types

using ABIRegisterData = RegisterDataTraits<abi>::type
 This is the concrete type holding the raw register data for this ABI.
 
using register_t = ABIRegisterData::register_t
 

Public Member Functions

 RegisterSet (const cosmos::no_init_t &)
 
void fillIov (cosmos::InputMemoryRegion &iov)
 Prepares iov for doing a ptrace system call of type ptrace::Request::GETREGSET.
 
void iovFilled (const cosmos::InputMemoryRegion &iov)
 Verify data received from a ptrace system call of type ptrace::Request::GETREGSET.
 
auto abiSyscallNr () const
 Returns the ABI-specific system call number on entry to a syscall.
 
SystemCallNr syscallNr () const
 Returns the generic SystemCallNr on entry to a syscall.
 
register_t syscallRes () const
 Returns the system call result on exit from a syscall.
 
register_t syscallParameter (const size_t number) const
 Returns the content of the given system call parameter register.
 
auto & raw () const
 Provides access to the raw RegisterData based data structure.
 

Static Public Member Functions

static constexpr cosmos::ptrace::RegisterType registerType ()
 The type to pass to ptrace::Request::GETREGSET for obtaining the general purpose registers.
 

Static Public Attributes

static constexpr auto ABI = abi
 

Protected Attributes

ABIRegisterData m_regs
 The raw data structure holding the ABI specific register data.
 

Detailed Description

template<ABI abi>
class clues::RegisterSet< abi >

Holds a set of registers for the given ABI.

This type holds and manages data for each of the ABI specific RegisterData types.

Definition at line 31 of file RegisterSet.hxx.

Member Typedef Documentation

◆ ABIRegisterData

template<ABI abi>
using clues::RegisterSet< abi >::ABIRegisterData = RegisterDataTraits<abi>::type

This is the concrete type holding the raw register data for this ABI.

Definition at line 35 of file RegisterSet.hxx.

◆ register_t

template<ABI abi>
using clues::RegisterSet< abi >::register_t = ABIRegisterData::register_t

Definition at line 37 of file RegisterSet.hxx.

Constructor & Destructor Documentation

◆ RegisterSet() [1/2]

template<ABI abi>
clues::RegisterSet< abi >::RegisterSet ( const cosmos::no_init_t & )
inlineexplicit

Definition at line 41 of file RegisterSet.hxx.

41 {
42 }

◆ RegisterSet() [2/2]

template<ABI abi>
clues::RegisterSet< abi >::RegisterSet ( )
inline

Definition at line 44 of file RegisterSet.hxx.

44 {
45 m_regs.clear();
46 }
ABIRegisterData m_regs
The raw data structure holding the ABI specific register data.

Member Function Documentation

◆ abiSyscallNr()

template<ABI abi>
auto clues::RegisterSet< abi >::abiSyscallNr ( ) const
inline

Returns the ABI-specific system call number on entry to a syscall.

Definition at line 70 of file RegisterSet.hxx.

70{ return m_regs.syscallNr(); }

◆ fillIov()

template<ABI abi>
void clues::RegisterSet< abi >::fillIov ( cosmos::InputMemoryRegion & iov)
inline

Prepares iov for doing a ptrace system call of type ptrace::Request::GETREGSET.

Definition at line 49 of file RegisterSet.hxx.

49 {
50 // This makes sure the RegisterData wrapper is not bigger than
51 // the expected amount of register data.
52 static_assert(sizeof(m_regs) == sizeof(typename ABIRegisterData::register_t) * ABIRegisterData::NUM_REGS);
53 iov.setBase(&m_regs);
54 iov.setLength(sizeof(m_regs));
55 }
Holds a set of registers for the given ABI.

◆ iovFilled()

template<ABI abi>
void clues::RegisterSet< abi >::iovFilled ( const cosmos::InputMemoryRegion & iov)
inline

Verify data received from a ptrace system call of type ptrace::Request::GETREGSET.

Definition at line 58 of file RegisterSet.hxx.

58 {
59 if (iov.getLength() < sizeof(m_regs)) {
60 throw cosmos::RuntimeError{"received incomplete register set"};
61 }
62 }

◆ raw()

template<ABI abi>
auto & clues::RegisterSet< abi >::raw ( ) const
inline

Provides access to the raw RegisterData based data structure.

Definition at line 97 of file RegisterSet.hxx.

97 {
98 return m_regs;
99 }

◆ registerType()

template<ABI abi>
static constexpr cosmos::ptrace::RegisterType clues::RegisterSet< abi >::registerType ( )
inlinestaticconstexpr

The type to pass to ptrace::Request::GETREGSET for obtaining the general purpose registers.

Definition at line 65 of file RegisterSet.hxx.

◆ syscallNr()

template<ABI abi>
SystemCallNr clues::RegisterSet< abi >::syscallNr ( ) const
inline

Returns the generic SystemCallNr on entry to a syscall.

Definition at line 73 of file RegisterSet.hxx.

73 {
74 return to_generic(abiSyscallNr());
75 }
auto abiSyscallNr() const
Returns the ABI-specific system call number on entry to a syscall.
clues::SystemCallNr to_generic(const SystemCallNrAARCH64 nr)
Convert the native system call nr. into its generic representation.
Definition aarch64.cxx:21

◆ syscallParameter()

template<ABI abi>
register_t clues::RegisterSet< abi >::syscallParameter ( const size_t number) const
inline

Returns the content of the given system call parameter register.

The current ABI can pass up to ABIRegisterData::NUM_SYSCALL_PARS registers to system calls. To get the n'th system call parameter register content, pass (n - 1) as number (i.e. counting starts at zero).

Definition at line 87 of file RegisterSet.hxx.

87 {
88 auto pars = m_regs.syscallPars();
89 if (number >= pars.size()) {
90 throw cosmos::UsageError{"invalid system call parameter nr."};
91 }
92
93 return pars[number];
94 }

◆ syscallRes()

template<ABI abi>
register_t clues::RegisterSet< abi >::syscallRes ( ) const
inline

Returns the system call result on exit from a syscall.

Definition at line 78 of file RegisterSet.hxx.

78{ return m_regs.syscallRes(); }

Member Data Documentation

◆ ABI

template<ABI abi>
auto clues::RegisterSet< abi >::ABI = abi
staticconstexpr

Definition at line 36 of file RegisterSet.hxx.

◆ m_regs

template<ABI abi>
ABIRegisterData clues::RegisterSet< abi >::m_regs
protected

The raw data structure holding the ABI specific register data.

Definition at line 104 of file RegisterSet.hxx.


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