[sysprof/wip/chergert/sysprof-3] libsysprof: add trailing empty kernel node
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] libsysprof: add trailing empty kernel node
- Date: Tue, 28 May 2019 20:55:42 +0000 (UTC)
commit 8c2d995e7db3f7b5fa6b18689adf749c48ee229b
Author: Christian Hergert <chergert redhat com>
Date: Tue May 28 13:54:14 2019 -0700
libsysprof: add trailing empty kernel node
This can be used so that we always know a symbol will be after the returned
symbol (so we can look for peer address).
src/libsysprof/sysprof-kernel-symbol.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/libsysprof/sysprof-kernel-symbol.c b/src/libsysprof/sysprof-kernel-symbol.c
index 3213c8b..98d5f7b 100644
--- a/src/libsysprof/sysprof-kernel-symbol.c
+++ b/src/libsysprof/sysprof-kernel-symbol.c
@@ -111,6 +111,7 @@ do_shared_init (void)
SysprofKernelSymbols *
_sysprof_kernel_symbols_new_from_kallsyms (SysprofKallsyms *kallsyms)
{
+ static const SysprofKernelSymbol empty = {0};
SysprofKernelSymbols *self;
const gchar *name;
guint64 addr;
@@ -123,6 +124,7 @@ _sysprof_kernel_symbols_new_from_kallsyms (SysprofKallsyms *kallsyms)
self = g_array_new (FALSE, FALSE, sizeof (SysprofKernelSymbol));
G_LOCK (kernel_lock);
+
while (sysprof_kallsyms_next (kallsyms, &name, &addr, &type))
{
if (!type_is_ignored (type))
@@ -135,10 +137,14 @@ _sysprof_kernel_symbols_new_from_kallsyms (SysprofKallsyms *kallsyms)
g_array_append_val (self, sym);
}
}
- G_UNLOCK (kernel_lock);
g_array_sort (self, sysprof_kernel_symbol_compare);
+ /* Always add a trailing node */
+ g_array_append_val (self, empty);
+
+ G_UNLOCK (kernel_lock);
+
return g_steal_pointer (&self);
}
@@ -224,7 +230,8 @@ _sysprof_kernel_symbols_lookup (const SysprofKernelSymbols *self,
ret = sysprof_kernel_symbol_lookup ((SysprofKernelSymbol *)(gpointer)self->data,
address,
0,
- self->len - 1);
+ /* 1 for right-most, 1 for empty node */
+ self->len - 2);
/* We resolve all symbols, including ignored symbols so that we
* don't give back the wrong function juxtapose an ignored func.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]