X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Flttng%2Fuserspace-probe.h;h=b6fc13508a3c02f48db57c7596cfa915d0bf150e;hb=4bd69c5f1161cd065f487da0f4c1aa03a73c47e4;hp=c8c1ae43af4850cd4bc9baa72100561d2edc2b53;hpb=f4d0bb2e92e94cb5eb304c8e92afcc804591539d;p=lttng-tools.git diff --git a/include/lttng/userspace-probe.h b/include/lttng/userspace-probe.h index c8c1ae43a..b6fc13508 100644 --- a/include/lttng/userspace-probe.h +++ b/include/lttng/userspace-probe.h @@ -1,23 +1,15 @@ /* - * Copyright (C) 2017 - Jérémie Galarneau + * Copyright (C) 2017 Jérémie Galarneau * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License, version 2.1 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: LGPL-2.1-only * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef LTTNG_USERSPACE_PROBE_H #define LTTNG_USERSPACE_PROBE_H +#include + #ifdef __cplusplus extern "C" { #endif @@ -38,28 +30,28 @@ enum lttng_userspace_probe_location_lookup_method_type { /* * Get the type of a lookup method. */ -extern enum lttng_userspace_probe_location_lookup_method_type +LTTNG_EXPORT extern enum lttng_userspace_probe_location_lookup_method_type lttng_userspace_probe_location_lookup_method_get_type( const struct lttng_userspace_probe_location_lookup_method *lookup_method); /* * Destroy a lookup method. */ -extern void lttng_userspace_probe_location_lookup_method_destroy( +LTTNG_EXPORT extern void lttng_userspace_probe_location_lookup_method_destroy( struct lttng_userspace_probe_location_lookup_method *lookup_method); /* * Create a tracepoint ELF function lookup method struct. * Return NULL on failure. */ -extern struct lttng_userspace_probe_location_lookup_method * +LTTNG_EXPORT extern struct lttng_userspace_probe_location_lookup_method * lttng_userspace_probe_location_lookup_method_function_elf_create(void); /* * Create a tracepoint SDT tracepoint lookup method struct. * Return NULL on failure. */ -extern struct lttng_userspace_probe_location_lookup_method * +LTTNG_EXPORT extern struct lttng_userspace_probe_location_lookup_method * lttng_userspace_probe_location_lookup_method_tracepoint_sdt_create(void); @@ -69,25 +61,40 @@ lttng_userspace_probe_location_lookup_method_tracepoint_sdt_create(void); */ struct lttng_userspace_probe_location; +enum lttng_userspace_probe_location_status { + LTTNG_USERSPACE_PROBE_LOCATION_STATUS_OK = 0, + /* Invalid parameters provided. */ + LTTNG_USERSPACE_PROBE_LOCATION_STATUS_INVALID = -1, +}; + enum lttng_userspace_probe_location_type { LTTNG_USERSPACE_PROBE_LOCATION_TYPE_UNKNOWN = -1, + /* Function. */ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION = 0, + /* SDT probe's callsites. */ LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT = 1, }; /* * Get the type of the userspace probe location. */ -extern enum lttng_userspace_probe_location_type +LTTNG_EXPORT extern enum lttng_userspace_probe_location_type lttng_userspace_probe_location_get_type( const struct lttng_userspace_probe_location *location); /* * Destroy the userspace probe location. */ -extern void lttng_userspace_probe_location_destroy( +LTTNG_EXPORT extern void lttng_userspace_probe_location_destroy( struct lttng_userspace_probe_location *location); + +enum lttng_userspace_probe_location_function_instrumentation_type { + LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_UNKNOWN = -1, + /* Only instrument the function's entry. */ + LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY = 0, +}; + /* * Create a probe location of the function type. * Receives the target binary file path and function to instrument. @@ -96,7 +103,7 @@ extern void lttng_userspace_probe_location_destroy( * The ownership of the lookup method is transferred to the created probe * location. */ -extern struct lttng_userspace_probe_location * +LTTNG_EXPORT extern struct lttng_userspace_probe_location * lttng_userspace_probe_location_function_create(const char *binary_path, const char *function_name, struct lttng_userspace_probe_location_lookup_method *lookup_method); @@ -104,29 +111,50 @@ lttng_userspace_probe_location_function_create(const char *binary_path, /* * Get the target binary path of the probe location of the function type. */ -extern const char *lttng_userspace_probe_location_function_get_binary_path( +LTTNG_EXPORT extern const char *lttng_userspace_probe_location_function_get_binary_path( const struct lttng_userspace_probe_location *location); /* * Get the target function type of the probe location of the function type. */ -extern const char *lttng_userspace_probe_location_function_get_function_name( +LTTNG_EXPORT extern const char *lttng_userspace_probe_location_function_get_function_name( const struct lttng_userspace_probe_location *location); /* * Get the FD to the target binary file to the probe location of the function - * type. + * type. The FD is only valid for the duration of the lifetime of `location`. */ -extern int lttng_userspace_probe_location_function_get_binary_fd( +LTTNG_EXPORT extern int lttng_userspace_probe_location_function_get_binary_fd( const struct lttng_userspace_probe_location *location); +/* + * Get the instrumentation type of the function probe location. + */ +LTTNG_EXPORT extern enum lttng_userspace_probe_location_function_instrumentation_type +lttng_userspace_probe_location_function_get_instrumentation_type( + const struct lttng_userspace_probe_location *location); + +/* + * Get the instrumentation type of the function probe location. + * Defaults to + * LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY. + * + * Returns LTTNG_USERSPACE_PROBE_LOCATION_STATUS_OK on success, + * LTTNG_USERSPACE_PROBE_LOCATION_STATUS_INVALID if invalid parameters + * are provided. + */ +LTTNG_EXPORT extern 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); + /* * Get the lookup method of the given userspace probe location. * Returns NULL if the probe location type is unsupported. * * The ownership of the lookup method is NOT transferred to the caller. */ -extern struct lttng_userspace_probe_location_lookup_method * +LTTNG_EXPORT extern const struct lttng_userspace_probe_location_lookup_method * lttng_userspace_probe_location_get_lookup_method( const struct lttng_userspace_probe_location *location); @@ -139,7 +167,7 @@ lttng_userspace_probe_location_get_lookup_method( * The ownership of the lookup method is transferred to the created probe * location. */ -extern struct lttng_userspace_probe_location * +LTTNG_EXPORT extern struct lttng_userspace_probe_location * lttng_userspace_probe_location_tracepoint_create(const char *binary_path, const char *probe_name, const char *provider_name, struct lttng_userspace_probe_location_lookup_method *lookup_method); @@ -147,27 +175,27 @@ lttng_userspace_probe_location_tracepoint_create(const char *binary_path, /* * Get the target binary path of the probe location of the tracepoint type. */ -extern const char *lttng_userspace_probe_location_tracepoint_get_binary_path( +LTTNG_EXPORT extern const char *lttng_userspace_probe_location_tracepoint_get_binary_path( const struct lttng_userspace_probe_location *location); /* * Get the target probe name of the probe location of the tracepoint type. */ -extern const char *lttng_userspace_probe_location_tracepoint_get_probe_name( +LTTNG_EXPORT extern const char *lttng_userspace_probe_location_tracepoint_get_probe_name( const struct lttng_userspace_probe_location *location); /* * Get the target probe provider name of the probe location of the tracepoint * type. */ -extern const char *lttng_userspace_probe_location_tracepoint_get_provider_name( +LTTNG_EXPORT extern const char *lttng_userspace_probe_location_tracepoint_get_provider_name( const struct lttng_userspace_probe_location *location); /* * Get the FD to the target binary file to the probe location of the tracepoint - * type. + * type. The FD is only valid for the duration of the lifetime of `location`. */ -extern int lttng_userspace_probe_location_tracepoint_get_binary_fd( +LTTNG_EXPORT extern int lttng_userspace_probe_location_tracepoint_get_binary_fd( const struct lttng_userspace_probe_location *location); #ifdef __cplusplus