--- /dev/null
+#ifndef _LTTNG_ALIGN_H
+#define _LTTNG_ALIGN_H
+
+/*
+ * align.h
+ *
+ * (C) Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include "bug.h"
+#include <unistd.h>
+#include <limits.h>
+
+#ifndef PAGE_SIZE /* Cygwin limits.h defines its own PAGE_SIZE */
+#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
+#endif
+
+#define PAGE_MASK (~(PAGE_SIZE - 1))
+#define __ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask))
+#define ALIGN(v, align) __ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
+#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
+
+/**
+ * offset_align - Calculate the offset needed to align an object on its natural
+ * alignment towards higher addresses.
+ * @align_drift: object offset from an "alignment"-aligned address.
+ * @alignment: natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be added to align towards higher
+ * addresses.
+ */
+#define offset_align(align_drift, alignment) \
+ ({ \
+ LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
+ || ((alignment) & ((alignment) - 1))); \
+ (((alignment) - (align_drift)) & ((alignment) - 1)); \
+ })
+
+/**
+ * offset_align_floor - Calculate the offset needed to align an object
+ * on its natural alignment towards lower addresses.
+ * @align_drift: object offset from an "alignment"-aligned address.
+ * @alignment: natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be substracted to align towards lower addresses.
+ */
+#define offset_align_floor(align_drift, alignment) \
+ ({ \
+ LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
+ || ((alignment) & ((alignment) - 1))); \
+ (((align_drift) - (alignment)) & ((alignment) - 1); \
+ })
+
+#endif /* _LTTNG_ALIGN_H */
--- /dev/null
+#ifndef _LTTNG_BUG_H
+#define _LTTNG_BUG_H
+
+/*
+ * lttng/bug.h
+ *
+ * (C) Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ */
+
+#include <urcu/compiler.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define LTTNG_BUG_ON(condition) \
+ do { \
+ if (caa_unlikely(condition)) { \
+ fprintf(stderr, \
+ "LTTng BUG in file %s, line %d.\n", \
+ __FILE__, __LINE__); \
+ exit(EXIT_FAILURE); \
+ } \
+ } while (0)
+
+#define LTTNG_BUILD_BUG_ON(condition) \
+ ((void) sizeof(char[-!!(condition)]))
+
+/**
+ * LTTNG_BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
+ * @condition: the condition which should be false.
+ *
+ * If the condition is a constant and true, the compiler will generate a build
+ * error. If the condition is not constant, a BUG will be triggered at runtime
+ * if the condition is ever true. If the condition is constant and false, no
+ * code is emitted.
+ */
+#define LTTNG_BUILD_RUNTIME_BUG_ON(condition) \
+ do { \
+ if (__builtin_constant_p(condition)) \
+ LTTNG_BUILD_BUG_ON(condition); \
+ else \
+ LTTNG_BUG_ON(condition); \
+ } while (0)
+
+#endif
#define __USE_LINUX_IOCTL_DEFS
#include <sys/ioctl.h>
#include <string.h>
+#include <common/align.h>
#include "kernel-ctl.h"
#include "kernel-ioctl.h"
return ioctl(fd, LTTNG_KERNEL_EVENT, &event);
}
+int kernctl_syscall_mask(int fd, char **syscall_mask, uint32_t *nr_bits)
+{
+ struct lttng_kernel_syscall_mask kmask_len, *kmask = NULL;
+ size_t array_alloc_len;
+ char *new_mask;
+ int ret = 0;
+
+ if (!syscall_mask) {
+ ret = -1;
+ goto end;
+ }
+
+ if (!nr_bits) {
+ ret = -1;
+ goto end;
+ }
+
+ kmask_len.len = 0;
+ ret = ioctl(fd, LTTNG_KERNEL_SYSCALL_MASK, &kmask_len);
+ if (ret) {
+ goto end;
+ }
+
+ array_alloc_len = ALIGN(kmask_len.len, 8) >> 3;
+ kmask = zmalloc(sizeof(*kmask) + array_alloc_len);
+ if (!kmask) {
+ ret = -1;
+ goto end;
+ }
+
+ kmask->len = kmask_len.len;
+ ret = ioctl(fd, LTTNG_KERNEL_SYSCALL_MASK, kmask);
+ if (ret) {
+ goto end;
+ }
+
+ new_mask = realloc(syscall_mask, array_alloc_len);
+ if (!new_mask) {
+ ret = -1;
+ goto end;
+ }
+ memcpy(new_mask, kmask->mask, array_alloc_len);
+ *syscall_mask = new_mask;
+ *nr_bits = kmask->len;
+
+end:
+ free(kmask);
+ return ret;
+}
+
int kernctl_create_stream(int fd)
{
return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_STREAM,
int kernctl_enable_syscall(int fd, const char *syscall_name);
int kernctl_disable_syscall(int fd, const char *syscall_name);
+/*
+ * kernctl_syscall_mask - Get syscall mask associated to a channel FD.
+ *
+ * The parameter @syscall_mask should initially be either NULL or point
+ * to memory allocated with malloc(3) or realloc(3). When the function
+ * returns, it will point to a memory area of the size required for the
+ * bitmask (using realloc(3) to resize the memory).
+ *
+ * It returns 0 if OK, -1 on error. In all cases (error and OK),
+ * @syscall_mask should be freed by the caller with free(3).
+ */
+int kernctl_syscall_mask(int fd, char **syscall_mask,
+ uint32_t *nr_bits);
+
/* Buffer operations */
/* For mmap mode, readable without "get" operation */
} LTTNG_PACKED;
struct lttng_kernel_syscall_mask {
- uint32_t len;
+ uint32_t len; /* in bits */
char mask[];
} LTTNG_PACKED;
+++ /dev/null
-#ifndef _LTTNG_ALIGN_H
-#define _LTTNG_ALIGN_H
-
-/*
- * align.h
- *
- * (C) Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#include "bug.h"
-#include <unistd.h>
-#include <limits.h>
-
-#ifndef PAGE_SIZE /* Cygwin limits.h defines its own PAGE_SIZE */
-#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
-#endif
-
-#define PAGE_MASK (~(PAGE_SIZE - 1))
-#define __ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask))
-#define ALIGN(v, align) __ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
-#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
-
-/**
- * offset_align - Calculate the offset needed to align an object on its natural
- * alignment towards higher addresses.
- * @align_drift: object offset from an "alignment"-aligned address.
- * @alignment: natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be added to align towards higher
- * addresses.
- */
-#define offset_align(align_drift, alignment) \
- ({ \
- LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
- || ((alignment) & ((alignment) - 1))); \
- (((alignment) - (align_drift)) & ((alignment) - 1)); \
- })
-
-/**
- * offset_align_floor - Calculate the offset needed to align an object
- * on its natural alignment towards lower addresses.
- * @align_drift: object offset from an "alignment"-aligned address.
- * @alignment: natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be substracted to align towards lower addresses.
- */
-#define offset_align_floor(align_drift, alignment) \
- ({ \
- LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
- || ((alignment) & ((alignment) - 1))); \
- (((align_drift) - (alignment)) & ((alignment) - 1); \
- })
-
-#endif /* _LTTNG_ALIGN_H */
+++ /dev/null
-#ifndef _LTTNG_BUG_H
-#define _LTTNG_BUG_H
-
-/*
- * lttng/bug.h
- *
- * (C) Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- */
-
-#include <urcu/compiler.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define LTTNG_BUG_ON(condition) \
- do { \
- if (caa_unlikely(condition)) { \
- fprintf(stderr, \
- "LTTng BUG in file %s, line %d.\n", \
- __FILE__, __LINE__); \
- exit(EXIT_FAILURE); \
- } \
- } while (0)
-
-#define LTTNG_BUILD_BUG_ON(condition) \
- ((void) sizeof(char[-!!(condition)]))
-
-/**
- * LTTNG_BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
- * @condition: the condition which should be false.
- *
- * If the condition is a constant and true, the compiler will generate a build
- * error. If the condition is not constant, a BUG will be triggered at runtime
- * if the condition is ever true. If the condition is constant and false, no
- * code is emitted.
- */
-#define LTTNG_BUILD_RUNTIME_BUG_ON(condition) \
- do { \
- if (__builtin_constant_p(condition)) \
- LTTNG_BUILD_BUG_ON(condition); \
- else \
- LTTNG_BUG_ON(condition); \
- } while (0)
-
-#endif
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include "align.h"
+#include <common/align.h>
+
#include "filter-bytecode.h"
#include "filter-ir.h"
#include "filter-ast.h"