+ DBG("Getting kernel system call events");
+
+ size = lttng_list_syscalls(&event_list);
+ if (size < 0) {
+ ERR("Unable to list system calls: %s", lttng_strerror(size));
+ ret = CMD_ERROR;
+ goto error;
+ }
+
+ if (lttng_opt_mi) {
+ /* Mi print */
+ ret = mi_list_syscalls(event_list, size);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ } else {
+ MSG("System calls:\n-------------");
+
+ for (i = 0; i < size; i++) {
+ print_events(&event_list[i]);
+ }
+
+ MSG("");
+ }
+
+end:
+ free(event_list);
+ return ret;
+
+error:
+ return ret;
+}
+
+/*
+ * Machine Interface
+ * Print a list of agent events
+ */
+static int mi_list_session_agent_events(struct lttng_event *events, int count)
+{
+ int ret, i;
+
+ /* Open events element */
+ ret = mi_lttng_events_open(writer);
+ if (ret) {
+ goto end;
+ }
+
+ for (i = 0; i < count; i++) {
+ ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
+ if (ret) {
+ goto end;
+ }
+ }
+
+ /* Close events element */
+ ret = mi_lttng_writer_close_element(writer);
+
+end:
+ return ret;
+}
+
+/*
+ * List agent events for a specific session using the handle.
+ *
+ * Return CMD_SUCCESS on success else a negative value.
+ */
+static int list_session_agent_events(void)
+{
+ int ret = CMD_SUCCESS, count, i;
+ struct lttng_event *events = NULL;
+
+ count = lttng_list_events(handle, "", &events);
+ if (count < 0) {
+ ret = CMD_ERROR;
+ ERR("%s", lttng_strerror(count));
+ goto error;
+ }
+
+ if (lttng_opt_mi) {
+ /* Mi print */
+ ret = mi_list_session_agent_events(events, count);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ } else {
+ /* Pretty print */
+ MSG("Events (Logger name):\n---------------------");
+ if (count == 0) {
+ MSG("%sNone\n", indent6);
+ goto end;
+ }
+
+ for (i = 0; i < count; i++) {
+ MSG("%s- %s%s (loglevel%s %s)", indent4, events[i].name,
+ enabled_string(events[i].enabled),
+ logleveltype_string(events[i].loglevel_type),
+ mi_lttng_loglevel_string(events[i].loglevel,
+ handle->domain.type));
+ }
+
+ MSG("");
+ }
+
+end:
+ free(events);
+error:
+ return ret;
+}
+
+/*
+ * Machine interface
+ * print a list of event
+ */
+static int mi_list_events(struct lttng_event *events, int count)
+{
+ int ret, i;
+
+ /* Open events element */
+ ret = mi_lttng_events_open(writer);
+ if (ret) {
+ goto end;
+ }
+
+ for (i = 0; i < count; i++) {
+ ret = mi_lttng_event(writer, &events[i], 0, handle->domain.type);
+ if (ret) {
+ goto end;
+ }
+ }
+
+ /* Close events element */
+ ret = mi_lttng_writer_close_element(writer);
+
+end:
+ return ret;
+}
+
+/*
+ * List events of channel of session and domain.
+ */
+static int list_events(const char *channel_name)
+{
+ int ret = CMD_SUCCESS, count, i;
+ struct lttng_event *events = NULL;
+
+ count = lttng_list_events(handle, channel_name, &events);
+ if (count < 0) {
+ ret = CMD_ERROR;
+ ERR("%s", lttng_strerror(count));
+ goto error;
+ }
+
+ if (lttng_opt_mi) {
+ /* Mi print */
+ ret = mi_list_events(events, count);
+ if (ret) {
+ ret = CMD_ERROR;
+ goto end;
+ }
+ } else {
+ /* Pretty print */
+ MSG("\n%sEvents:", indent4);
+ if (count == 0) {
+ MSG("%sNone\n", indent6);
+ goto end;
+ }
+
+ for (i = 0; i < count; i++) {
+ print_events(&events[i]);
+ }
+
+ MSG("");
+ }
+end:
+ free(events);
+error:
+ return ret;
+}
+
+/*
+ * Pretty print channel
+ */
+static void print_channel(struct lttng_channel *channel)
+{
+ MSG("- %s:%s\n", channel->name, enabled_string(channel->enabled));
+
+ MSG("%sAttributes:", indent4);
+ MSG("%soverwrite mode: %d", indent6, channel->attr.overwrite);
+ MSG("%ssubbufers size: %" PRIu64, indent6, channel->attr.subbuf_size);
+ MSG("%snumber of subbufers: %" PRIu64, indent6, channel->attr.num_subbuf);
+ MSG("%sswitch timer interval: %u", indent6, channel->attr.switch_timer_interval);