From a3df31c246203e9c0b69326ff3a57b79abe01258 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 12 Jun 2023 17:21:28 -0700 Subject: [PATCH] libsysprof-analyze: include binary path basename in hash This helps improve the chances that we get a match on "libfoo.so" and the symbol name within it. --- src/libsysprof-analyze/sysprof-symbol.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libsysprof-analyze/sysprof-symbol.c b/src/libsysprof-analyze/sysprof-symbol.c index 1d44209e..48936c62 100644 --- a/src/libsysprof-analyze/sysprof-symbol.c +++ b/src/libsysprof-analyze/sysprof-symbol.c @@ -146,6 +146,21 @@ _sysprof_symbol_new (GRefString *name, self->end_address = end_address; self->hash = g_str_hash (name); + /* If we got a path for the symbol, add that to the hash so that we + * can be sure that we're working with a symbol in the same file when + * there are collisions. + * + * That way, we have a chance of joining symbols from different runtimes + * and/or containers, but only if they are reasonably the same ABI. + */ + if (binary_path != NULL) + { + const char *base = strrchr (binary_path, '/'); + + if (base != NULL) + self->hash ^= g_str_hash (base); + } + return self; }