libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
SystemCallInfo.cxx
1// cosmos
2#include <cosmos/error/RuntimeError.hxx>
3
4// clues
5#include <clues/SystemCallInfo.hxx>
6#include <clues/sysnrs/all.hxx>
7
8namespace clues {
9
10SystemCallInfo::SystemCallInfo() :
11 m_generic{SystemCallNr::UNKNOWN} {
12}
13
15 if (!isEntry()) {
16 throw cosmos::RuntimeError{"bad SysCallInfo state"};
17 }
18
19 using Arch = cosmos::ptrace::Arch;
20 const auto native = entryInfo()->syscallNr();
21
22 switch (arch()) {
23 case Arch::X86_64: {
24 if (isX32()) {
25 m_abi = ABI::X32;
26 const auto x32_syscall = SystemCallNrX32{native};
27 m_native = x32_syscall;
28 m_generic = to_generic(x32_syscall);
29 } else {
30 m_abi = ABI::X86_64;
31 const auto x64_syscall = SystemCallNrX64{native};
32 m_native = x64_syscall;
33 m_generic = to_generic(x64_syscall);
34 }
35 break;
36 }
37 case Arch::I386: {
38 const auto i386_syscall = SystemCallNrI386{native};
39 m_native = i386_syscall;
40 m_generic = to_generic(i386_syscall);
41 m_abi = ABI::I386;
42 break;
43 }
44 case Arch::AARCH64: {
45 const auto aarch64_syscall = SystemCallNrAARCH64{native};
46 m_native = aarch64_syscall;
47 m_generic = to_generic(aarch64_syscall);
48 m_abi = ABI::AARCH64;
49 break;
50 }
51 default:
52 throw cosmos::RuntimeError("unsupported ARCH");
53 break;
54 }
55}
56
57} // end ns
void updateSysNr()
Update m_generic and m_native based on the raw system call nr.
@ X32
X86_64 with 32-bit pointers.
Definition types.hxx:66
SystemCallNrAARCH64
Native system call numbers as used by Linux on the aarch64 ABI.
Definition aarch64.hxx:31
SystemCallNr
Abstract system call number usable across architectures and ABIs.
Definition generic.hxx:29
SystemCallNrX64
Native system call numbers as used by Linux on the x64 ABI.
Definition x64.hxx:31
clues::SystemCallNr to_generic(const SystemCallNrAARCH64 nr)
Convert the native system call nr. into its generic representation.
Definition aarch64.cxx:21
SystemCallNrI386
Native system call numbers as used by Linux on the i386 ABI.
Definition i386.hxx:32