| 1 | /* |
| 2 | * Copyright (C) 2020 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: LGPL-2.1-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef LTTNG_KERNEL_PROBE_H |
| 9 | #define LTTNG_KERNEL_PROBE_H |
| 10 | |
| 11 | #include <lttng/lttng-export.h> |
| 12 | |
| 13 | #include <stdint.h> |
| 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | struct lttng_kernel_probe_location; |
| 20 | |
| 21 | enum lttng_kernel_probe_location_status { |
| 22 | LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK = 0, |
| 23 | /* Invalid parameters provided. */ |
| 24 | LTTNG_KERNEL_PROBE_LOCATION_STATUS_INVALID = -1, |
| 25 | }; |
| 26 | |
| 27 | enum lttng_kernel_probe_location_type { |
| 28 | LTTNG_KERNEL_PROBE_LOCATION_TYPE_UNKNOWN = -1, |
| 29 | /* Location derived from a symbol and an offset. */ |
| 30 | LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET = 0, |
| 31 | /* Location derived from an address. */ |
| 32 | LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS = 1, |
| 33 | }; |
| 34 | |
| 35 | /* |
| 36 | * Get the type of the kernel probe location. |
| 37 | */ |
| 38 | LTTNG_EXPORT extern enum lttng_kernel_probe_location_type |
| 39 | lttng_kernel_probe_location_get_type(const struct lttng_kernel_probe_location *location); |
| 40 | |
| 41 | /* |
| 42 | * Destroy the kernel probe location. |
| 43 | */ |
| 44 | LTTNG_EXPORT extern void |
| 45 | lttng_kernel_probe_location_destroy(struct lttng_kernel_probe_location *location); |
| 46 | |
| 47 | /* |
| 48 | * Create a symbol derived probe location. |
| 49 | * On failure, NULL is returned. |
| 50 | */ |
| 51 | LTTNG_EXPORT extern struct lttng_kernel_probe_location * |
| 52 | lttng_kernel_probe_location_symbol_create(const char *symbol_name, uint64_t offset); |
| 53 | |
| 54 | /* |
| 55 | * Get the symbol name of a symbol derived probe location. |
| 56 | */ |
| 57 | LTTNG_EXPORT extern const char * |
| 58 | lttng_kernel_probe_location_symbol_get_name(const struct lttng_kernel_probe_location *location); |
| 59 | |
| 60 | /* |
| 61 | * Get the offset of a symbol derived location. |
| 62 | */ |
| 63 | LTTNG_EXPORT extern enum lttng_kernel_probe_location_status |
| 64 | lttng_kernel_probe_location_symbol_get_offset(const struct lttng_kernel_probe_location *location, |
| 65 | uint64_t *offset); |
| 66 | |
| 67 | /* |
| 68 | * Create an address derived probe location. |
| 69 | * On failure, NULL is returned. |
| 70 | */ |
| 71 | LTTNG_EXPORT extern struct lttng_kernel_probe_location * |
| 72 | lttng_kernel_probe_location_address_create(uint64_t address); |
| 73 | |
| 74 | /* |
| 75 | * Get the address of an address derived probe location. |
| 76 | */ |
| 77 | LTTNG_EXPORT extern enum lttng_kernel_probe_location_status |
| 78 | lttng_kernel_probe_location_address_get_address(const struct lttng_kernel_probe_location *location, |
| 79 | uint64_t *offset); |
| 80 | |
| 81 | #ifdef __cplusplus |
| 82 | } |
| 83 | #endif |
| 84 | |
| 85 | #endif /* LTTNG_KERNEL_PROBE_H */ |