#include <linux/in6.h>
#include <linux/seq_file.h>
#include <linux/stringify.h>
+#include <linux/file.h>
+#include <linux/anon_inodes.h>
#include <asm/ptrace.h>
#include <asm/syscall.h>
#include "lib/bitfield.h"
#include "wrapper/tracepoint.h"
+#include "wrapper/file.h"
#include "lttng-events.h"
#ifndef CONFIG_COMPAT
}
}
-/* noinline to diminish caller stack size */
+/*
+ * noinline to diminish caller stack size.
+ * Should be called with sessions lock held.
+ */
static
int fill_table(const struct trace_syscall_entry *table, size_t table_len,
struct lttng_event **chan_table, struct lttng_channel *chan,
strncat(ev.name, desc->name,
LTTNG_KERNEL_SYM_NAME_LEN - strlen(ev.name) - 1);
ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- ev.instrumentation = LTTNG_KERNEL_NOOP;
- chan_table[i] = lttng_event_create(chan, &ev, filter,
- desc);
+ ev.instrumentation = LTTNG_KERNEL_SYSCALL;
+ chan_table[i] = _lttng_event_create(chan, &ev, filter,
+ desc, ev.instrumentation);
WARN_ON_ONCE(!chan_table[i]);
if (IS_ERR(chan_table[i])) {
/*
return 0;
}
+/*
+ * Should be called with sessions lock held.
+ */
int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
{
struct lttng_kernel_event ev;
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- ev.instrumentation = LTTNG_KERNEL_NOOP;
- chan->sc_unknown = lttng_event_create(chan, &ev, filter,
- desc);
+ ev.instrumentation = LTTNG_KERNEL_SYSCALL;
+ chan->sc_unknown = _lttng_event_create(chan, &ev, filter,
+ desc,
+ ev.instrumentation);
WARN_ON_ONCE(!chan->sc_unknown);
if (IS_ERR(chan->sc_unknown)) {
return PTR_ERR(chan->sc_unknown);
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- ev.instrumentation = LTTNG_KERNEL_NOOP;
- chan->sc_compat_unknown = lttng_event_create(chan, &ev, filter,
- desc);
+ ev.instrumentation = LTTNG_KERNEL_SYSCALL;
+ chan->sc_compat_unknown = _lttng_event_create(chan, &ev, filter,
+ desc,
+ ev.instrumentation);
WARN_ON_ONCE(!chan->sc_unknown);
if (IS_ERR(chan->sc_compat_unknown)) {
return PTR_ERR(chan->sc_compat_unknown);
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- ev.instrumentation = LTTNG_KERNEL_NOOP;
- chan->compat_sc_exit_unknown = lttng_event_create(chan, &ev,
- filter, desc);
+ ev.instrumentation = LTTNG_KERNEL_SYSCALL;
+ chan->compat_sc_exit_unknown = _lttng_event_create(chan, &ev,
+ filter, desc,
+ ev.instrumentation);
WARN_ON_ONCE(!chan->compat_sc_exit_unknown);
if (IS_ERR(chan->compat_sc_exit_unknown)) {
return PTR_ERR(chan->compat_sc_exit_unknown);
memset(&ev, 0, sizeof(ev));
strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
- ev.instrumentation = LTTNG_KERNEL_NOOP;
- chan->sc_exit_unknown = lttng_event_create(chan, &ev, filter,
- desc);
+ ev.instrumentation = LTTNG_KERNEL_SYSCALL;
+ chan->sc_exit_unknown = _lttng_event_create(chan, &ev, filter,
+ desc, ev.instrumentation);
WARN_ON_ONCE(!chan->sc_exit_unknown);
if (IS_ERR(chan->sc_exit_unknown)) {
return PTR_ERR(chan->sc_exit_unknown);
filter = channel->sc_filter;
for (bit = 0; bit < ARRAY_SIZE(sc_table); bit++) {
- bt_bitfield_write_be(tmp_mask, char, bit, 1,
- filter ? test_bit(bit, filter->sc) : 1);
+ bool state;
+
+ if (channel->sc_table) {
+ if (filter)
+ state = test_bit(bit, filter->sc);
+ else
+ state = 1;
+ } else {
+ state = 0;
+ }
+ bt_bitfield_write_be(tmp_mask, char, bit, 1, state);
}
for (; bit < sc_tables_len; bit++) {
- bt_bitfield_write_be(tmp_mask, char, bit, 1,
- filter ? test_bit(bit - ARRAY_SIZE(sc_table),
- filter->sc_compat) : 1);
+ bool state;
+
+ if (channel->compat_sc_table) {
+ if (filter)
+ state = test_bit(bit - ARRAY_SIZE(sc_table),
+ filter->sc_compat);
+ else
+ state = 1;
+ } else {
+ state = 0;
+ }
+ bt_bitfield_write_be(tmp_mask, char, bit, 1, state);
}
if (copy_to_user(usyscall_mask->mask, tmp_mask, bitmask_len))
ret = -EFAULT;
kfree(tmp_mask);
return ret;
}
+
+int lttng_abi_syscall_list(void)
+{
+ struct file *syscall_list_file;
+ int file_fd, ret;
+
+ file_fd = lttng_get_unused_fd();
+ if (file_fd < 0) {
+ ret = file_fd;
+ goto fd_error;
+ }
+
+ syscall_list_file = anon_inode_getfile("[lttng_syscall_list]",
+ <tng_syscall_list_fops,
+ NULL, O_RDWR);
+ if (IS_ERR(syscall_list_file)) {
+ ret = PTR_ERR(syscall_list_file);
+ goto file_error;
+ }
+ ret = lttng_syscall_list_fops.open(NULL, syscall_list_file);
+ if (ret < 0)
+ goto open_error;
+ fd_install(file_fd, syscall_list_file);
+ if (file_fd < 0) {
+ ret = file_fd;
+ goto fd_error;
+ }
+ return file_fd;
+
+open_error:
+ fput(syscall_list_file);
+file_error:
+ put_unused_fd(file_fd);
+fd_error:
+ return ret;
+}