Fix: kernel function event was listed as probe
[lttng-tools.git] / src / bin / lttng / commands / list.c
index 966be2def5e3ac8f300e47ab65e2db149c7c3a21..b7c2b6c2263cdae040bedd6ccc4e4527ff47fdd2 100644 (file)
@@ -146,6 +146,15 @@ const char *enabled_string(int value)
        }
 }
 
+static
+const char *filter_string(int value)
+{
+       switch (value) {
+       case 1: return " [with filter]";
+       default: return "";
+       }
+}
+
 static const char *loglevel_string(int value)
 {
        switch (value) {
@@ -195,23 +204,37 @@ static void print_events(struct lttng_event *event)
        case LTTNG_EVENT_TRACEPOINT:
        {
                if (event->loglevel != -1) {
-                       MSG("%s%s (loglevel: %s (%d)) (type: tracepoint)%s",
+                       MSG("%s%s (loglevel: %s (%d)) (type: tracepoint)%s%s",
                                indent6,
                                event->name,
                                loglevel_string(event->loglevel),
                                event->loglevel,
-                               enabled_string(event->enabled));
+                               enabled_string(event->enabled),
+                               filter_string(event->filter));
                } else {
-                       MSG("%s%s (type: tracepoint)%s",
+                       MSG("%s%s (type: tracepoint)%s%s",
                                indent6,
                                event->name,
-                               enabled_string(event->enabled));
+                               enabled_string(event->enabled),
+                               filter_string(event->filter));
                }
                break;
        }
+       case LTTNG_EVENT_FUNCTION:
+               MSG("%s%s (type: function)%s%s", indent6,
+                               event->name, enabled_string(event->enabled),
+                               filter_string(event->filter));
+               if (event->attr.probe.addr != 0) {
+                       MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
+               } else {
+                       MSG("%soffset: 0x%" PRIx64, indent8, event->attr.probe.offset);
+                       MSG("%ssymbol: %s", indent8, event->attr.probe.symbol_name);
+               }
+               break;
        case LTTNG_EVENT_PROBE:
-               MSG("%s%s (type: probe)%s", indent6,
-                               event->name, enabled_string(event->enabled));
+               MSG("%s%s (type: probe)%s%s", indent6,
+                               event->name, enabled_string(event->enabled),
+                               filter_string(event->filter));
                if (event->attr.probe.addr != 0) {
                        MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
                } else {
@@ -219,19 +242,21 @@ static void print_events(struct lttng_event *event)
                        MSG("%ssymbol: %s", indent8, event->attr.probe.symbol_name);
                }
                break;
-       case LTTNG_EVENT_FUNCTION:
        case LTTNG_EVENT_FUNCTION_ENTRY:
-               MSG("%s%s (type: function)%s", indent6,
-                               event->name, enabled_string(event->enabled));
+               MSG("%s%s (type: function)%s%s", indent6,
+                               event->name, enabled_string(event->enabled),
+                               filter_string(event->filter));
                MSG("%ssymbol: \"%s\"", indent8, event->attr.ftrace.symbol_name);
                break;
        case LTTNG_EVENT_SYSCALL:
-               MSG("%ssyscalls (type: syscall)%s", indent6,
-                               enabled_string(event->enabled));
+               MSG("%ssyscalls (type: syscall)%s%s", indent6,
+                               enabled_string(event->enabled),
+                               filter_string(event->filter));
                break;
        case LTTNG_EVENT_NOOP:
-               MSG("%s (type: noop)%s", indent6,
-                               enabled_string(event->enabled));
+               MSG("%s (type: noop)%s%s", indent6,
+                               enabled_string(event->enabled),
+                               filter_string(event->filter));
                break;
        case LTTNG_EVENT_ALL:
                /* We should never have "all" events in list. */
@@ -265,8 +290,8 @@ static void print_event_field(struct lttng_event_field *field)
        if (!field->field_name[0]) {
                return;
        }
-       MSG("%sfield: %s (%s)", indent8, field->field_name,
-               field_type(field));
+       MSG("%sfield: %s (%s)%s", indent8, field->field_name,
+               field_type(field), field->nowrite ? " [no write]" : "");
 }
 
 /*
@@ -279,6 +304,7 @@ static int list_ust_events(void)
        struct lttng_handle *handle;
        struct lttng_event *event_list;
        pid_t cur_pid = 0;
+       char *cmdline = NULL;
 
        memset(&domain, 0, sizeof(domain));
 
@@ -307,7 +333,9 @@ static int list_ust_events(void)
        for (i = 0; i < size; i++) {
                if (cur_pid != event_list[i].pid) {
                        cur_pid = event_list[i].pid;
-                       MSG("\nPID: %d - Name: %s", cur_pid, get_cmdline_by_pid(cur_pid));
+                       cmdline = get_cmdline_by_pid(cur_pid);
+                       MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
+                       free(cmdline);
                }
                print_events(&event_list[i]);
        }
@@ -334,6 +362,8 @@ static int list_ust_event_fields(void)
        struct lttng_handle *handle;
        struct lttng_event_field *event_field_list;
        pid_t cur_pid = 0;
+       char *cmdline = NULL;
+
        struct lttng_event cur_event;
 
        memset(&domain, 0, sizeof(domain));
@@ -364,7 +394,9 @@ static int list_ust_event_fields(void)
        for (i = 0; i < size; i++) {
                if (cur_pid != event_field_list[i].event.pid) {
                        cur_pid = event_field_list[i].event.pid;
-                       MSG("\nPID: %d - Name: %s", cur_pid, get_cmdline_by_pid(cur_pid));
+                       cmdline = get_cmdline_by_pid(cur_pid);
+                       MSG("\nPID: %d - Name: %s", cur_pid, cmdline);
+                       free(cmdline);
                }
                if (strcmp(cur_event.name, event_field_list[i].event.name) != 0) {
                        print_events(&event_field_list[i].event);
@@ -459,9 +491,7 @@ static int list_events(const char *channel_name)
        MSG("");
 
 end:
-       if (events) {
-               free(events);
-       }
+       free(events);
        ret = CMD_SUCCESS;
 
 error:
@@ -506,11 +536,17 @@ static int list_channels(const char *channel_name)
 
        count = lttng_list_channels(handle, &channels);
        if (count < 0) {
-               ret = count;
+               switch (-count) {
+               case LTTNG_ERR_KERN_CHAN_NOT_FOUND:
+                       ret = CMD_SUCCESS;
+                       WARN("No kernel channel");
+                       break;
+               default:
+                       /* We had a real error */
+                       ret = count;
+                       ERR("%s", lttng_strerror(ret));
+               }
                goto error_channels;
-       } else if (count == 0) {
-               ERR("Channel %s not found", channel_name);
-               goto error;
        }
 
        if (channel_name == NULL) {
@@ -567,6 +603,7 @@ static int list_sessions(const char *session_name)
        DBG("Session count %d", count);
        if (count < 0) {
                ret = count;
+               ERR("%s", lttng_strerror(ret));
                goto error;
        } else if (count == 0) {
                MSG("Currently no available tracing session");
@@ -659,8 +696,7 @@ error:
  */
 int cmd_list(int argc, const char **argv)
 {
-       int opt, i, ret = CMD_SUCCESS;
-       int nb_domain;
+       int opt, ret = CMD_SUCCESS;
        const char *session_name;
        static poptContext pc;
        struct lttng_domain domain;
@@ -724,6 +760,7 @@ int cmd_list(int argc, const char **argv)
                if (opt_kernel) {
                        ret = list_kernel_events();
                        if (ret < 0) {
+                               ret = CMD_ERROR;
                                goto end;
                        }
                }
@@ -734,6 +771,7 @@ int cmd_list(int argc, const char **argv)
                                ret = list_ust_events();
                        }
                        if (ret < 0) {
+                               ret = CMD_ERROR;
                                goto end;
                        }
                }
@@ -757,6 +795,8 @@ int cmd_list(int argc, const char **argv)
                                goto end;
                        }
                } else {
+                       int i, nb_domain;
+
                        /* We want all domain(s) */
                        nb_domain = lttng_list_domains(session_name, &domains);
                        if (nb_domain < 0) {
@@ -797,9 +837,7 @@ int cmd_list(int argc, const char **argv)
        }
 
 end:
-       if (domains) {
-               free(domains);
-       }
+       free(domains);
        if (handle) {
                lttng_destroy_handle(handle);
        }
This page took 0.044708 seconds and 5 git commands to generate.