libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
aarch64.hxx
1#pragma once
2
3// C++
4#include <limits>
5
6// clues
7#include <clues/regs/RegisterData.hxx>
8#include <clues/sysnrs/aarch64.hxx>
9
10namespace clues {
11
14 public RegisterData<uint64_t, 6> {
15public: // constants
16
17 static constexpr auto NUM_REGS = 34;
18
19 SystemCallNrAARCH64 syscallNr() const {
20 // w8 (32-bit wide register access) contains the system call
21 // number, thus make sure the upper 4 bytes are ignored to be
22 // on the safe side.
23 return SystemCallNrAARCH64{regs[8] & std::numeric_limits<uint32_t>::max()};
24 }
25
26 auto syscallRes() const {
27 return regs[0];
28 }
29
30 SystemCallPars syscallPars() const {
31 return SystemCallPars{
32 regs[0], regs[1], regs[2], regs[3], regs[4], regs[5]
33 };
34 }
35
36 void clear() {
37 cosmos::zero_object(*this);
38 }
39
40 static auto registerNames() {
41 return std::array<const char*, NUM_REGS>({
42 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10",
43 "x11", "x12", "x13", "x14", "x15", "x16", "x17", "x18", "x19", "x20",
44 "x21", "x22", "x23", "x24", "x25", "x26", "x27", "x28", "x29", "x30",
45 "sp", "pc", "pstate"
46 });
47 }
48
49 auto array() const {
50 return std::array<register_t, NUM_REGS>({
51 regs[0], regs[1], regs[2], regs[3], regs[4], regs[5], regs[6], regs[7], regs[8],
52 regs[9], regs[10], regs[11], regs[12], regs[13], regs[14], regs[15], regs[16],
53 regs[17], regs[18], regs[19], regs[20], regs[21], regs[22], regs[23], regs[24],
54 regs[25], regs[26], regs[27], regs[28], regs[29], regs[30],
55 sp, pc, pstate
56 });
57 }
58
59public: // functions
60
61public: // data
62
63 // this is based on `struct user_pt_regs` found in ptrace.h for arm64.
64
65 uint64_t regs[31];
66 uint64_t sp;
67 uint64_t pc;
68 uint64_t pstate;
69};
70
71} // end ns
SystemCallNrAARCH64
Native system call numbers as used by Linux on the aarch64 ABI.
Definition aarch64.hxx:31
Native register data for the aarch64 ABI.
Definition aarch64.hxx:14
Base class for ABI specific register data.
std::array< register_t, NUM_SYSCALL_PARS > SystemCallPars