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

@ -52,6 +52,7 @@ struct _SysprofCallgraphView
guint reload_source;
guint include_threads : 1;
guint hide_system_libraries : 1;
};
struct _SysprofCallgraphViewClass

View File

@ -31,6 +31,7 @@ enum {
PROP_0,
PROP_CALLGRAPH,
PROP_DOCUMENT,
PROP_HIDE_SYSTEM_LIBRARIES,
PROP_INCLUDE_THREADS,
PROP_TRACEABLES,
N_PROPS
@ -385,6 +386,10 @@ sysprof_callgraph_view_get_property (GObject *object,
g_value_set_object (value, sysprof_callgraph_view_get_document (self));
break;
case PROP_HIDE_SYSTEM_LIBRARIES:
g_value_set_boolean (value, sysprof_callgraph_view_get_hide_system_libraries (self));
break;
case PROP_INCLUDE_THREADS:
g_value_set_boolean (value, sysprof_callgraph_view_get_include_threads (self));
break;
@ -412,6 +417,10 @@ sysprof_callgraph_view_set_property (GObject *object,
sysprof_callgraph_view_set_document (self, g_value_get_object (value));
break;
case PROP_HIDE_SYSTEM_LIBRARIES:
sysprof_callgraph_view_set_hide_system_libraries (self, g_value_get_boolean (value));
break;
case PROP_INCLUDE_THREADS:
sysprof_callgraph_view_set_include_threads (self, g_value_get_boolean (value));
break;
@ -445,6 +454,11 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass)
SYSPROF_TYPE_DOCUMENT,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties[PROP_HIDE_SYSTEM_LIBRARIES] =
g_param_spec_boolean ("hide-system-libraries", NULL, NULL,
FALSE,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties[PROP_INCLUDE_THREADS] =
g_param_spec_boolean ("include-threads", NULL, NULL,
FALSE,
@ -590,6 +604,9 @@ sysprof_callgraph_view_reload (SysprofCallgraphView *self)
if (self->include_threads)
flags |= SYSPROF_CALLGRAPH_FLAGS_INCLUDE_THREADS;
if (self->hide_system_libraries)
flags |= SYSPROF_CALLGRAPH_FLAGS_HIDE_SYSTEM_LIBRARIES;
sysprof_document_callgraph_async (self->document,
flags,
self->traceables,
@ -724,6 +741,30 @@ sysprof_callgraph_view_get_callgraph (SysprofCallgraphView *self)
return self->callgraph;
}
gboolean
sysprof_callgraph_view_get_hide_system_libraries (SysprofCallgraphView *self)
{
g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self), FALSE);
return self->hide_system_libraries;
}
void
sysprof_callgraph_view_set_hide_system_libraries (SysprofCallgraphView *self,
gboolean hide_system_libraries)
{
g_return_if_fail (SYSPROF_IS_CALLGRAPH_VIEW (self));
hide_system_libraries = !!hide_system_libraries;
if (self->hide_system_libraries != hide_system_libraries)
{
self->hide_system_libraries = hide_system_libraries;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HIDE_SYSTEM_LIBRARIES]);
sysprof_callgraph_view_queue_reload (self);
}
}
gboolean
sysprof_callgraph_view_get_include_threads (SysprofCallgraphView *self)
{

View File

@ -36,24 +36,29 @@ typedef struct _SysprofCallgraphView SysprofCallgraphView;
typedef struct _SysprofCallgraphViewClass SysprofCallgraphViewClass;
SYSPROF_AVAILABLE_IN_ALL
GType sysprof_callgraph_view_get_type (void) G_GNUC_CONST;
GType sysprof_callgraph_view_get_type (void) G_GNUC_CONST;
SYSPROF_AVAILABLE_IN_ALL
SysprofCallgraph *sysprof_callgraph_view_get_callgraph (SysprofCallgraphView *self);
SysprofCallgraph *sysprof_callgraph_view_get_callgraph (SysprofCallgraphView *self);
SYSPROF_AVAILABLE_IN_ALL
SysprofDocument *sysprof_callgraph_view_get_document (SysprofCallgraphView *self);
SysprofDocument *sysprof_callgraph_view_get_document (SysprofCallgraphView *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_callgraph_view_set_document (SysprofCallgraphView *self,
SysprofDocument *document);
void sysprof_callgraph_view_set_document (SysprofCallgraphView *self,
SysprofDocument *document);
SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_callgraph_view_get_traceables (SysprofCallgraphView *self);
GListModel *sysprof_callgraph_view_get_traceables (SysprofCallgraphView *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_callgraph_view_set_traceables (SysprofCallgraphView *self,
GListModel *model);
void sysprof_callgraph_view_set_traceables (SysprofCallgraphView *self,
GListModel *model);
SYSPROF_AVAILABLE_IN_ALL
gboolean sysprof_callgraph_view_get_include_threads (SysprofCallgraphView *self);
gboolean sysprof_callgraph_view_get_include_threads (SysprofCallgraphView *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_callgraph_view_set_include_threads (SysprofCallgraphView *self,
gboolean include_threads);
void sysprof_callgraph_view_set_include_threads (SysprofCallgraphView *self,
gboolean include_threads);
SYSPROF_AVAILABLE_IN_ALL
gboolean sysprof_callgraph_view_get_hide_system_libraries (SysprofCallgraphView *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_callgraph_view_set_hide_system_libraries (SysprofCallgraphView *self,
gboolean hide_system_libraries);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCallgraphView, g_object_unref)

View File

@ -29,9 +29,11 @@ static GMainLoop *main_loop;
static char *kallsyms_path;
static char *filename;
static gboolean include_threads;
static gboolean hide_system_libraries;
static const GOptionEntry entries[] = {
{ "kallsyms", 'k', 0, G_OPTION_ARG_FILENAME, &kallsyms_path, "The path to kallsyms to use for decoding", "PATH" },
{ "threads", 't', 0, G_OPTION_ARG_NONE, &include_threads, "Include threads in the callgraph" },
{ "hide-system-libraries", 's', 0, G_OPTION_ARG_NONE, &hide_system_libraries, "Hide system libraries in the callgraph" },
{ 0 }
};
@ -73,6 +75,7 @@ main (int argc,
GtkWidget *progress;
GtkWidget *message;
GtkWidget *threads;
GtkWidget *system_libs;
GtkWindow *window;
sysprof_clock_init ();
@ -134,8 +137,14 @@ main (int argc,
"active", include_threads,
NULL);
gtk_box_append (GTK_BOX (hbox), threads);
gtk_box_append (GTK_BOX (hbox), gtk_label_new ("Hide System Libraries"));
system_libs = g_object_new (GTK_TYPE_SWITCH,
"active", hide_system_libraries,
NULL);
gtk_box_append (GTK_BOX (hbox), system_libs);
view = g_object_new (SYSPROF_TYPE_WEIGHTED_CALLGRAPH_VIEW,
"include-threads", include_threads,
"hide-system-libraries", hide_system_libraries,
"vexpand", TRUE,
NULL);
gtk_box_append (GTK_BOX (box), GTK_WIDGET (view));
@ -159,6 +168,7 @@ main (int argc,
gtk_window_present (window);
g_object_bind_property (threads, "active", view, "include-threads", 0);
g_object_bind_property (system_libs, "active", view, "hide-system-libraries", 0);
g_object_bind_property (loader, "message", message, "label", 0);
g_object_bind_property (loader, "fraction", progress, "fraction", 0);

View File

@ -187,9 +187,8 @@
<menu id="view_menu">
<section>
<attribute name="label">Callgraph</attribute>
<item>
<attribute name="label">Show Threads</attribute>
</item>
<item><attribute name="label">Show Threads</attribute></item>
<item><attribute name="label">Show System Libraries</attribute></item>
</section>
</menu>
<menu id="omni_menu">