enum lttng_event_rule_type event_rule_type;
struct ltt_kernel_event_notifier_rule *event_notifier_rule;
struct lttng_kernel_event_notifier kernel_event_notifier = {};
+ unsigned int capture_bytecode_count = 0, i;
const struct lttng_condition *condition = NULL;
const struct lttng_event_rule *event_rule = NULL;
+ enum lttng_condition_status cond_status;
assert(trigger);
}
}
+ /* Set the capture bytecode, if any. */
+ cond_status = lttng_condition_event_rule_get_capture_descriptor_count(
+ condition, &capture_bytecode_count);
+ assert(cond_status == LTTNG_CONDITION_STATUS_OK);
+
+ for (i = 0; i < capture_bytecode_count; i++) {
+ const struct lttng_bytecode *capture_bytecode =
+ lttng_condition_event_rule_get_capture_bytecode_at_index(
+ condition, i);
+
+ if (capture_bytecode == NULL) {
+ ERR("Unexpected NULL capture bytecode on condition");
+ error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL;
+ goto error;
+ }
+
+ ret = kernctl_capture(event_notifier_rule->fd, capture_bytecode);
+ if (ret < 0) {
+ ERR("Failed to set capture bytecode on event notifier rule fd: fd = %d",
+ event_notifier_rule->fd);
+ error_code_ret = LTTNG_ERR_KERN_ENABLE_FAIL;
+ goto error;
+ }
+ }
+
err = kernctl_enable(event_notifier_rule->fd);
if (err < 0) {
switch (-err) {
break;
case LTTNG_DOMAIN_KERNEL:
token = kernel_notification.token;
- capture_buffer_size = 0;
+ capture_buffer_size = kernel_notification.capture_buf_size;
break;
default:
abort();
LTTNG_KERNEL_EVENT_NOTIFIER_CREATE, event_notifier);
}
+int kernctl_capture(int fd, const struct lttng_bytecode *capture)
+{
+ int ret;
+ struct lttng_kernel_capture_bytecode *kb;
+
+ /* Translate bytecode to kernel bytecode. */
+ kb = zmalloc(sizeof(*kb) + capture->len);
+ if (!kb) {
+ ret = -ENOMEM;
+ goto end;
+ }
+
+ kb->len = capture->len;
+ kb->reloc_offset = capture->reloc_table_offset;
+ kb->seqnum = capture->seqnum;
+ memcpy(kb->data, capture->data, capture->len);
+ ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_CAPTURE, kb);
+ free(kb);
+end:
+ return ret;
+}
+
int kernctl_filter(int fd, const struct lttng_bytecode *filter)
{
struct lttng_kernel_filter_bytecode *kb;
/* Apply on event file descriptor. */
int kernctl_filter(int fd, const struct lttng_bytecode *filter);
int kernctl_add_callsite(int fd, struct lttng_kernel_event_callsite *callsite);
+int kernctl_capture(int fd, const struct lttng_bytecode *capture);
int kernctl_tracepoint_list(int fd);
int kernctl_syscall_list(int fd);
#define LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD \
_IO(0xF6, 0xB1)
+/* Trigger file descriptor ioctl */
+#define LTTNG_KERNEL_CAPTURE _IO(0xF6, 0xB8)
+
#endif /* _LTT_KERNEL_IOCTL_H */
char padding[LTTNG_KERNEL_EVENT_NOTIFIER_PADDING];
} LTTNG_PACKED;
-#define LTTNG_KERNEL_EVENT_NOTIFIER_NOTIFICATION_PADDING 34
+#define LTTNG_KERNEL_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
struct lttng_kernel_event_notifier_notification {
uint64_t token;
+ uint16_t capture_buf_size;
char padding[LTTNG_KERNEL_EVENT_NOTIFIER_NOTIFICATION_PADDING];
} LTTNG_PACKED;
+#define LTTNG_KERNEL_CAPTURE_BYTECODE_MAX_LEN 65536
+struct lttng_kernel_capture_bytecode {
+ uint32_t len;
+ uint32_t reloc_offset;
+ uint64_t seqnum;
+ char data[0];
+} LTTNG_PACKED;
+
struct lttng_kernel_tracer_version {
uint32_t major;
uint32_t minor;