libsysprof-analyze: add flag to ignore system libraries

This commit is contained in:
Christian Hergert
2023-07-06 12:12:25 -07:00
parent c3e0235d99
commit c0a7a94d52
9 changed files with 131 additions and 32 deletions

View File

@ -213,7 +213,8 @@ static SysprofCallgraphNode *
sysprof_callgraph_add_trace (SysprofCallgraph *self,
SysprofSymbol **symbols,
guint n_symbols,
guint list_model_index)
guint list_model_index,
gboolean hide_system_libraries)
{
SysprofCallgraphNode *parent = NULL;
@ -238,6 +239,9 @@ sysprof_callgraph_add_trace (SysprofCallgraph *self,
SysprofSymbol *symbol = symbols[i-1];
SysprofCallgraphNode *node = NULL;
if (hide_system_libraries && _sysprof_symbol_is_system_library (symbol))
continue;
/* Try to find @symbol within the children of @parent */
for (SysprofCallgraphNode *iter = parent->children;
iter != NULL;
@ -335,7 +339,11 @@ sysprof_callgraph_add_traceable (SysprofCallgraph *self,
symbols[n_symbols++] = _sysprof_document_process_symbol (self->document, pid);
symbols[n_symbols++] = everything;
node = sysprof_callgraph_add_trace (self, symbols, n_symbols, list_model_index);
node = sysprof_callgraph_add_trace (self,
symbols,
n_symbols,
list_model_index,
!!(self->flags & SYSPROF_CALLGRAPH_FLAGS_HIDE_SYSTEM_LIBRARIES));
if (node && self->augment_func)
self->augment_func (self,

View File

@ -64,8 +64,9 @@ typedef void (*SysprofAugmentationFunc) (SysprofCallgraph *callgraph,
typedef enum _SysprofCallgraphFlags
{
SYSPROF_CALLGRAPH_FLAGS_NONE = 0,
SYSPROF_CALLGRAPH_FLAGS_INCLUDE_THREADS = 1 << 1,
SYSPROF_CALLGRAPH_FLAGS_NONE = 0,
SYSPROF_CALLGRAPH_FLAGS_INCLUDE_THREADS = 1 << 1,
SYSPROF_CALLGRAPH_FLAGS_HIDE_SYSTEM_LIBRARIES = 1 << 2,
} SysprofCallgraphFlags;
SYSPROF_AVAILABLE_IN_ALL

View File

@ -54,32 +54,18 @@ static const struct {
const char *nick;
} nick_table[] = {
{ "libc.so", "libc" },
{ "libcairo-gobject.so", "Cairo" },
{ "libcairo.so", "Cairo" },
{ "libclutter-1.0.so", "Clutter" },
{ "libclutter-glx-1.0.so", "Clutter" },
{ "libffi.so", "libffi" },
{ "libgjs.so", "GJS" },
{ "libgstreamer-1-0.so", "GStreamer" },
{ "libgudev-1.0.so", "udev" },
{ "libibus-1.0.so", "IBus" },
{ "libinput.so", "Mutter" },
{ "ld-linux-x86-64.so", "glibc" },
{ "libnss_sss.so", "NSS" },
{ "libsss_debug.so", "SSSD" },
{ "libsss_util.so", "SSSD" },
{ "libnss_systemd.so", "NSS" },
{ "libpcre2-8.so", "PCRE" },
{ "libpixman-1.so", "Pixman" },
{ "libpolkit-agent-1.so", "PolicyKit" },
{ "libpolkit-gobject-1.so", "PolicyKit" },
{ "libselinux.so", "SELinux" },
{ "libssl3.so", "NSS" },
{ "libstdc++.so", "libc" },
{ "libsystemd.so", "systemd" },
{ "libudev.so", "udev" },
{ "libvte-2.91.so", "VTE" },
{ "libvte-2.91-gtk4.so", "VTE" },
{ "libxul.so", "XUL" },
{ "libz.so", "Zlib" },
{ "libzstd.so", "Zstd" },
@ -90,6 +76,24 @@ static const struct {
{ "libgio-2.0.so", "Gio" },
{ "libgirepository-1.0.so", "Introspection" },
/* Cairo/Pixman */
{ "libcairo-gobject.so", "Cairo" },
{ "libcairo.so", "Cairo" },
{ "libpixman-1.so", "Pixman" },
/* Various GNOME Platform Libraries */
{ "libdex-1.so", "Dex" },
{ "libgjs.so", "GJS" },
{ "libgstreamer-1-0.so", "GStreamer" },
{ "libgudev-1.0.so", "udev" },
{ "libibus-1.0.so", "IBus" },
{ "libjson-glib-1.0.so", "JSON-GLib" },
{ "libjsonrpc-glib-1.0.so", "JSONRPC-GLib" },
{ "libpolkit-agent-1.so", "PolicyKit" },
{ "libpolkit-gobject-1.so", "PolicyKit" },
{ "libvte-2.91-gtk4.so", "VTE" },
{ "libvte-2.91.so", "VTE" },
/* Pango and Harfbuzz */
{ "libfribidi.so", "Fribidi" },
{ "libpango-1.0.so", "Pango" },
@ -122,6 +126,9 @@ static const struct {
{ "libwayland-server.so", "Wayland Server" },
/* Mutter/Clutter/Shell */
{ "libclutter-1.0.so", "Clutter" },
{ "libclutter-glx-1.0.so", "Clutter" },
{ "libinput.so", "libinput" },
{ "libmutter-12.so", "Mutter" },
{ "libmutter-cogl-12.so", "Mutter" },
{ "libmutter-clutter-12.so", "Mutter" },

View File

@ -85,4 +85,31 @@ _sysprof_symbol_is_context_switch (SysprofSymbol *symbol)
return symbol->kind == SYSPROF_SYMBOL_KIND_CONTEXT_SWITCH;
}
static inline gboolean
_sysprof_symbol_is_system_library (SysprofSymbol *symbol)
{
switch (symbol->kind)
{
case SYSPROF_SYMBOL_KIND_ROOT:
case SYSPROF_SYMBOL_KIND_PROCESS:
case SYSPROF_SYMBOL_KIND_THREAD:
case SYSPROF_SYMBOL_KIND_CONTEXT_SWITCH:
case SYSPROF_SYMBOL_KIND_UNWINDABLE:
default:
return FALSE;
case SYSPROF_SYMBOL_KIND_KERNEL:
return TRUE;
case SYSPROF_SYMBOL_KIND_USER:
if (symbol->binary_nick != NULL)
return TRUE;
if (symbol->binary_path != NULL)
return !!strstr (symbol->binary_path, "/usr/");
return FALSE;
}
}
G_END_DECLS