/* 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[] =
goto end;
}
- _MSG(" rule: %s (type: userspace probe, location: ", name);
+ _MSG(" rule: %s (type: userspace probe, ", name);
userspace_probe_location_type =
lttng_userspace_probe_location_get_type(location);
function_name = lttng_userspace_probe_location_function_get_function_name(
location);
- _MSG("%s:%s", binary_path, function_name);
+ _MSG("location type: ELF, location: %s:%s", binary_path, function_name);
break;
}
case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
- _MSG("SDT not implemented yet");
+ {
+ const char *binary_path, *provider_name, *probe_name;
+
+ binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(
+ location);
+ provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(
+ location);
+ probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(
+ location);
+ _MSG("location type: SDT, location: %s:%s:%s", binary_path, provider_name, probe_name);
break;
+ }
default:
abort();
}
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: %ld", 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;
+ const struct lttng_rate_policy *policy = NULL;
const char *value;
action_type = lttng_action_get_type(action);
switch (action_type) {
case LTTNG_ACTION_TYPE_NOTIFY:
- MSG("notify");
+ _MSG("notify");
+
+ action_status = lttng_action_notify_get_rate_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve rate policy.");
+ goto end;
+ }
break;
case LTTNG_ACTION_TYPE_START_SESSION:
action_status = lttng_action_start_session_get_session_name(
action, &value);
assert(action_status == LTTNG_ACTION_STATUS_OK);
- MSG("start session `%s`", value);
+ _MSG("start session `%s`", value);
+
+ action_status = lttng_action_start_session_get_rate_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve rate policy.");
+ goto end;
+ }
break;
case LTTNG_ACTION_TYPE_STOP_SESSION:
action_status = lttng_action_stop_session_get_session_name(
action, &value);
assert(action_status == LTTNG_ACTION_STATUS_OK);
- MSG("stop session `%s`", value);
+ _MSG("stop session `%s`", value);
+
+ action_status = lttng_action_stop_session_get_rate_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve rate policy.");
+ goto end;
+ }
break;
case LTTNG_ACTION_TYPE_ROTATE_SESSION:
action_status = lttng_action_rotate_session_get_session_name(
action, &value);
assert(action_status == LTTNG_ACTION_STATUS_OK);
- MSG("rotate session `%s`", value);
+ _MSG("rotate session `%s`", value);
+
+ action_status = lttng_action_rotate_session_get_rate_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve rate policy.");
+ goto end;
+ }
break;
case LTTNG_ACTION_TYPE_SNAPSHOT_SESSION:
{
}
}
- MSG("");
+ action_status = lttng_action_snapshot_session_get_rate_policy(
+ action, &policy);
+ if (action_status != LTTNG_ACTION_STATUS_OK) {
+ ERR("Failed to retrieve rate policy.");
+ goto end;
+ }
break;
}
-
default:
abort();
}
+
+ if (policy) {
+ enum lttng_rate_policy_type policy_type;
+ enum lttng_rate_policy_status policy_status;
+ uint64_t policy_value = 0;
+
+ policy_type = lttng_rate_policy_get_type(policy);
+
+ switch (policy_type) {
+ case LTTNG_RATE_POLICY_TYPE_EVERY_N:
+ policy_status = lttng_rate_policy_every_n_get_interval(
+ policy, &policy_value);
+ if (policy_status != LTTNG_RATE_POLICY_STATUS_OK) {
+ ERR("Failed to get action rate policy interval");
+ goto end;
+ }
+ if (policy_value > 1) {
+ /* The default is 1 so print only when it is a
+ * special case.
+ */
+ _MSG(", rate policy: after every %" PRIu64
+ " occurrences",
+ policy_value);
+ }
+ break;
+ case LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N:
+ policy_status = lttng_rate_policy_once_after_n_get_threshold(
+ policy, &policy_value);
+ if (policy_status != LTTNG_RATE_POLICY_STATUS_OK) {
+ ERR("Failed to get action rate policy interval");
+ goto end;
+ }
+ _MSG(", rate policy: once after %" PRIu64
+ " occurrences",
+ policy_value);
+ break;
+ default:
+ abort();
+ }
+ }
+
+ 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
enum lttng_action_type action_type;
enum lttng_trigger_status trigger_status;
const char *name;
- enum lttng_trigger_firing_policy firing_policy_type;
- uint64_t threshold;
uid_t trigger_uid;
trigger_status = lttng_trigger_get_name(trigger, &name);
MSG("- id: %s", name);
MSG(" user id: %d", trigger_uid);
- trigger_status = lttng_trigger_get_firing_policy(
- trigger, &firing_policy_type, &threshold);
- if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
- ERR("Failed to get trigger's policy.");
- goto end;
- }
-
- switch (firing_policy_type) {
- case LTTNG_TRIGGER_FIRING_POLICY_EVERY_N:
- if (threshold > 1) {
- MSG(" firing policy: after every %" PRIu64 " occurences", threshold);
- }
- break;
- case LTTNG_TRIGGER_FIRING_POLICY_ONCE_AFTER_N:
- MSG(" firing policy: once after %" PRIu64 " occurences", threshold);
- break;
- default:
- abort();
- }
-
condition = lttng_trigger_get_const_condition(trigger);
condition_type = lttng_condition_get_type(condition);
MSG(" condition: %s", lttng_condition_type_str(condition_type));
action, i);
_MSG(" ");
- print_one_action(subaction);
+ print_one_action(trigger, subaction);
}
} else {
_MSG(" action:");
- print_one_action(action);
+ print_one_action(trigger, action);
}
-end:
- return;
+ print_trigger_errors(trigger);
}
static