Implement lttng-mi for userspace-probe
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 29 Jun 2018 20:04:20 +0000 (16:04 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 20:08:03 +0000 (16:08 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/mi-lttng-3.0.xsd
src/common/mi-lttng.c

index b619b54c8a3c63df850ff8b31d6a966c745655c6..017956cccc3302a50df0e8b5ab5da7abe2e76bdc 100644 (file)
@@ -73,6 +73,7 @@ THE SOFTWARE.
                        <xs:enumeration value="FUNCTION_ENTRY" />
                        <xs:enumeration value="NOOP" />
                        <xs:enumeration value="SYSCALL" />
                        <xs:enumeration value="FUNCTION_ENTRY" />
                        <xs:enumeration value="NOOP" />
                        <xs:enumeration value="SYSCALL" />
+                       <xs:enumeration value="USERSPACE_PROBE" />
                </xs:restriction>
        </xs:simpleType>
 
                </xs:restriction>
        </xs:simpleType>
 
index 084932811a6c13055d9e33c615833c028afbdae5..0191cbd0f6d09f7e6c83db096027f209c7f91795 100644 (file)
@@ -373,6 +373,8 @@ const char *mi_lttng_eventtype_string(enum lttng_event_type value)
                return config_event_type_tracepoint;
        case LTTNG_EVENT_PROBE:
                return config_event_type_probe;
                return config_event_type_tracepoint;
        case LTTNG_EVENT_PROBE:
                return config_event_type_probe;
+       case LTTNG_EVENT_USERSPACE_PROBE:
+               return config_event_type_userspace_probe;
        case LTTNG_EVENT_FUNCTION:
                return config_event_type_function;
        case LTTNG_EVENT_FUNCTION_ENTRY:
        case LTTNG_EVENT_FUNCTION:
                return config_event_type_function;
        case LTTNG_EVENT_FUNCTION_ENTRY:
@@ -1273,6 +1275,141 @@ end:
        return ret;
 }
 
        return ret;
 }
 
+LTTNG_HIDDEN
+int mi_lttng_event_userspace_probe(struct mi_writer *writer,
+               struct lttng_event *event)
+{
+       int ret;
+       struct lttng_userspace_probe_location *location;
+       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) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       lookup_method = lttng_userspace_probe_location_get_lookup_method(location);
+       if (!lookup_method) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       lookup_type = lttng_userspace_probe_location_lookup_method_get_type(lookup_method);
+
+       ret = mi_lttng_writer_open_element(writer, config_element_attributes);
+       if (ret) {
+               goto end;
+       }
+
+       switch (lttng_userspace_probe_location_get_type(location)) {
+       case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
+       {
+               const char *function_name;
+               const char *binary_path;
+
+               ret = mi_lttng_writer_open_element(writer,
+                               config_element_userspace_probe_function_attributes);
+               if (ret) {
+                       goto end;
+               }
+
+               switch (lookup_type) {
+               case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
+                       ret = mi_lttng_writer_write_element_string(writer,
+                                       config_element_userspace_probe_lookup,
+                                       config_element_userspace_probe_lookup_function_elf);
+                       if (ret) {
+                               goto end;
+                       }
+                       break;
+               case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
+                       ret = mi_lttng_writer_write_element_string(writer,
+                                       config_element_userspace_probe_lookup,
+                                       config_element_userspace_probe_lookup_function_default);
+                       if (ret) {
+                               goto end;
+                       }
+                       break;
+               default:
+                       goto end;
+               }
+
+               binary_path = lttng_userspace_probe_location_function_get_binary_path(location);
+               ret = mi_lttng_writer_write_element_string(writer,
+                               config_element_userspace_probe_location_binary_path, binary_path);
+               if (ret) {
+                       goto end;
+               }
+
+               function_name = lttng_userspace_probe_location_function_get_function_name(location);
+               ret = mi_lttng_writer_write_element_string(writer,
+                               config_element_userspace_probe_function_location_function_name,
+                               function_name);
+               if (ret) {
+                       goto end;
+               }
+
+               break;
+       }
+       case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
+       {
+               const char *probe_name, *provider_name;
+               const char *binary_path;
+
+               ret = mi_lttng_writer_open_element(writer,
+                               config_element_userspace_probe_function_attributes);
+               if (ret) {
+                       goto end;
+               }
+
+               switch (lookup_type) {
+               case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
+                       ret = mi_lttng_writer_write_element_string(writer,
+                                       config_element_userspace_probe_lookup,
+                                       config_element_userspace_probe_lookup_tracepoint_sdt);
+                       if (ret) {
+                               goto end;
+                       }
+                       break;
+               default:
+                       goto end;
+               }
+
+               binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(location);
+               ret = mi_lttng_writer_write_element_string(writer,
+                               config_element_userspace_probe_location_binary_path,
+                               binary_path);
+               if (ret) {
+                       goto end;
+               }
+
+               provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(location);
+               ret = mi_lttng_writer_write_element_string(writer,
+                               config_element_userspace_probe_tracepoint_location_provider_name,
+                               provider_name);
+               if (ret) {
+                       goto end;
+               }
+
+               probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(location);
+               ret = mi_lttng_writer_write_element_string(writer,
+                               config_element_userspace_probe_tracepoint_location_probe_name, probe_name);
+               if (ret) {
+                       goto end;
+               }
+               break;
+       }
+       default:
+               ERR("Invalid probe type encountered");
+       }
+       /* Close probe_attributes and attributes */
+       ret = mi_lttng_close_multi_element(writer, 2);
+end:
+       return ret;
+}
+
 LTTNG_HIDDEN
 int mi_lttng_event_function_entry(struct mi_writer *writer,
                struct lttng_event *event)
 LTTNG_HIDDEN
 int mi_lttng_event_function_entry(struct mi_writer *writer,
                struct lttng_event *event)
@@ -1337,12 +1474,19 @@ int mi_lttng_event(struct mi_writer *writer,
        case LTTNG_EVENT_FUNCTION_ENTRY:
                ret = mi_lttng_event_function_entry(writer, event);
                break;
        case LTTNG_EVENT_FUNCTION_ENTRY:
                ret = mi_lttng_event_function_entry(writer, event);
                break;
+       case LTTNG_EVENT_USERSPACE_PROBE:
+               ret = mi_lttng_event_userspace_probe(writer, event);
+               break;
        case LTTNG_EVENT_ALL:
                /* Fallthrough */
        default:
                break;
        }
 
        case LTTNG_EVENT_ALL:
                /* Fallthrough */
        default:
                break;
        }
 
+       if (ret) {
+               goto end;
+       }
+
        if (!is_open) {
                ret = mi_lttng_writer_close_element(writer);
        }
        if (!is_open) {
                ret = mi_lttng_writer_close_element(writer);
        }
This page took 0.03023 seconds and 5 git commands to generate.