Fix: userspace probe accessors are not const-correct
[lttng-tools.git] / src / bin / lttng / commands / list.c
index a4ee96e9e0f2b1843a9696f28e8f822cb84c0b51..eabeb8132ecd36c6e15fb996cb8bdba96b61249d 100644 (file)
@@ -249,6 +249,82 @@ end:
        return exclusion_msg;
 }
 
+static void print_userspace_probe_location(struct lttng_event *event)
+{
+       const struct lttng_userspace_probe_location *location;
+       const struct lttng_userspace_probe_location_lookup_method *lookup_method;
+       enum lttng_userspace_probe_location_lookup_method_type lookup_type;
+
+       location = lttng_event_get_userspace_probe_location(event);
+       if (!location) {
+               MSG("Event has no userspace probe location");
+               return;
+       }
+
+       lookup_method = lttng_userspace_probe_location_get_lookup_method(location);
+       if (!lookup_method) {
+               MSG("Event has no userspace probe location lookup method");
+               return;
+       }
+
+       MSG("%s%s (type: userspace-probe)%s", indent6, event->name, enabled_string(event->enabled));
+
+       lookup_type = lttng_userspace_probe_location_lookup_method_get_type(lookup_method);
+
+       switch (lttng_userspace_probe_location_get_type(location)) {
+       case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_UNKNOWN:
+               MSG("%sType: Unknown", indent8);
+               break;
+       case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
+       {
+               const char *function_name;
+               const char *binary_path;
+
+               MSG("%sType: Function", indent8);
+               function_name = lttng_userspace_probe_location_function_get_function_name(location);
+               binary_path = realpath(lttng_userspace_probe_location_function_get_binary_path(location), NULL);
+
+               MSG("%sBinary path:   %s", indent8, binary_path ? binary_path : "NULL");
+               MSG("%sFunction:      %s()", indent8, function_name ? function_name : "NULL");
+               switch (lookup_type) {
+               case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
+                       MSG("%sLookup method: ELF", indent8);
+                       break;
+               case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
+                       MSG("%sLookup method: default", indent8);
+                       break;
+               default:
+                       MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
+                       break;
+               }
+               break;
+       }
+       case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
+       {
+               const char *probe_name, *provider_name;
+               const char *binary_path;
+
+               MSG("%sType: Tracepoint", indent8);
+               probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
+               provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(location);
+               binary_path = realpath(lttng_userspace_probe_location_tracepoint_get_binary_path(location), NULL);
+               MSG("%sBinary path:   %s", indent8, binary_path ? binary_path : "NULL");
+               MSG("%sTracepoint:    %s:%s", indent8, provider_name ? provider_name : "NULL", probe_name ? probe_name : "NULL");
+               switch (lookup_type) {
+               case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
+                       MSG("%sLookup method: SDT", indent8);
+                       break;
+               default:
+                       MSG("%sLookup method: INVALID LOOKUP TYPE ENCOUNTERED", indent8);
+                       break;
+               }
+               break;
+       }
+       default:
+               ERR("Invalid probe type encountered");
+       }
+}
+
 /*
  * Pretty print single event.
  */
@@ -324,6 +400,9 @@ static void print_events(struct lttng_event *event)
                        MSG("%ssymbol: %s", indent8, event->attr.probe.symbol_name);
                }
                break;
+       case LTTNG_EVENT_USERSPACE_PROBE:
+               print_userspace_probe_location(event);
+               break;
        case LTTNG_EVENT_FUNCTION_ENTRY:
                MSG("%s%s (type: function)%s%s", indent6,
                                event->name, enabled_string(event->enabled),
@@ -343,6 +422,8 @@ static void print_events(struct lttng_event *event)
                                safe_string(filter_msg));
                break;
        case LTTNG_EVENT_ALL:
+               /* Fall-through. */
+       default:
                /* We should never have "all" events in list. */
                assert(0);
                break;
@@ -1536,16 +1617,6 @@ static enum cmd_error_code print_periodic_rotation_schedule(
        }
 
        MSG("    timer period: %" PRIu64" µs", value);
-       if (lttng_opt_mi) {
-               int mi_ret = mi_lttng_writer_write_element_unsigned_int(writer,
-                               config_element_rotation_timer_interval, value);
-
-               if (mi_ret) {
-                       ret = CMD_ERROR;
-                       goto end;
-               }
-       }
-
        ret = CMD_SUCCESS;
 end:
        return ret;
@@ -1567,16 +1638,6 @@ static enum cmd_error_code print_size_threshold_rotation_schedule(
        }
 
        MSG("    size threshold: %" PRIu64" bytes", value);
-       if (lttng_opt_mi) {
-               int mi_ret = mi_lttng_writer_write_element_unsigned_int(writer,
-                               config_element_rotation_size, value);
-
-               if (mi_ret) {
-                       ret = CMD_ERROR;
-                       goto end;
-               }
-       }
-
        ret = CMD_SUCCESS;
 end:
        return ret;
This page took 0.024123 seconds and 4 git commands to generate.