#include <lttng/events-internal.h>
#include <lttng/utils.h>
+#include "lttng-syscalls.h"
+
#ifndef CONFIG_COMPAT
# ifndef is_compat_task
# define is_compat_task() (0)
#undef LTTNG_PACKAGE_BUILD
#undef CREATE_TRACE_POINTS
-struct trace_syscall_entry {
- void *event_func;
- const struct lttng_kernel_event_desc *desc;
- const struct lttng_kernel_event_field **fields;
- unsigned int nrargs;
-};
-
#define CREATE_SYSCALL_TABLE
#define SC_ENTER
},
/* Event syscall enter tracing table */
-static const struct trace_syscall_entry sc_table[] = {
+static const struct trace_syscall_entry _sc_table[] = {
#include <instrumentation/syscalls/headers/syscalls_integers.h>
#include <instrumentation/syscalls/headers/syscalls_pointers.h>
};
+
+const struct trace_syscall_table sc_table = {
+ .table = _sc_table,
+ .len = ARRAY_SIZE(_sc_table),
+};
+
#undef TRACE_SYSCALL_TABLE
#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \
[ _nr ] = { \
},
/* Event compat syscall enter table */
-const struct trace_syscall_entry compat_sc_table[] = {
+const struct trace_syscall_entry _compat_sc_table[] = {
#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
};
+const struct trace_syscall_table compat_sc_table = {
+ .table = _compat_sc_table,
+ .len = ARRAY_SIZE(_compat_sc_table),
+};
+
#undef SC_ENTER
#define SC_EXIT
},
/* Event syscall exit table */
-static const struct trace_syscall_entry sc_exit_table[] = {
+static const struct trace_syscall_entry _sc_exit_table[] = {
#include <instrumentation/syscalls/headers/syscalls_integers.h>
#include <instrumentation/syscalls/headers/syscalls_pointers.h>
};
+const struct trace_syscall_table sc_exit_table = {
+ .table = _sc_exit_table,
+ .len = ARRAY_SIZE(_sc_exit_table),
+};
+
+
#undef TRACE_SYSCALL_TABLE
#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs) \
[ _nr ] = { \
},
/* Event compat syscall exit table */
-const struct trace_syscall_entry compat_sc_exit_table[] = {
+const struct trace_syscall_entry _compat_sc_exit_table[] = {
#include <instrumentation/syscalls/headers/compat_syscalls_integers.h>
#include <instrumentation/syscalls/headers/compat_syscalls_pointers.h>
};
+const struct trace_syscall_table compat_sc_exit_table = {
+ .table = _compat_sc_exit_table,
+ .len = ARRAY_SIZE(_compat_sc_exit_table),
+};
+
#undef SC_EXIT
#undef CREATE_SYSCALL_TABLE
/* System call filtered out. */
return;
}
- table = compat_sc_table;
- table_len = ARRAY_SIZE(compat_sc_table);
+ table = compat_sc_table.table;
+ table_len = compat_sc_table.len;
unknown_action_list = &chan->sc_compat_unknown;
} else {
struct lttng_syscall_filter *filter = chan->sc_filter;
/* System call filtered out. */
return;
}
- table = sc_table;
- table_len = ARRAY_SIZE(sc_table);
+ table = sc_table.table;
+ table_len = sc_table.len;
unknown_action_list = &chan->sc_unknown;
}
if (unlikely(id < 0 || id >= table_len)) {
/* System call filtered out. */
return;
}
- table = compat_sc_table;
- table_len = ARRAY_SIZE(compat_sc_table);
+ table = compat_sc_table.table;
+ table_len = compat_sc_table.len;
unknown_dispatch_list = &group->event_notifier_compat_unknown_syscall_dispatch;
} else {
struct lttng_syscall_filter *filter = group->sc_filter;
/* System call filtered out. */
return;
}
- table = sc_table;
- table_len = ARRAY_SIZE(sc_table);
+ table = sc_table.table;
+ table_len = sc_table.len;
unknown_dispatch_list = &group->event_notifier_unknown_syscall_dispatch;
}
/* Check if the syscall id is out of bound. */
/* System call filtered out. */
return;
}
- table = compat_sc_exit_table;
- table_len = ARRAY_SIZE(compat_sc_exit_table);
+ table = compat_sc_exit_table.table;
+ table_len = compat_sc_exit_table.len;
unknown_action_list = &chan->compat_sc_exit_unknown;
} else {
struct lttng_syscall_filter *filter = chan->sc_filter;
/* System call filtered out. */
return;
}
- table = sc_exit_table;
- table_len = ARRAY_SIZE(sc_exit_table);
+ table = sc_exit_table.table;
+ table_len = sc_exit_table.len;
unknown_action_list = &chan->sc_exit_unknown;
}
if (unlikely(id < 0 || id >= table_len)) {
/* System call filtered out. */
return;
}
- table = compat_sc_exit_table;
- table_len = ARRAY_SIZE(compat_sc_exit_table);
+ table = compat_sc_exit_table.table;
+ table_len = compat_sc_exit_table.len;
unknown_dispatch_list = &group->event_notifier_exit_compat_unknown_syscall_dispatch;
} else {
struct lttng_syscall_filter *filter = group->sc_filter;
/* System call filtered out. */
return;
}
- table = sc_exit_table;
- table_len = ARRAY_SIZE(sc_exit_table);
+ table = sc_exit_table.table;
+ table_len = sc_exit_table.len;
unknown_dispatch_list = &group->event_notifier_exit_unknown_syscall_dispatch;
}
/* Check if the syscall id is out of bound. */
if (!chan->sc_table) {
/* create syscall table mapping syscall to events */
chan->sc_table = kzalloc(sizeof(struct lttng_kernel_event_recorder *)
- * ARRAY_SIZE(sc_table), GFP_KERNEL);
+ * sc_table.len, GFP_KERNEL);
if (!chan->sc_table)
return -ENOMEM;
}
if (!chan->sc_exit_table) {
/* create syscall table mapping syscall to events */
chan->sc_exit_table = kzalloc(sizeof(struct lttng_kernel_event_recorder *)
- * ARRAY_SIZE(sc_exit_table), GFP_KERNEL);
+ * sc_exit_table.len, GFP_KERNEL);
if (!chan->sc_exit_table)
return -ENOMEM;
}
if (!chan->compat_sc_table) {
/* create syscall table mapping compat syscall to events */
chan->compat_sc_table = kzalloc(sizeof(struct lttng_kernel_event_recorder *)
- * ARRAY_SIZE(compat_sc_table), GFP_KERNEL);
+ * compat_sc_table.len, GFP_KERNEL);
if (!chan->compat_sc_table)
return -ENOMEM;
}
if (!chan->compat_sc_exit_table) {
/* create syscall table mapping compat syscall to events */
chan->compat_sc_exit_table = kzalloc(sizeof(struct lttng_kernel_event_recorder *)
- * ARRAY_SIZE(compat_sc_exit_table), GFP_KERNEL);
+ * compat_sc_exit_table.len, GFP_KERNEL);
if (!chan->compat_sc_exit_table)
return -ENOMEM;
}
hlist_add_head(&event_recorder->priv->parent.u.syscall.node, &chan->sc_exit_unknown);
}
- ret = lttng_create_syscall_event_if_missing(sc_table, ARRAY_SIZE(sc_table),
+ ret = lttng_create_syscall_event_if_missing(sc_table.table, sc_table.len,
chan->sc_table, event_enabler, SC_TYPE_ENTRY);
if (ret)
return ret;
- ret = lttng_create_syscall_event_if_missing(sc_exit_table, ARRAY_SIZE(sc_exit_table),
+ ret = lttng_create_syscall_event_if_missing(sc_exit_table.table, sc_exit_table.len,
chan->sc_exit_table, event_enabler, SC_TYPE_EXIT);
if (ret)
return ret;
#ifdef CONFIG_COMPAT
- ret = lttng_create_syscall_event_if_missing(compat_sc_table, ARRAY_SIZE(compat_sc_table),
+ ret = lttng_create_syscall_event_if_missing(compat_sc_table.table, compat_sc_table.len,
chan->compat_sc_table, event_enabler, SC_TYPE_COMPAT_ENTRY);
if (ret)
return ret;
- ret = lttng_create_syscall_event_if_missing(compat_sc_exit_table, ARRAY_SIZE(compat_sc_exit_table),
+ ret = lttng_create_syscall_event_if_missing(compat_sc_exit_table.table, compat_sc_exit_table.len,
chan->compat_sc_exit_table, event_enabler, SC_TYPE_COMPAT_EXIT);
if (ret)
return ret;
if (!group->event_notifier_syscall_dispatch) {
group->event_notifier_syscall_dispatch =
- kzalloc(sizeof(struct hlist_head) * ARRAY_SIZE(sc_table),
+ kzalloc(sizeof(struct hlist_head) * sc_table.len,
GFP_KERNEL);
if (!group->event_notifier_syscall_dispatch)
return -ENOMEM;
/* Initialize all list_head */
- for (i = 0; i < ARRAY_SIZE(sc_table); i++)
+ for (i = 0; i < sc_table.len; i++)
INIT_HLIST_HEAD(&group->event_notifier_syscall_dispatch[i]);
/* Init the unknown syscall notifier list. */
if (!group->event_notifier_exit_syscall_dispatch) {
group->event_notifier_exit_syscall_dispatch =
- kzalloc(sizeof(struct hlist_head) * ARRAY_SIZE(sc_table),
+ kzalloc(sizeof(struct hlist_head) * sc_table.len,
GFP_KERNEL);
if (!group->event_notifier_exit_syscall_dispatch)
return -ENOMEM;
/* Initialize all list_head */
- for (i = 0; i < ARRAY_SIZE(sc_table); i++)
+ for (i = 0; i < sc_table.len; i++)
INIT_HLIST_HEAD(&group->event_notifier_exit_syscall_dispatch[i]);
/* Init the unknown exit syscall notifier list. */
#ifdef CONFIG_COMPAT
if (!group->event_notifier_compat_syscall_dispatch) {
group->event_notifier_compat_syscall_dispatch =
- kzalloc(sizeof(struct hlist_head) * ARRAY_SIZE(compat_sc_table),
+ kzalloc(sizeof(struct hlist_head) * compat_sc_table.len,
GFP_KERNEL);
if (!group->event_notifier_syscall_dispatch)
return -ENOMEM;
/* Initialize all list_head */
- for (i = 0; i < ARRAY_SIZE(compat_sc_table); i++)
+ for (i = 0; i < compat_sc_table.len; i++)
INIT_HLIST_HEAD(&group->event_notifier_compat_syscall_dispatch[i]);
/* Init the unknown syscall notifier list. */
if (!group->event_notifier_exit_compat_syscall_dispatch) {
group->event_notifier_exit_compat_syscall_dispatch =
- kzalloc(sizeof(struct hlist_head) * ARRAY_SIZE(compat_sc_exit_table),
+ kzalloc(sizeof(struct hlist_head) * compat_sc_exit_table.len,
GFP_KERNEL);
if (!group->event_notifier_exit_syscall_dispatch)
return -ENOMEM;
/* Initialize all list_head */
- for (i = 0; i < ARRAY_SIZE(compat_sc_exit_table); i++)
+ for (i = 0; i < compat_sc_exit_table.len; i++)
INIT_HLIST_HEAD(&group->event_notifier_exit_compat_syscall_dispatch[i]);
/* Init the unknown exit syscall notifier list. */
if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRY || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) {
ret = create_matching_event_notifiers(event_notifier_enabler,
- sc_table, ARRAY_SIZE(sc_table), SC_TYPE_ENTRY);
+ sc_table.table, sc_table.len, SC_TYPE_ENTRY);
if (ret)
goto end;
ret = create_matching_event_notifiers(event_notifier_enabler,
- compat_sc_table, ARRAY_SIZE(compat_sc_table),
+ compat_sc_table.table, compat_sc_table.len,
SC_TYPE_COMPAT_ENTRY);
if (ret)
goto end;
if (entryexit == LTTNG_KERNEL_ABI_SYSCALL_EXIT || entryexit == LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT) {
ret = create_matching_event_notifiers(event_notifier_enabler,
- sc_exit_table, ARRAY_SIZE(sc_exit_table),
+ sc_exit_table.table, sc_exit_table.len,
SC_TYPE_EXIT);
if (ret)
goto end;
goto end;
ret = create_matching_event_notifiers(event_notifier_enabler,
- compat_sc_exit_table, ARRAY_SIZE(compat_sc_exit_table),
+ compat_sc_exit_table.table, compat_sc_exit_table.len,
SC_TYPE_COMPAT_EXIT);
if (ret)
goto end;
int syscall_nr = -1;
int i;
- for (i = 0; i < ARRAY_SIZE(sc_table); i++) {
+ for (i = 0; i < sc_table.len; i++) {
const struct trace_syscall_entry *entry;
const char *it_name;
- entry = &sc_table[i];
+ entry = &sc_table.table[i];
if (!entry->desc)
continue;
it_name = entry->desc->event_name;
int syscall_nr = -1;
int i;
- for (i = 0; i < ARRAY_SIZE(compat_sc_table); i++) {
+ for (i = 0; i < compat_sc_table.len; i++) {
const struct trace_syscall_entry *entry;
const char *it_name;
- entry = &compat_sc_table[i];
+ entry = &compat_sc_table.table[i];
if (!entry->desc)
continue;
it_name = entry->desc->event_name;
static
uint32_t get_sc_tables_len(void)
{
- return ARRAY_SIZE(sc_table) + ARRAY_SIZE(compat_sc_table);
+ return sc_table.len + compat_sc_table.len;
}
static
const struct trace_syscall_entry *entry;
int iter = 0;
- for (entry = sc_table;
- entry < sc_table + ARRAY_SIZE(sc_table);
+ for (entry = sc_table.table;
+ entry < sc_table.table + sc_table.len;
entry++) {
if (iter++ >= *pos)
return entry;
}
- for (entry = compat_sc_table;
- entry < compat_sc_table + ARRAY_SIZE(compat_sc_table);
+ for (entry = compat_sc_table.table;
+ entry < compat_sc_table.table + compat_sc_table.len;
entry++) {
if (iter++ >= *pos)
return entry;
const struct trace_syscall_entry **table,
unsigned int *bitness)
{
- if (entry >= sc_table && entry < sc_table + ARRAY_SIZE(sc_table)) {
+ if (entry >= sc_table.table && entry < sc_table.table + sc_table.len) {
if (bitness)
*bitness = BITS_PER_LONG;
if (table)
- *table = sc_table;
+ *table = sc_table.table;
return 0;
}
- if (!(entry >= compat_sc_table
- && entry < compat_sc_table + ARRAY_SIZE(compat_sc_table))) {
+ if (!(entry >= compat_sc_table.table
+ && entry < compat_sc_table.table + compat_sc_table.len)) {
return -EINVAL;
}
if (bitness)
*bitness = 32;
if (table)
- *table = compat_sc_table;
+ *table = compat_sc_table.table;
return 0;
}
return ret;
if (!entry->desc)
return 0;
- if (table == sc_table) {
+ if (table == sc_table.table) {
index = entry - table;
name = &entry->desc->event_name[strlen(SYSCALL_ENTRY_STR)];
} else {
- index = (entry - table) + ARRAY_SIZE(sc_table);
+ index = (entry - table) + sc_table.len;
name = &entry->desc->event_name[strlen(COMPAT_SYSCALL_ENTRY_STR)];
}
seq_printf(m, "syscall { index = %lu; name = %s; bitness = %u; };\n",
return -ENOMEM;
filter = channel->sc_filter;
- for (bit = 0; bit < ARRAY_SIZE(sc_table); bit++) {
+ for (bit = 0; bit < sc_table.len; bit++) {
char state;
if (channel->sc_table) {
if (channel->compat_sc_table) {
if (!(READ_ONCE(channel->syscall_all_entry)
|| READ_ONCE(channel->syscall_all_exit)) && filter)
- state = test_bit(bit - ARRAY_SIZE(sc_table),
+ state = test_bit(bit - sc_table.len,
filter->sc_compat_entry)
- || test_bit(bit - ARRAY_SIZE(sc_table),
+ || test_bit(bit - sc_table.len,
filter->sc_compat_exit);
else
state = 1;