mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-gtk: show a list of backtraces on the right
When selecting a callback node, show all a list of all of the traces where that occurred on the right, so that you can select them individually. Currently this only shows pid/time for on the right, but we'll add another pane that will show the symbolized backtrace soon.
This commit is contained in:
@ -37,6 +37,7 @@ struct _SysprofCallgraphView
|
||||
GtkColumnView *callers_column_view;
|
||||
GtkColumnView *descendants_column_view;
|
||||
GtkColumnView *functions_column_view;
|
||||
GtkColumnView *traceables_column_view;
|
||||
GtkCustomSorter *descendants_name_sorter;
|
||||
GtkCustomSorter *functions_name_sorter;
|
||||
GtkScrolledWindow *scrolled_window;
|
||||
|
||||
@ -60,6 +60,51 @@ callers_selection_changed_cb (SysprofCallgraphView *self,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_callgraph_view_list_traceables_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
SysprofCallgraphFrame *frame = (SysprofCallgraphFrame *)object;
|
||||
g_autoptr(SysprofCallgraphView) self = user_data;
|
||||
g_autoptr(GListModel) model = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
g_assert (SYSPROF_IS_CALLGRAPH_FRAME (frame));
|
||||
g_assert (G_IS_ASYNC_RESULT (result));
|
||||
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
|
||||
|
||||
if ((model = sysprof_callgraph_frame_list_traceables_finish (frame, result, &error)))
|
||||
{
|
||||
g_autoptr(GtkSingleSelection) single = gtk_single_selection_new (g_object_ref (model));
|
||||
gtk_column_view_set_model (self->traceables_column_view, GTK_SELECTION_MODEL (single));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
descendants_selection_changed_cb (SysprofCallgraphView *self,
|
||||
guint position,
|
||||
guint n_items,
|
||||
GtkSingleSelection *single)
|
||||
{
|
||||
g_autoptr(GObject) item = NULL;
|
||||
GObject *object;
|
||||
|
||||
g_assert (SYSPROF_IS_CALLGRAPH_VIEW (self));
|
||||
g_assert (GTK_IS_SINGLE_SELECTION (single));
|
||||
|
||||
gtk_column_view_set_model (self->traceables_column_view, NULL);
|
||||
|
||||
if ((object = gtk_single_selection_get_selected_item (single)) &&
|
||||
GTK_IS_TREE_LIST_ROW (object) &&
|
||||
(item = gtk_tree_list_row_get_item (GTK_TREE_LIST_ROW (object))) &&
|
||||
SYSPROF_IS_CALLGRAPH_FRAME (item))
|
||||
sysprof_callgraph_frame_list_traceables_async (SYSPROF_CALLGRAPH_FRAME (item),
|
||||
NULL,
|
||||
sysprof_callgraph_view_list_traceables_cb,
|
||||
g_object_ref (self));
|
||||
}
|
||||
|
||||
static void
|
||||
functions_selection_changed_cb (SysprofCallgraphView *self,
|
||||
guint position,
|
||||
@ -126,6 +171,31 @@ sysprof_callgraph_view_key_pressed_cb (GtkTreeExpander *expander,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static char *
|
||||
format_time_offset (gpointer cell)
|
||||
{
|
||||
g_autoptr(SysprofDocumentFrame) frame = NULL;
|
||||
int hours;
|
||||
int minutes;
|
||||
double time;
|
||||
|
||||
g_object_get (cell, "item", &frame, NULL);
|
||||
g_assert (!frame || SYSPROF_IS_DOCUMENT_FRAME (frame));
|
||||
|
||||
if (!frame)
|
||||
return NULL;
|
||||
|
||||
time = sysprof_document_frame_get_time_offset (frame) / (double)SYSPROF_NSEC_PER_SEC;
|
||||
|
||||
hours = time / (60 * 60);
|
||||
time -= hours * (60 * 60);
|
||||
|
||||
minutes = time / 60;
|
||||
time -= minutes * 60;
|
||||
|
||||
return g_strdup_printf ("%02d:%02d:%02.4lf", hours, minutes, time);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_callgraph_view_dispose (GObject *object)
|
||||
{
|
||||
@ -231,7 +301,9 @@ sysprof_callgraph_view_class_init (SysprofCallgraphViewClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, functions_name_sorter);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, paned);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, scrolled_window);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofCallgraphView, traceables_column_view);
|
||||
gtk_widget_class_bind_template_callback (widget_class, sysprof_callgraph_view_key_pressed_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, format_time_offset);
|
||||
|
||||
klass->augment_size = GLIB_SIZEOF_VOID_P;
|
||||
|
||||
@ -290,7 +362,7 @@ sysprof_callgraph_view_reload_cb (GObject *object,
|
||||
GtkSorter *column_sorter;
|
||||
|
||||
g_autoptr(GtkTreeListRowSorter) descendants_sorter = NULL;
|
||||
g_autoptr(GtkMultiSelection) descendants_selection = NULL;
|
||||
g_autoptr(GtkSingleSelection) descendants_selection = NULL;
|
||||
g_autoptr(GtkSortListModel) descendants_sort_model = NULL;
|
||||
g_autoptr(GtkTreeListModel) descendants_tree = NULL;
|
||||
g_autoptr(GtkTreeListRow) descendants_first = NULL;
|
||||
@ -319,7 +391,12 @@ sysprof_callgraph_view_reload_cb (GObject *object,
|
||||
descendants_sorter = gtk_tree_list_row_sorter_new (g_object_ref (column_sorter));
|
||||
descendants_sort_model = gtk_sort_list_model_new (g_object_ref (G_LIST_MODEL (descendants_tree)),
|
||||
g_object_ref (GTK_SORTER (descendants_sorter)));
|
||||
descendants_selection = gtk_multi_selection_new (g_object_ref (G_LIST_MODEL (descendants_sort_model)));
|
||||
descendants_selection = gtk_single_selection_new (g_object_ref (G_LIST_MODEL (descendants_sort_model)));
|
||||
g_signal_connect_object (descendants_selection,
|
||||
"selection-changed",
|
||||
G_CALLBACK (descendants_selection_changed_cb),
|
||||
self,
|
||||
G_CONNECT_SWAPPED);
|
||||
gtk_column_view_set_model (self->descendants_column_view, GTK_SELECTION_MODEL (descendants_selection));
|
||||
|
||||
column_sorter = gtk_column_view_get_sorter (self->functions_column_view);
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
<property name="text-overflow">ellipsize-start</property>
|
||||
<property name="xalign">.0</property>
|
||||
<binding name="text">
|
||||
<lookup name="name">
|
||||
<lookup name="name">
|
||||
<lookup name="symbol" type="SysprofCallgraphSymbol">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
@ -76,7 +76,7 @@
|
||||
<property name="text-overflow">ellipsize-start</property>
|
||||
<property name="xalign">.0</property>
|
||||
<binding name="text">
|
||||
<lookup name="name">
|
||||
<lookup name="name">
|
||||
<lookup name="symbol" type="SysprofCallgraphSymbol">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
@ -99,23 +99,26 @@
|
||||
</object>
|
||||
</property>
|
||||
<property name="end-child">
|
||||
<object class="GtkScrolledWindow" id="scrolled_window">
|
||||
<child>
|
||||
<object class="GtkColumnView" id="descendants_column_view">
|
||||
<style>
|
||||
<class name="data-table"/>
|
||||
</style>
|
||||
<object class="GtkPaned">
|
||||
<property name="start-child">
|
||||
<object class="GtkScrolledWindow" id="scrolled_window">
|
||||
<property name="hexpand">true</property>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="descendants_column">
|
||||
<property name="title" translatable="yes">Descendants</property>
|
||||
<property name="expand">true</property>
|
||||
<property name="sorter">
|
||||
<object class="GtkCustomSorter" id="descendants_name_sorter">
|
||||
</object>
|
||||
</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<object class="GtkColumnView" id="descendants_column_view">
|
||||
<style>
|
||||
<class name="data-table"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="descendants_column">
|
||||
<property name="title" translatable="yes">Descendants</property>
|
||||
<property name="expand">true</property>
|
||||
<property name="sorter">
|
||||
<object class="GtkCustomSorter" id="descendants_name_sorter">
|
||||
</object>
|
||||
</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
@ -182,13 +185,89 @@
|
||||
</template>
|
||||
</interface>
|
||||
]]>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</property>
|
||||
<property name="end-child">
|
||||
<object class="GtkPaned">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="start-child">
|
||||
<object class="GtkScrolledWindow">
|
||||
<child>
|
||||
<object class="GtkColumnView" id="traceables_column_view">
|
||||
<property name="width-request">200</property>
|
||||
<style>
|
||||
<class name="data-table"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="traceables_pid_column">
|
||||
<property name="title" translatable="yes">PID</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkInscription">
|
||||
<property name="xalign">1.</property>
|
||||
<binding name="text">
|
||||
<lookup name="pid" type="SysprofDocumentFrame">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkColumnViewColumn" id="traceables_time_column">
|
||||
<property name="title" translatable="yes">Time</property>
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="GtkLabel">
|
||||
<property name="xalign">0</property>
|
||||
<attributes>
|
||||
<attribute name="font-features" value="'tnum'"/>
|
||||
</attributes>
|
||||
<binding name="label">
|
||||
<closure type="gchararray" function="format_time_offset">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
Reference in New Issue
Block a user