event->type = LTTNG_EVENT_SYSCALL;
}
+/*
+ * Return 1 if loglevels match or 0 on failure.
+ */
+static int loglevel_match(struct ltt_ust_event *uevent,
+ enum lttng_ust_loglevel_type log_type, int loglevel)
+{
+ /*
+ * For the loglevel type ALL, the loglevel is set to -1 but the event
+ * received by the session daemon is 0 which does not match the negative
+ * value in the existing event.
+ */
+ if (log_type == LTTNG_UST_LOGLEVEL_ALL) {
+ loglevel = -1;
+ }
+
+ if (uevent == NULL || uevent->attr.loglevel_type != log_type ||
+ uevent->attr.loglevel != loglevel) {
+ goto no_match;
+ }
+
+ return 1;
+
+no_match:
+ return 0;
+}
+
/*
* Disable kernel tracepoint event for a channel from the kernel session.
*/
int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
struct ltt_ust_channel *uchan)
{
- int ret, i;
- size_t size;
+ int ret, i, size;
struct lttng_ht_iter iter;
struct ltt_ust_event *uevent = NULL;
struct lttng_event *events = NULL;
to_create = 1;
}
+ /* Check loglevels */
+ ret = loglevel_match(uevent, event->loglevel_type, event->loglevel);
+ if (ret == 0) {
+ /*
+ * No match meaning that the user tried to enable a known event but
+ * with a different loglevel.
+ */
+ DBG("Enable event %s does not match existing event %s with loglevel "
+ "respectively of %d and %d", event->name, uevent->attr.name,
+ uevent->attr.loglevel, event->loglevel);
+ ret = LTTCOMM_EVENT_EXIST_LOGLEVEL;
+ goto error;
+ }
+
if (uevent->enabled) {
/* It's already enabled so everything is OK */
+ ret = LTTCOMM_OK;
goto end;
}
int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain,
struct ltt_ust_channel *uchan)
{
- int ret, i;
- size_t size;
+ int ret, i, size;
struct lttng_ht_iter iter;
struct ltt_ust_event *uevent = NULL;
struct lttng_event *events = NULL;