case LTTNG_DOMAIN_LOG4J:
case LTTNG_DOMAIN_JUL:
{
+ const char *default_event_name, *default_chan_name;
struct agent *agt;
struct lttng_event uevent;
struct lttng_domain tmp_dom;
memset(&uevent, 0, sizeof(uevent));
uevent.type = LTTNG_EVENT_TRACEPOINT;
uevent.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
- if (is_root) {
- strncpy(uevent.name, DEFAULT_SYS_JUL_EVENT_NAME,
- sizeof(uevent.name));
- } else {
- strncpy(uevent.name, DEFAULT_USER_JUL_EVENT_NAME,
- sizeof(uevent.name));
+ default_event_name = event_get_default_agent_ust_name(domain->type);
+ if (!default_event_name) {
+ ret = -LTTNG_ERR_FATAL;
+ goto error;
}
+ strncpy(uevent.name, default_event_name, sizeof(uevent.name));
uevent.name[sizeof(uevent.name) - 1] = '\0';
/*
memcpy(&tmp_dom, domain, sizeof(tmp_dom));
tmp_dom.type = LTTNG_DOMAIN_UST;
- ret = cmd_enable_event(session, &tmp_dom, DEFAULT_JUL_CHANNEL_NAME,
+ if (domain->type == LTTNG_DOMAIN_LOG4J) {
+ default_chan_name = DEFAULT_LOG4J_CHANNEL_NAME;
+ } else {
+ default_chan_name = DEFAULT_JUL_CHANNEL_NAME;
+ }
+
+ ret = cmd_enable_event(session, &tmp_dom, (char *) default_chan_name,
&uevent, filter_expression, filter, NULL, wpipe);
if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
goto error;
case LTTNG_DOMAIN_LOG4J:
case LTTNG_DOMAIN_JUL:
{
- struct agent *agt;
- struct lttng_event uevent, event;
- struct lttng_domain tmp_dom;
+ struct lttng_event event;
struct ltt_ust_session *usess = session->ust_session;
assert(usess);
- agt = trace_ust_find_agent(usess, domain->type);
- if (!agt) {
- agt = agent_create(domain->type);
- if (!agt) {
- ret = -LTTNG_ERR_NOMEM;
- goto error;
- }
- agent_add(agt, usess->agents);
- }
-
- /* Create the default tracepoint. */
- uevent.type = LTTNG_EVENT_TRACEPOINT;
- uevent.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
- if (is_root) {
- strncpy(uevent.name, DEFAULT_SYS_JUL_EVENT_NAME,
- sizeof(uevent.name));
- } else {
- strncpy(uevent.name, DEFAULT_USER_JUL_EVENT_NAME,
- sizeof(uevent.name));
- }
- uevent.name[sizeof(uevent.name) - 1] = '\0';
-
- /*
- * The domain type is changed because we are about to enable the
- * default channel and event for the JUL domain that are hardcoded.
- * This happens in the UST domain.
- */
- memcpy(&tmp_dom, domain, sizeof(tmp_dom));
- tmp_dom.type = LTTNG_DOMAIN_UST;
-
- ret = cmd_enable_event(session, &tmp_dom, DEFAULT_JUL_CHANNEL_NAME,
- &uevent, NULL, NULL, NULL, wpipe);
- if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
- goto error;
- }
-
event.loglevel = LTTNG_LOGLEVEL_JUL_ALL;
event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
strncpy(event.name, "*", sizeof(event.name));
event.name[sizeof(event.name) - 1] = '\0';
- ret = event_agent_enable_all(usess, agt, &event, filter);
- if (ret != LTTNG_OK) {
+ ret = cmd_enable_event(session, domain, NULL, &event,
+ filter_expression, filter, NULL, wpipe);
+ if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
goto error;
}
return ret;
}
+/*
+ * Return the agent default event name to use by testing if the process is root
+ * or not. Return NULL on error.
+ */
+const char *event_get_default_agent_ust_name(enum lttng_domain_type domain)
+{
+ const char *default_event_name = NULL;
+
+ if (domain == LTTNG_DOMAIN_JUL) {
+ if (is_root) {
+ default_event_name = DEFAULT_SYS_JUL_EVENT_NAME;
+ } else {
+ default_event_name = DEFAULT_USER_JUL_EVENT_NAME;
+ }
+ } else if (domain == LTTNG_DOMAIN_LOG4J) {
+ if (is_root) {
+ default_event_name = DEFAULT_SYS_LOG4J_EVENT_NAME;
+ } else {
+ default_event_name = DEFAULT_USER_LOG4J_EVENT_NAME;
+ }
+ } else {
+ assert(0);
+ }
+
+ return default_event_name;
+}
+
+
/*
* Disable a single agent event for a given UST session.
*
struct agent_event *aevent;
struct ltt_ust_event *uevent = NULL;
struct ltt_ust_channel *uchan = NULL;
- char *ust_event_name;
+ const char *ust_event_name;
assert(agt);
assert(usess);
goto error;
}
- if (is_root) {
- ust_event_name = DEFAULT_SYS_JUL_EVENT_NAME;
- } else {
- ust_event_name = DEFAULT_USER_JUL_EVENT_NAME;
+ ust_event_name = event_get_default_agent_ust_name(agt->domain);
+ if (!ust_event_name) {
+ ret = LTTNG_ERR_FATAL;
+ goto error;
}
/*
* with the loglevel type to ALL thus the loglevel stays 0. The event's
* filter is the one handling the loglevel for agent.
*/
- uevent = trace_ust_find_event(uchan->events, ust_event_name,
+ uevent = trace_ust_find_event(uchan->events, (char *) ust_event_name,
aevent->filter, 0, NULL);
/* If the agent event exists, it must be available on the UST side. */
assert(uevent);