/* For lttng_domain_type_str(). */
#include "lttng/domain-internal.h"
#include "../loglevel.h"
+#include <lttng/lttng.h>
#ifdef LTTNG_EMBED_HELP
static const char help_msg[] =
const struct lttng_event_rule *event_rule;
enum lttng_condition_status condition_status;
unsigned int cap_desc_count, i;
- uint64_t error_count;
condition_status =
lttng_condition_on_event_get_rule(condition, &event_rule);
condition, &cap_desc_count);
assert(condition_status == LTTNG_CONDITION_STATUS_OK);
- error_count = lttng_condition_on_event_get_error_count(condition);
- MSG(" tracer notifications discarded: %" PRIu64, error_count);
-
if (cap_desc_count > 0) {
MSG(" captures:");
}
static
-void print_one_action(const struct lttng_action *action)
+void print_action_errors(const struct lttng_trigger *trigger,
+ const struct lttng_action *action)
+{
+ unsigned int i, count, printed_errors_count = 0;
+ enum lttng_error_code error_query_ret;
+ enum lttng_error_query_results_status results_status;
+ struct lttng_error_query_results *results = NULL;
+ const char *trigger_name;
+ uid_t trigger_uid;
+ enum lttng_trigger_status trigger_status;
+ struct lttng_error_query *query =
+ lttng_error_query_action_create(trigger, action);
+
+ assert(query);
+
+ trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
+ assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
+ assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+ error_query_ret = lttng_error_query_execute(
+ query, lttng_session_daemon_command_endpoint, &results);
+ if (error_query_ret != LTTNG_OK) {
+ ERR("Failed to query errors of trigger '%s' (owner uid: %d): %s",
+ trigger_name, (int) trigger_uid,
+ lttng_strerror(-error_query_ret));
+ goto end;
+ }
+
+ results_status = lttng_error_query_results_get_count(results, &count);
+ assert(results_status == LTTNG_ERROR_QUERY_RESULTS_STATUS_OK);
+
+ _MSG(" errors:");
+
+ for (i = 0; i < count; i++) {
+ const struct lttng_error_query_result *result;
+ enum lttng_error_query_result_status result_status;
+ const char *result_name;
+ const char *result_description;
+ uint64_t result_value;
+
+ results_status = lttng_error_query_results_get_result(
+ results, &result, i);
+ assert(results_status == LTTNG_ERROR_QUERY_RESULTS_STATUS_OK);
+
+ result_status = lttng_error_query_result_get_name(
+ result, &result_name);
+ assert(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+ result_status = lttng_error_query_result_get_description(
+ result, &result_description);
+ assert(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+
+ if (lttng_error_query_result_get_type(result) ==
+ LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER) {
+ result_status = lttng_error_query_result_counter_get_value(
+ result, &result_value);
+ assert(result_status ==
+ LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+ if (result_value == 0) {
+ continue;
+ }
+
+ MSG("");
+ _MSG(" %s: %" PRIu64, result_name,
+ result_value);
+ printed_errors_count++;
+ } else {
+ _MSG(" Unknown error query result type for result '%s' (%s)",
+ result_name, result_description);
+ continue;
+ }
+ }
+
+ if (printed_errors_count == 0) {
+ _MSG(" none");
+ }
+
+end:
+ MSG("");
+ lttng_error_query_destroy(query);
+ lttng_error_query_results_destroy(results);
+}
+
+static
+void print_one_action(const struct lttng_trigger *trigger,
+ const struct lttng_action *action)
{
enum lttng_action_type action_type;
enum lttng_action_status action_status;
}
MSG("");
+ print_action_errors(trigger, action);
+
end:
return;
}
+static
+void print_trigger_errors(const struct lttng_trigger *trigger)
+{
+ unsigned int i, count, printed_errors_count = 0;
+ enum lttng_error_code error_query_ret;
+ enum lttng_error_query_results_status results_status;
+ struct lttng_error_query_results *results = NULL;
+ enum lttng_trigger_status trigger_status;
+ const char *trigger_name;
+ uid_t trigger_uid;
+ struct lttng_error_query *query =
+ lttng_error_query_trigger_create(trigger);
+
+ assert(query);
+
+ trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
+ assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
+ assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+ error_query_ret = lttng_error_query_execute(
+ query, lttng_session_daemon_command_endpoint, &results);
+ if (error_query_ret != LTTNG_OK) {
+ ERR("Failed to query errors of trigger '%s' (owner uid: %d): %s",
+ trigger_name, (int) trigger_uid,
+ lttng_strerror(-error_query_ret));
+ goto end;
+ }
+
+ results_status = lttng_error_query_results_get_count(results, &count);
+ assert(results_status == LTTNG_ERROR_QUERY_RESULTS_STATUS_OK);
+
+ _MSG(" errors:");
+
+ for (i = 0; i < count; i++) {
+ const struct lttng_error_query_result *result;
+ enum lttng_error_query_result_status result_status;
+ const char *result_name;
+ const char *result_description;
+ uint64_t result_value;
+
+ results_status = lttng_error_query_results_get_result(
+ results, &result, i);
+ assert(results_status == LTTNG_ERROR_QUERY_RESULTS_STATUS_OK);
+
+ result_status = lttng_error_query_result_get_name(
+ result, &result_name);
+ assert(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+ result_status = lttng_error_query_result_get_description(
+ result, &result_description);
+ assert(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+
+ if (lttng_error_query_result_get_type(result) ==
+ LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER) {
+ result_status = lttng_error_query_result_counter_get_value(
+ result, &result_value);
+ assert(result_status ==
+ LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+ if (result_value == 0) {
+ continue;
+ }
+
+ MSG("");
+ _MSG(" %s: %" PRIu64, result_name,
+ result_value);
+ printed_errors_count++;
+ } else {
+ _MSG(" Unknown error query result type for result '%s' (%s)",
+ result_name, result_description);
+ continue;
+ }
+ }
+
+ if (printed_errors_count == 0) {
+ _MSG(" none");
+ }
+
+end:
+ MSG("");
+ lttng_error_query_destroy(query);
+ lttng_error_query_results_destroy(results);
+}
+
static
void print_one_trigger(const struct lttng_trigger *trigger)
{
action, i);
_MSG(" ");
- print_one_action(subaction);
+ print_one_action(trigger, subaction);
}
} else {
_MSG(" action:");
- print_one_action(action);
+ print_one_action(trigger, action);
}
+ print_trigger_errors(trigger);
}
static
FULL_LTTNG_BIN="${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}"
FULL_LTTNG_SESSIOND_BIN="${TESTDIR}/../src/bin/lttng-sessiond/lttng-sessiond"
-UST_NUM_TESTS=16
-KERNEL_NUM_TESTS=15
+UST_NUM_TESTS=18
+KERNEL_NUM_TESTS=17
NUM_TESTS=$(($UST_NUM_TESTS + $KERNEL_NUM_TESTS))
plan_tests $NUM_TESTS
"$FULL_LTTNG_BIN" list-triggers > "$list_triggers_stdout"
- # Confirm that the discarded notification line is present.
- cat "$list_triggers_stdout" | grep --quiet "tracer notifications discarded: 0"
- ok $? "No discarded tracer notification"
+ # Confirm that the discarded notification line is not present.
+ cat "$list_triggers_stdout" | grep -v --quiet "discarded tracer messages"
+ ok $? "No discarded tracer notification message"
+
+ tail -n 1 "$list_triggers_stdout" | grep --quiet "errors: none"
+ ok $? "Trigger 'errors: none' notification message"
# Stop consumption of notifier tracer notifications.
+ diag "Pause consumption of tracer messages"
echo -n 1 > $sessiond_pipe
# The notifier ring buffer configuration is currently made of 16 4096
# Confirm that the discarded notification line is present. To avoid
# false positives.
- cat "$list_triggers_stdout" | grep --quiet "tracer notifications discarded"
+ cat "$list_triggers_stdout" | grep --quiet "dicarded tracer messages"
ok $? "Tracer notification discarded line printed"
- # Confirm that the number of tracer notifications discarded is not zero.
- cat "$list_triggers_stdout" | grep --quiet "tracer notifications discarded: 0"
+ # Confirm that the number of dicarded tracer messages is not zero.
+ cat "$list_triggers_stdout" | grep --quiet "dicarded tracer messages: 0"
isnt $? 0 "Discarded tracer notification number non-zero as expected"
lttng_remove_trigger_ok "$trigger_name"
--condition on-event --kernel lttng_test_filter_event \
--action notify
- # Confirm that the discarded notification line is present.
- "$FULL_LTTNG_BIN" list-triggers > "$list_triggers_stdout"
- cat "$list_triggers_stdout" | grep --quiet "tracer notifications discarded: 0"
- ok $? "No discarded tracer notification"
+ # Confirm that the discarded notification line is not present.
+ cat "$list_triggers_stdout" | grep -v --quiet "discarded tracer messages"
+ ok $? "No discarded tracer notification message"
+
+ tail -n 1 "$list_triggers_stdout" | grep --quiet "errors: none"
+ ok $? "Trigger 'errors: none' notification message"
lttng_remove_trigger_ok "$trigger_name"
"$FULL_LTTNG_BIN" list-triggers > "$list_triggers_stdout"
- # Confirm that the discarded notification line is present.
- cat "$list_triggers_stdout" | grep --quiet "tracer notifications discarded: 0"
- ok $? "No discarded tracer notification"
+ # Confirm that the discarded notification line is not present.
+ cat "$list_triggers_stdout" | grep -v --quiet "discarded tracer messages"
+ ok $? "No discarded tracer notification message"
+
+ tail -n 1 "$list_triggers_stdout" | grep --quiet "errors: none"
+ ok $? "Trigger 'errors: none' notification message"
# Stop consumption of notifier tracer notifications.
+ diag "Pause consumption of tracer messages"
echo -n 1 > $sessiond_pipe
$TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT
# Confirm that the discarded notification line is present. To avoid
# false positive.
- cat "$list_triggers_stdout" | grep --quiet "tracer notifications discarded"
+ cat "$list_triggers_stdout" | grep --quiet "discarded tracer messages"
ok $? "Tracer notification discarded line printed"
- # Confirm that the number of tracer notifications discarded is not zero.
- cat "$list_triggers_stdout" | grep --quiet "tracer notifications discarded: 0"
+ # Confirm that the number of discarded tracer messages is not zero.
+ cat "$list_triggers_stdout" | grep --quiet "discarded tracer messages: 0"
isnt $? 0 "Discarded tracer notification number non-zero as expected"
# Remove the notifier.
--condition on-event --userspace tp:tptest \
--action notify
- # Confirm that the discarded notification line is present.
+ # Confirm that the discarded notification line is not present.
"$FULL_LTTNG_BIN" list-triggers > "$list_triggers_stdout"
- cat "$list_triggers_stdout" | grep --quiet "tracer notifications discarded: 0"
- ok $? "No discarded tracer notification"
+
+ # Confirm that the discarded notification line is not present.
+ cat "$list_triggers_stdout" | grep -v --quiet "discarded tracer messages"
+ ok $? "No discarded tracer notification message"
+
+ tail -n 1 "$list_triggers_stdout" | grep --quiet "errors: none"
+ ok $? "Trigger 'errors: none' notification message"
lttng_remove_trigger_ok "$trigger_name"
user id: ${uid}
condition: event rule hit
rule: test-id (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
EOF
list_triggers "top level options" "${tmp_expected_stdout}"
user id: ${uid}
condition: event rule hit
rule: aaa (type: tracepoint, domain: ust, filter: p == 2)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
- id: B
user id: ${uid}
condition: event rule hit
rule: gerboise (type: tracepoint, domain: ust, log level at least INFO)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
- id: C
user id: ${uid}
condition: event rule hit
rule: * (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
- id: D
user id: ${uid}
condition: event rule hit
rule: hello* (type: tracepoint, domain: ust, exclusions: hello2,hello3,hello4)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
- id: E
user id: ${uid}
condition: event rule hit
rule: lemming (type: tracepoint, domain: ust, log level is WARNING)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
- id: F
user id: ${uid}
condition: event rule hit
rule: capture-payload-field (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
captures:
- a
actions:
notify
+ errors: none
+ errors: none
- id: G
user id: ${uid}
condition: event rule hit
rule: capture-array (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
captures:
- a[2]
- \$ctx.tourlou[18]
actions:
notify
+ errors: none
+ errors: none
- id: H
user id: ${uid}
condition: event rule hit
rule: capture-chan-ctx (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
captures:
- \$ctx.vpid
actions:
notify
+ errors: none
+ errors: none
- id: I
user id: ${uid}
condition: event rule hit
rule: capture-app-ctx (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
captures:
- \$app.iga:active_clients
actions:
notify
+ errors: none
+ errors: none
EOF
list_triggers "on-event, tracepoint event rule" "${tmp_expected_stdout}"
user id: ${uid}
condition: event rule hit
rule: my_channel_enable (type: probe, location: lttng_channel_enable)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
- id: T1
user id: ${uid}
condition: event rule hit
rule: my_channel_enable (type: probe, location: ${base_symbol}+${offset_hex})
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
- id: T2
user id: ${uid}
condition: event rule hit
rule: my_channel_enable (type: probe, location: 0x${channel_enable_addr})
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
EOF
list_triggers "on-event, probe event rule" "${tmp_expected_stdout}"
user id: ${uid}
condition: event rule hit
rule: ma-probe (type: userspace probe, location: ${uprobe_elf_binary}:test_function)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
EOF
list_triggers "on-event, userspace-probe event rule" "${tmp_expected_stdout}"
user id: ${uid}
condition: event rule hit
rule: open (type: syscall)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
- id: T1
user id: ${uid}
condition: event rule hit
rule: ptrace (type: syscall, filter: a > 2)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
EOF
list_triggers "on-event, syscall event rule" "${tmp_expected_stdout}"
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`
+ errors: none
+ errors: none
- id: T1
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`, path: /some/path
+ errors: none
+ errors: none
- id: T2
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`, path: /some/other/path
+ errors: none
+ errors: none
- id: T3
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`, url: net://1.2.3.4
+ errors: none
+ errors: none
- id: T4
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`, url: net://1.2.3.4:1234:1235
+ errors: none
+ errors: none
- id: T5
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`, control url: tcp://1.2.3.4:1111, data url: tcp://1.2.3.4:1112
+ errors: none
+ errors: none
- id: T6
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`, path: /some/path, max size: 1234
+ errors: none
+ errors: none
- id: T7
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`, path: /some/path, name: meh
+ errors: none
+ errors: none
- id: T8
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`, rate policy: after every 10 occurrences
+ errors: none
+ errors: none
- id: T9
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
snapshot session \`ze-session\`, rate policy: once after 10 occurrences
+ errors: none
+ errors: none
EOF
list_triggers "snapshot action" "${tmp_expected_stdout}"
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
notify, rate policy: once after 5 occurrences
+ errors: none
+ errors: none
- id: T1
user id: ${uid}
condition: event rule hit
rule: some-event (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
notify, rate policy: after every 10 occurrences
+ errors: none
+ errors: none
EOF
list_triggers "snapshot action" "${tmp_expected_stdout}"
user id: ${uid}
condition: event rule hit
rule: aaa (type: tracepoint, domain: ust, filter: p == 2)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
- id: DEF
user id: ${uid}
condition: event rule hit
rule: * (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
EOF
list_triggers "two triggers left" "${tmp_expected_stdout}"
user id: ${uid}
condition: event rule hit
rule: * (type: tracepoint, domain: ust)
- tracer notifications discarded: 0
actions:
notify
+ errors: none
+ errors: none
EOF
list_triggers "one trigger left" "${tmp_expected_stdout}"