From: Francis Deslauriers Date: Fri, 29 Jun 2018 20:04:20 +0000 (-0400) Subject: Implement lttng-mi for userspace-probe X-Git-Tag: v2.11.0-rc1~68 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5a1c0a75771c4b95f9518be0e1960a25bb691caf;p=lttng-tools.git Implement lttng-mi for userspace-probe Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/mi-lttng-3.0.xsd b/src/common/mi-lttng-3.0.xsd index b619b54c8..017956ccc 100644 --- a/src/common/mi-lttng-3.0.xsd +++ b/src/common/mi-lttng-3.0.xsd @@ -73,6 +73,7 @@ THE SOFTWARE. + diff --git a/src/common/mi-lttng.c b/src/common/mi-lttng.c index 084932811..0191cbd0f 100644 --- a/src/common/mi-lttng.c +++ b/src/common/mi-lttng.c @@ -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; + 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: @@ -1273,6 +1275,141 @@ end: 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) @@ -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_USERSPACE_PROBE: + ret = mi_lttng_event_userspace_probe(writer, event); + break; case LTTNG_EVENT_ALL: /* Fallthrough */ default: break; } + if (ret) { + goto end; + } + if (!is_open) { ret = mi_lttng_writer_close_element(writer); }