libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
SystemCallDB.hxx
1#pragma once
2
3// C++
4#include <map>
5
6// clues
7#include <clues/SystemCall.hxx>
8
9namespace clues {
10
12
19class SystemCallDB {
20public: // functions
21
22 SystemCallDB() = default;
23
24 // non-copyable semantics
25 SystemCallDB(const SystemCallDB &) = delete;
26 SystemCallDB& operator=(const SystemCallDB &) = delete;
27
28 SystemCallDB(SystemCallDB &&other) {
29 *this = std::move(other);
30 }
31 SystemCallDB& operator=(SystemCallDB &&other) {
32 m_map = std::move(other.m_map);
33 return *this;
34 }
35
36 SystemCall& get(const SystemCallNr nr);
37
38 const SystemCall& get(const SystemCallNr nr) const {
39 return const_cast<SystemCallDB&>(*this).get(nr);
40 }
41
42protected: // data
43
44 /* XXX: this could also be a std::array of fixed size.
45 * This would waste a some memory but reduce lookup complexity even
46 * more.
47 * Every Tracee maintains its own SystemCallDB and often a thread only
48 * uses a rather limited amount of system calls. There are about ~500
49 * different system calls, so allocating a fixed array would cost
50 * about 4 KiB per Tracee. For 100 Tracees, which would be a high load
51 * scenario, the cost would cost be 400 KiB for maintaining all the
52 * pointers to potential SystemCall instances.
53 *
54 * Initial cost is higher for fixed sized arrays and non-lazy
55 * initialization, but runtime cost should be lower and determinism
56 * greater.
57 */
58
59 std::map<SystemCallNr, SystemCallPtr> m_map;
60};
61
62} // end ns
Access to System Call Data.
SystemCallNr
Abstract system call number usable across architectures and ABIs.
Definition generic.hxx:29