X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fuserspace-probe.c;h=7f038f5b53ec8a0e76d77df6c121542dbb3129f9;hp=89066bf0549a553df0564528d450a7763910ccc0;hb=9d3981b5c746b87954c46218b2c7c6e76ae7ed46;hpb=87597c2c3bbaa1502ad2025cbf16704829f3b464 diff --git a/src/common/userspace-probe.c b/src/common/userspace-probe.c index 89066bf05..7f038f5b5 100644 --- a/src/common/userspace-probe.c +++ b/src/common/userspace-probe.c @@ -38,26 +38,7 @@ void lttng_userspace_probe_location_lookup_method_destroy( return; } - switch (lookup_method->type) { - case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF: - { - struct lttng_userspace_probe_location_lookup_method_elf *elf_method = - container_of(lookup_method, - struct lttng_userspace_probe_location_lookup_method_elf, parent); - free(elf_method); - break; - } - case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT: - { - struct lttng_userspace_probe_location_lookup_method_sdt *sdt_method = - container_of(lookup_method, - struct lttng_userspace_probe_location_lookup_method_sdt, parent); - free(sdt_method); - break; - } - default: - break; - } + free(lookup_method); } struct lttng_userspace_probe_location_lookup_method * @@ -169,7 +150,7 @@ void lttng_userspace_probe_location_destroy( lttng_userspace_probe_location_tracepoint_destroy(location); break; default: - free(location); + abort(); } } @@ -215,6 +196,8 @@ lttng_userspace_probe_location_function_create_no_check(const char *binary_path, location->function_name = function_name_copy; location->binary_path = binary_path_copy; location->binary_fd = binary_fd; + location->instrumentation_type = + LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY; ret = &location->parent; ret->lookup_method = lookup_method; @@ -711,6 +694,52 @@ end: return ret; } +enum lttng_userspace_probe_location_function_instrumentation_type +lttng_userspace_probe_location_function_get_instrumentation_type( + const struct lttng_userspace_probe_location *location) +{ + enum lttng_userspace_probe_location_function_instrumentation_type type; + struct lttng_userspace_probe_location_function *function_location; + + if (!location || lttng_userspace_probe_location_get_type(location) != + LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION) { + ERR("Invalid argument(s)"); + type = LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_UNKNOWN; + goto end; + } + + function_location = container_of(location, + struct lttng_userspace_probe_location_function, parent); + type = function_location->instrumentation_type; +end: + return type; +} + +enum lttng_userspace_probe_location_status +lttng_userspace_probe_location_function_set_instrumentation_type( + const struct lttng_userspace_probe_location *location, + enum lttng_userspace_probe_location_function_instrumentation_type instrumentation_type) +{ + enum lttng_userspace_probe_location_status status = + LTTNG_USERSPACE_PROBE_LOCATION_STATUS_OK; + struct lttng_userspace_probe_location_function *function_location; + + if (!location || lttng_userspace_probe_location_get_type(location) != + LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION || + instrumentation_type != + LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY) { + ERR("Invalid argument(s)"); + status = LTTNG_USERSPACE_PROBE_LOCATION_STATUS_INVALID; + goto end; + } + + function_location = container_of(location, + struct lttng_userspace_probe_location_function, parent); + function_location->instrumentation_type = instrumentation_type; +end: + return status; +} + int lttng_userspace_probe_location_tracepoint_get_binary_fd( const struct lttng_userspace_probe_location *location) {