2 * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
8 #ifndef LTTNG_SYSCALL_H
9 #define LTTNG_SYSCALL_H
11 #include "trace-kernel.hpp"
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>
18 #include <lttng/event.h>
21 * Default size of the kernel system call array. With this size, we usually
22 * reallocate twice considering a 32 bit compat layer also.
24 #define SYSCALL_TABLE_INIT_SIZE 256
26 /* Maximum length of a syscall name. */
27 #define SYSCALL_NAME_LEN 255
30 * Represent a kernel syscall and used when we are populating the internal
34 syscall(std::uint32_t index_, std::uint32_t bitness_, const lttng::c_string_view name_) :
35 index(index_), bitness(bitness_)
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={}",
45 lttng_ht_node_init_str(&node, name);
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 = {};
56 * Allocated once when listing all syscalls at boot time. This is an array
57 * indexed by the syscall index provided in the listing.
59 extern std::vector<struct syscall> syscall_table;
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);
65 #endif /* LTTNG_SYSCALL_H */