/* The wild card * means that everything should be enabled. */
if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) {
- ret = event_jul_enable_all(usess, event);
+ ret = event_jul_enable_all(usess, event, filter);
} else {
- ret = event_jul_enable(usess, event);
+ ret = event_jul_enable(usess, event, filter);
}
if (ret != LTTNG_OK) {
goto error;
strncpy(event.name, "*", sizeof(event.name));
event.name[sizeof(event.name) - 1] = '\0';
- ret = event_jul_enable_all(usess, &event);
+ ret = event_jul_enable_all(usess, &event, filter);
if (ret != LTTNG_OK) {
goto error;
}
#include "channel.h"
#include "event.h"
#include "kernel.h"
+#include "lttng-sessiond.h"
#include "ust-ctl.h"
#include "ust-app.h"
#include "trace-kernel.h"
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
int event_jul_enable_all(struct ltt_ust_session *usess,
- struct lttng_event *event)
+ struct lttng_event *event, struct lttng_filter_bytecode *filter)
{
int ret;
struct jul_event *jevent;
DBG("Event JUL enabling ALL events for session %" PRIu64, usess->id);
/* Enable event on JUL application through TCP socket. */
- ret = event_jul_enable(usess, event);
+ ret = event_jul_enable(usess, event, filter);
if (ret != LTTNG_OK) {
goto error;
}
*
* Return LTTNG_OK on success or else a LTTNG_ERR* code.
*/
-int event_jul_enable(struct ltt_ust_session *usess, struct lttng_event *event)
+int event_jul_enable(struct ltt_ust_session *usess, struct lttng_event *event,
+ struct lttng_filter_bytecode *filter)
{
int ret, created = 0;
struct jul_event *jevent;
}
jevent->loglevel = event->loglevel;
jevent->loglevel_type = event->loglevel_type;
+ jevent->filter = filter;
created = 1;
}
int event_jul_disable(struct ltt_ust_session *usess, char *event_name)
{
int ret;
+ char *ust_event_name;
struct jul_event *jevent;
+ struct ltt_ust_event *uevent = NULL;
+ struct ltt_ust_channel *uchan = NULL;
assert(usess);
assert(event_name);
goto end;
}
+ /*
+ * Disable it on the UST side. First get the channel reference then find
+ * the event and finally disable it.
+ */
+ uchan = trace_ust_find_channel_by_name(usess->domain_global.channels,
+ DEFAULT_JUL_CHANNEL_NAME);
+ if (!uchan) {
+ ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
+ goto error;
+ }
+
+ if (is_root) {
+ ust_event_name = DEFAULT_SYS_JUL_EVENT_NAME;
+ } else {
+ ust_event_name = DEFAULT_USER_JUL_EVENT_NAME;
+ }
+
+ /*
+ * The loglevel is hardcoded with 0 here since the agent ust event is set
+ * 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,
+ jevent->filter, 0, NULL);
+ /* If the agent event exists, it must be available on the UST side. */
+ assert(uevent);
+
+ ret = ust_app_disable_event_glb(usess, uchan, uevent);
+ if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) {
+ ret = LTTNG_ERR_UST_DISABLE_FAIL;
+ goto error;
+ }
+ uevent->enabled = 0;
+
ret = jul_disable_event(jevent);
if (ret != LTTNG_OK) {
goto error;
error:
return ret;
}
+
/*
* Disable all JUL event for a given UST session.
*
*/
int event_jul_disable_all(struct ltt_ust_session *usess)
{
- int ret, do_disable = 0;
+ int ret;
struct jul_event *jevent;
struct lttng_ht_iter iter;
/* Enable event on JUL application through TCP socket. */
ret = event_jul_disable(usess, "*");
- if (ret != LTTNG_OK) {
- if (ret == LTTNG_ERR_UST_EVENT_NOT_FOUND) {
- /*
- * This means that no enable all was done before but still a user
- * could want to disable everything even though the * wild card
- * event does not exists.
- */
- do_disable = 1;
- } else {
- goto error;
- }
+ if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_NOT_FOUND) {
+ goto error;
}
/* Flag every event that they are now enabled. */
rcu_read_lock();
cds_lfht_for_each_entry(usess->domain_jul.events->ht, &iter.iter, jevent,
node.node) {
- if (jevent->enabled && do_disable) {
- ret = event_jul_disable(usess, jevent->name);
- if (ret != LTTNG_OK) {
- rcu_read_unlock();
- goto error;
- }
+ if (!jevent->enabled) {
+ continue;
+ }
+
+ ret = event_jul_disable(usess, jevent->name);
+ if (ret != LTTNG_OK) {
+ rcu_read_unlock();
+ goto error;
}
- jevent->enabled = 0;
}
rcu_read_unlock();
int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess,
struct ltt_ust_channel *uchan);
-int event_jul_enable(struct ltt_ust_session *usess, struct lttng_event *event);
+int event_jul_enable(struct ltt_ust_session *usess, struct lttng_event *event,
+ struct lttng_filter_bytecode *filter);
int event_jul_enable_all(struct ltt_ust_session *usess,
- struct lttng_event *event);
+ struct lttng_event *event, struct lttng_filter_bytecode *filter);
int event_jul_disable(struct ltt_ust_session *usess, char *event_name);
int event_jul_disable_all(struct ltt_ust_session *usess);
fi
}
+function test_jul_disable()
+{
+ diag "Test JUL disable event"
+
+ create_lttng_session $SESSION_NAME $TRACE_PATH/$SESSION_NAME
+ # Enable all event with a filter.
+ enable_jul_lttng_event $SESSION_NAME $EVENT_NAME
+ enable_jul_lttng_event $SESSION_NAME $EVENT_NAME2
+ disable_jul_lttng_event $SESSION_NAME $EVENT_NAME
+ start_lttng_tracing $SESSION_NAME
+
+ # Fire second TP but not the finest one.
+ run_app 0 1
+ wait_apps
+
+ stop_lttng_tracing $SESSION_NAME
+ destroy_lttng_session $SESSION_NAME
+
+ # Validate test. Expecting one event of the second TP only.
+ trace_match_only $EVENT_NAME2 1 $TRACE_PATH/$SESSION_NAME
+ if [ $? -ne 0 ]; then
+ return $?
+ fi
+}
+
plan_tests $NUM_TESTS
print_test_banner "$TEST_DESC"
start_lttng_sessiond
tests=(
+ test_jul_disable
test_jul_multi_session_loglevel
test_jul_destroy_session
test_jul_loglevel
if [ $? -ne 0 ]; then
break;
fi
- rm -rf $TRACE_PATH
+ #rm -rf $TRACE_PATH
done
stop_lttng_sessiond
ok $? "Disable event $event_name for session $sess_name"
}
+function disable_jul_lttng_event ()
+{
+ local sess_name="$1"
+ local event_name="$2"
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event "$event_name" -s $sess_name -j >/dev/null 2>&1
+ ok $? "Disable JUL event $event_name for session $sess_name"
+}
+
function start_lttng_tracing ()
{
sess_name=$1
IFS=$OLDIFS
return $ret
}
+
+function trace_match_only()
+{
+ local event_name=$1
+ local nr_iter=$2
+ local trace_path=$3
+
+ which $BABELTRACE_BIN >/dev/null
+ skip $? -ne 0 "Babeltrace binary not found. Skipping trace matches"
+
+ local count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
+ local total=$($BABELTRACE_BIN $trace_path | wc -l)
+
+ if [ "$nr_iter" -eq "$count" ] && [ "$total" -eq "$nr_iter" ]; then
+ pass "Trace match with $total event $event_name"
+ else
+ fail "Trace match"
+ diag "$total event(s) found, expecting $nr_iter of event $event_name and only found $count"
+ fi
+}