877f59390f7f0e491a2388566aaddc377b0cb1ae
[lttng-tools.git] / src / bin / lttng-sessiond / lttng-syscall.hpp
1 /*
2 * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef LTTNG_SYSCALL_H
9 #define LTTNG_SYSCALL_H
10
11 #include "trace-kernel.hpp"
12
13 #include <common/exception.hpp>
14 #include <common/hashtable/hashtable.hpp>
15 #include <common/macros.hpp>
16 #include <common/string-utils/c-string-view.hpp>
17
18 #include <lttng/event.h>
19
20 /*
21 * Default size of the kernel system call array. With this size, we usually
22 * reallocate twice considering a 32 bit compat layer also.
23 */
24 #define SYSCALL_TABLE_INIT_SIZE 256
25
26 /* Maximum length of a syscall name. */
27 #define SYSCALL_NAME_LEN 255
28
29 /*
30 * Represent a kernel syscall and used when we are populating the internal
31 * list.
32 */
33 struct syscall {
34 syscall(std::uint32_t index_, std::uint32_t bitness_, const lttng::c_string_view name_) :
35 index(index_), bitness(bitness_)
36 {
37 if (lttng_strncpy(name, name_.data(), sizeof(name))) {
38 LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format(
39 "Invalid syscall name: name=`{}`, length={}, max_length={}",
40 name_.data(),
41 name_.len(),
42 sizeof(name)));
43 }
44
45 lttng_ht_node_init_str(&node, name);
46 }
47
48 std::uint32_t index = 0;
49 std::uint32_t bitness = 0;
50 char name[SYSCALL_NAME_LEN] = {};
51 /* Used by the list syscalls command. */
52 struct lttng_ht_node_str node = {};
53 };
54
55 /*
56 * Allocated once when listing all syscalls at boot time. This is an array
57 * indexed by the syscall index provided in the listing.
58 */
59 extern std::vector<struct syscall> syscall_table;
60
61 /* Use to list kernel system calls. */
62 int syscall_init_table(int tracer_fd);
63 ssize_t syscall_table_list(struct lttng_event **events);
64
65 #endif /* LTTNG_SYSCALL_H */
This page took 0.033174 seconds and 5 git commands to generate.