libsysprof: normalize binary path/nick empty strings

If we get an empty string, just normalize that to NULL so that we can be
more likely to match equality checks via hash comparison.

Additionally, break hashes out into two so that we can improve the
situation where some symbols do not have paths but still match. This
can happen with bundled symbols.
This commit is contained in:
Christian Hergert
2023-08-28 13:28:59 -07:00
parent e6d9f7c849
commit aad3441fee
2 changed files with 24 additions and 7 deletions

View File

@ -30,6 +30,7 @@ struct _SysprofSymbol
GObject parent_instance;
guint hash;
guint simple_hash;
GRefString *name;
GRefString *binary_path;
@ -71,14 +72,22 @@ _sysprof_symbol_equal (const SysprofSymbol *a,
if (a == b)
return TRUE;
if (a->hash != b->hash)
if (a->simple_hash != b->simple_hash)
return FALSE;
if (a->kind != b->kind)
return FALSE;
if (a->name == NULL || b->name == NULL)
return FALSE;
if (a->hash != b->hash)
{
/* Special case symbols w/o binary_path which can happen
* when we have symbols decoded from a bundled symbols.
*/
if (a->binary_path == NULL || b->binary_path == NULL)
return TRUE;
return FALSE;
}
return strcmp (a->name, b->name) == 0;
}