X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fkernel-probe.c;h=d2637f933efa18afb243049353cdab4c089908a2;hp=27ca02c99d09ea03212bd7d1489221d17270f50c;hb=959e3c66727698e58a8788aceeda5820b3c938ba;hpb=76992d4d80834399b1b08bc21eca634f22d18017 diff --git a/src/common/kernel-probe.c b/src/common/kernel-probe.c index 27ca02c99..d2637f933 100644 --- a/src/common/kernel-probe.c +++ b/src/common/kernel-probe.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include #include @@ -39,6 +41,14 @@ bool lttng_kernel_probe_location_symbol_is_equal( const struct lttng_kernel_probe_location *a, const struct lttng_kernel_probe_location *b); +static +unsigned long lttng_kernel_probe_location_address_hash( + const struct lttng_kernel_probe_location *location); + +static +unsigned long lttng_kernel_probe_location_symbol_hash( + const struct lttng_kernel_probe_location *location); + enum lttng_kernel_probe_location_type lttng_kernel_probe_location_get_type( const struct lttng_kernel_probe_location *location) { @@ -109,6 +119,7 @@ lttng_kernel_probe_location_address_create(uint64_t address) ret->type = LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS; ret->equal = lttng_kernel_probe_location_address_is_equal; ret->serialize = lttng_kernel_probe_location_address_serialize; + ret->hash = lttng_kernel_probe_location_address_hash; end: return ret; @@ -145,6 +156,7 @@ lttng_kernel_probe_location_symbol_create(const char *symbol_name, ret->type = LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET; ret->equal = lttng_kernel_probe_location_symbol_is_equal; ret->serialize = lttng_kernel_probe_location_symbol_serialize; + ret->hash = lttng_kernel_probe_location_symbol_hash; goto end; error: @@ -489,6 +501,22 @@ end: return ret; } +static +unsigned long lttng_kernel_probe_location_address_hash( + const struct lttng_kernel_probe_location *location) +{ + unsigned long hash = hash_key_ulong( + (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS, + lttng_ht_seed); + struct lttng_kernel_probe_location_address *address_location = + container_of(location, typeof(*address_location), + parent); + + hash ^= hash_key_u64(&address_location->address, lttng_ht_seed); + + return hash; +} + static bool lttng_kernel_probe_location_address_is_equal( const struct lttng_kernel_probe_location *_a, @@ -512,6 +540,23 @@ end: return is_equal; } +static +unsigned long lttng_kernel_probe_location_symbol_hash( + const struct lttng_kernel_probe_location *location) +{ + unsigned long hash = hash_key_ulong( + (void *) LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET, + lttng_ht_seed); + struct lttng_kernel_probe_location_symbol *symbol_location = + container_of(location, typeof(*symbol_location), + parent); + + hash ^= hash_key_str(symbol_location->symbol_name, lttng_ht_seed); + hash ^= hash_key_u64(&symbol_location->offset, lttng_ht_seed); + + return hash; +} + static bool lttng_kernel_probe_location_symbol_is_equal( const struct lttng_kernel_probe_location *_a, @@ -672,3 +717,10 @@ struct lttng_kernel_probe_location *lttng_kernel_probe_location_copy( err: return new_location; } + +LTTNG_HIDDEN +unsigned long lttng_kernel_probe_location_hash( + const struct lttng_kernel_probe_location *location) +{ + return location->hash(location); +}