*** empty log message ***

This commit is contained in:
Søren Sandmann Pedersen
2004-11-05 16:57:40 +00:00
parent 17febd9bbe
commit c27b97c7c0
3 changed files with 152 additions and 47 deletions

View File

@ -21,7 +21,7 @@
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Soeren Sandmann (sandmann@daimi.au.dk)"); MODULE_AUTHOR("Soeren Sandmann (sandmann@daimi.au.dk)");
#define SAMPLES_PER_SECOND (30) #define SAMPLES_PER_SECOND (100)
#define INTERVAL (HZ / SAMPLES_PER_SECOND) #define INTERVAL (HZ / SAMPLES_PER_SECOND)
#define N_TRACES 256 #define N_TRACES 256
@ -316,6 +316,8 @@ procfile_read(char *buffer,
int *eof, int *eof,
void *data) void *data)
{ {
if (head == tail)
return -EWOULDBLOCK;
wait_event_interruptible (wait_for_trace, head != tail); wait_event_interruptible (wait_for_trace, head != tail);
*buffer_location = (char *)tail; *buffer_location = (char *)tail;
if (tail++ == &stack_traces[N_TRACES - 1]) if (tail++ == &stack_traces[N_TRACES - 1])

126
sysprof.c
View File

@ -4,6 +4,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <glade/glade.h> #include <glade/glade.h>
#include <errno.h>
#include "binfile.h" #include "binfile.h"
#include "watch.h" #include "watch.h"
@ -37,8 +38,9 @@ struct Application
GtkWidget * start_button; GtkWidget * start_button;
GtkWidget * profile_button; GtkWidget * profile_button;
GtkWidget * open_button; GtkWidget * reset_button;
GtkWidget * save_as_button; GtkWidget * save_as_button;
GtkWidget * dummy_button;
GtkWidget * start_item; GtkWidget * start_item;
GtkWidget * profile_item; GtkWidget * profile_item;
@ -68,7 +70,9 @@ update_sensitivity (Application *app)
gboolean sensitive_profile_button; gboolean sensitive_profile_button;
gboolean sensitive_save_as_button; gboolean sensitive_save_as_button;
gboolean sensitive_start_button; gboolean sensitive_start_button;
gboolean active_profile_button; gboolean sensitive_tree_views;
GtkWidget *active_radio_button;
switch (app->state) switch (app->state)
{ {
@ -76,35 +80,41 @@ update_sensitivity (Application *app)
sensitive_profile_button = FALSE; sensitive_profile_button = FALSE;
sensitive_save_as_button = FALSE; sensitive_save_as_button = FALSE;
sensitive_start_button = TRUE; sensitive_start_button = TRUE;
active_profile_button = FALSE; sensitive_tree_views = FALSE;
active_radio_button = app->dummy_button;
break; break;
case PROFILING: case PROFILING:
sensitive_profile_button = (app->n_samples > 0); sensitive_profile_button = (app->n_samples > 0);
sensitive_save_as_button = (app->n_samples > 0); sensitive_save_as_button = (app->n_samples > 0);
sensitive_start_button = TRUE; sensitive_start_button = TRUE;
active_profile_button = FALSE; sensitive_tree_views = FALSE;
active_radio_button = app->start_button;
break; break;
case DISPLAYING: case DISPLAYING:
sensitive_profile_button = FALSE; sensitive_profile_button = TRUE;
sensitive_save_as_button = TRUE; sensitive_save_as_button = TRUE;
sensitive_start_button = TRUE; sensitive_start_button = TRUE;
active_profile_button = TRUE; sensitive_tree_views = TRUE;
active_radio_button = app->profile_button;
break; break;
} }
gtk_widget_set_sensitive (GTK_WIDGET (app->profile_button), gtk_widget_set_sensitive (GTK_WIDGET (app->profile_button),
sensitive_profile_button); sensitive_profile_button);
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (app->profile_button), gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (active_radio_button), TRUE);
active_profile_button);
gtk_widget_set_sensitive (GTK_WIDGET (app->save_as_button), gtk_widget_set_sensitive (GTK_WIDGET (app->save_as_button),
sensitive_save_as_button); sensitive_save_as_button);
gtk_widget_set_sensitive (GTK_WIDGET (app->start_button), gtk_widget_set_sensitive (GTK_WIDGET (app->start_button),
sensitive_start_button); sensitive_start_button);
gtk_widget_set_sensitive (GTK_WIDGET (app->object_view), sensitive_tree_views);
gtk_widget_set_sensitive (GTK_WIDGET (app->callers_view), sensitive_tree_views);
gtk_widget_set_sensitive (GTK_WIDGET (app->descendants_view), sensitive_tree_views);
} }
#if 0 #if 0
@ -157,6 +167,9 @@ on_read (gpointer data)
if (app->state != PROFILING) if (app->state != PROFILING)
return; return;
if (rd == -1 && errno == EWOULDBLOCK)
return;
#if 0 #if 0
g_print ("pid: %d\n", trace.pid); g_print ("pid: %d\n", trace.pid);
for (i=0; i < trace.n_addresses; ++i) for (i=0; i < trace.n_addresses; ++i)
@ -190,10 +203,8 @@ on_read (gpointer data)
} }
static void static void
on_start_clicked (GtkToggleToolButton *tool_button, gpointer data) delete_data (Application *app)
{ {
Application *app = data;
if (app->profile) if (app->profile)
{ {
profile_free (app->profile); profile_free (app->profile);
@ -210,7 +221,17 @@ on_start_clicked (GtkToggleToolButton *tool_button, gpointer data)
process_flush_caches (); process_flush_caches ();
app->n_samples = 0; app->n_samples = 0;
show_samples (app); show_samples (app);
}
static void
on_start_toggled (GtkToggleToolButton *tool_button, gpointer data)
{
Application *app = data;
if (!gtk_toggle_tool_button_get_active (tool_button))
return;
delete_data (app);
app->state = PROFILING; app->state = PROFILING;
update_sensitivity (app); update_sensitivity (app);
} }
@ -313,17 +334,32 @@ on_profile_toggled (gpointer widget, gpointer data)
app->state = DISPLAYING; app->state = DISPLAYING;
#if 0
gtk_tree_view_columns_autosize (app->object_view);
gtk_tree_view_columns_autosize (app->callers_view);
gtk_tree_view_columns_autosize (app->descendants_view);
#endif
update_sensitivity (app); update_sensitivity (app);
} }
static void static void
on_open_clicked (gpointer widget, gpointer data) on_open_clicked (gpointer widget, gpointer data)
{
}
static void
on_reset_clicked (gpointer widget, gpointer data)
{ {
Application *app = data; Application *app = data;
if (app) delete_data (app);
;
/* FIXME */ if (app->state == DISPLAYING)
app->state = INITIAL;
update_sensitivity (app);
} }
static void static void
@ -612,13 +648,28 @@ on_callers_row_activated (GtkTreeView *tree_view,
} }
static void static void
get_default_size (int *w, int *h) set_sizes (GtkWindow *window,
GtkWidget *hpaned,
GtkWidget *vpaned)
{ {
/* FIXME, this should really be some percentage of the screen, GdkScreen *screen;
* and the window size should be stored in gconf etc. int monitor_num;
*/ GdkRectangle monitor;
*w = 700; int width, height;
*h = 480; GtkWidget *widget = GTK_WIDGET (window);
screen = gtk_widget_get_screen (widget);
monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
width = monitor.width * 3 / 4;
height = monitor.height * 3 / 4;
gtk_window_resize (window, width, height);
gtk_paned_set_position (GTK_PANED (vpaned), height / 2);
gtk_paned_set_position (GTK_PANED (hpaned), width / 2);
} }
static void static void
@ -627,7 +678,7 @@ build_gui (Application *app)
GladeXML *xml; GladeXML *xml;
GtkWidget *main_window; GtkWidget *main_window;
GtkTreeSelection *selection; GtkTreeSelection *selection;
int w, h; GtkTreeViewColumn *col;
xml = glade_xml_new ("./sysprof.glade", NULL, NULL); xml = glade_xml_new ("./sysprof.glade", NULL, NULL);
@ -651,7 +702,7 @@ build_gui (Application *app)
g_assert (app->open_item); g_assert (app->open_item);
g_signal_connect (G_OBJECT (app->start_item), "activate", g_signal_connect (G_OBJECT (app->start_item), "activate",
G_CALLBACK (on_start_clicked), app); G_CALLBACK (on_start_toggled), app);
g_signal_connect (G_OBJECT (app->profile_item), "activate", g_signal_connect (G_OBJECT (app->profile_item), "activate",
G_CALLBACK (on_profile_toggled), app); G_CALLBACK (on_profile_toggled), app);
@ -670,54 +721,65 @@ build_gui (Application *app)
app->start_button = glade_xml_get_widget (xml, "start_button"); app->start_button = glade_xml_get_widget (xml, "start_button");
app->profile_button = glade_xml_get_widget (xml, "profile_button"); app->profile_button = glade_xml_get_widget (xml, "profile_button");
app->open_button = glade_xml_get_widget (xml, "open_button"); app->reset_button = glade_xml_get_widget (xml, "reset_button");
app->save_as_button = glade_xml_get_widget (xml, "save_as_button"); app->save_as_button = glade_xml_get_widget (xml, "save_as_button");
app->dummy_button = glade_xml_get_widget (xml, "dummy_button");
gtk_widget_hide (app->dummy_button);
gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON ( gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (
app->profile_button), FALSE); app->profile_button), FALSE);
g_signal_connect (G_OBJECT (app->start_button), "clicked", g_signal_connect (G_OBJECT (app->start_button), "toggled",
G_CALLBACK (on_start_clicked), app); G_CALLBACK (on_start_toggled), app);
g_signal_connect (G_OBJECT (app->profile_button), "toggled", g_signal_connect (G_OBJECT (app->profile_button), "toggled",
G_CALLBACK (on_profile_toggled), app); G_CALLBACK (on_profile_toggled), app);
g_signal_connect (G_OBJECT (app->open_button), "clicked", g_signal_connect (G_OBJECT (app->reset_button), "clicked",
G_CALLBACK (on_open_clicked), app); G_CALLBACK (on_reset_clicked), app);
g_signal_connect (G_OBJECT (app->save_as_button), "clicked", g_signal_connect (G_OBJECT (app->save_as_button), "clicked",
G_CALLBACK (on_save_as_clicked), app); G_CALLBACK (on_save_as_clicked), app);
get_default_size (&w, &h); gtk_widget_realize (GTK_WIDGET (main_window));
set_sizes (GTK_WINDOW (main_window),
glade_xml_get_widget (xml, "hpaned"),
glade_xml_get_widget (xml, "vpaned"));
gtk_window_set_default_size (GTK_WINDOW (main_window), w, h);
/* TreeViews */ /* TreeViews */
/* object view */ /* object view */
app->object_view = (GtkTreeView *)glade_xml_get_widget (xml, "object_view"); app->object_view = (GtkTreeView *)glade_xml_get_widget (xml, "object_view");
add_plain_text_column (app->object_view, _("Name"), OBJECT_NAME); col = add_plain_text_column (app->object_view, _("Name"), OBJECT_NAME);
add_double_format_column (app->object_view, _("Self"), OBJECT_SELF, "%.2f"); add_double_format_column (app->object_view, _("Self"), OBJECT_SELF, "%.2f");
add_double_format_column (app->object_view, _("Total"), OBJECT_TOTAL, "%.2f"); add_double_format_column (app->object_view, _("Total"), OBJECT_TOTAL, "%.2f");
selection = gtk_tree_view_get_selection (app->object_view); selection = gtk_tree_view_get_selection (app->object_view);
g_signal_connect (selection, "changed", G_CALLBACK (on_object_selection_changed), app); g_signal_connect (selection, "changed", G_CALLBACK (on_object_selection_changed), app);
gtk_tree_view_column_set_expand (col, TRUE);
/* callers view */ /* callers view */
app->callers_view = (GtkTreeView *)glade_xml_get_widget (xml, "callers_view"); app->callers_view = (GtkTreeView *)glade_xml_get_widget (xml, "callers_view");
add_plain_text_column (app->callers_view, _("Name"), CALLERS_NAME); col = add_plain_text_column (app->callers_view, _("Name"), CALLERS_NAME);
add_double_format_column (app->callers_view, _("Self"), CALLERS_SELF, "%.2f"); add_double_format_column (app->callers_view, _("Self"), CALLERS_SELF, "%.2f");
add_double_format_column (app->callers_view, _("Total"), CALLERS_TOTAL, "%.2f"); add_double_format_column (app->callers_view, _("Total"), CALLERS_TOTAL, "%.2f");
g_signal_connect (app->callers_view, "row-activated", g_signal_connect (app->callers_view, "row-activated",
G_CALLBACK (on_callers_row_activated), app); G_CALLBACK (on_callers_row_activated), app);
gtk_tree_view_column_set_expand (col, TRUE);
/* descendants view */ /* descendants view */
app->descendants_view = (GtkTreeView *)glade_xml_get_widget (xml, "descendants_view"); app->descendants_view = (GtkTreeView *)glade_xml_get_widget (xml, "descendants_view");
add_plain_text_column (app->descendants_view, _("Name"), DESCENDANTS_NAME); col = add_plain_text_column (app->descendants_view, _("Name"), DESCENDANTS_NAME);
add_double_format_column (app->descendants_view, _("Self"), DESCENDANTS_SELF, "%.2f"); add_double_format_column (app->descendants_view, _("Self"), DESCENDANTS_SELF, "%.2f");
add_double_format_column (app->descendants_view, _("Cummulative"), DESCENDANTS_NON_RECURSE, "%.2f"); add_double_format_column (app->descendants_view, _("Cummulative"), DESCENDANTS_NON_RECURSE, "%.2f");
g_signal_connect (app->descendants_view, "row-activated", g_signal_connect (app->descendants_view, "row-activated",
G_CALLBACK (on_descendants_row_activated), app); G_CALLBACK (on_descendants_row_activated), app);
gtk_tree_view_column_set_expand (col, TRUE);
/* Statusbar */ /* Statusbar */
app->statusbar = (GtkStatusbar *)glade_xml_get_widget (xml, "statusbar"); app->statusbar = (GtkStatusbar *)glade_xml_get_widget (xml, "statusbar");
show_samples (app); show_samples (app);

View File

@ -91,7 +91,7 @@
<signal name="activate" handler="on_start1_activate" last_modification_time="Thu, 04 Nov 2004 18:51:54 GMT"/> <signal name="activate" handler="on_start1_activate" last_modification_time="Thu, 04 Nov 2004 18:51:54 GMT"/>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image8"> <widget class="GtkImage" id="image10">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-media-play</property> <property name="stock">gtk-media-play</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -112,7 +112,7 @@
<signal name="activate" handler="on_profile1_activate" last_modification_time="Thu, 04 Nov 2004 18:51:54 GMT"/> <signal name="activate" handler="on_profile1_activate" last_modification_time="Thu, 04 Nov 2004 18:51:54 GMT"/>
<child internal-child="image"> <child internal-child="image">
<widget class="GtkImage" id="image9"> <widget class="GtkImage" id="image11">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-justify-left</property> <property name="stock">gtk-justify-left</property>
<property name="icon_size">1</property> <property name="icon_size">1</property>
@ -124,6 +124,27 @@
</child> </child>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkImageMenuItem" id="reset_item">
<property name="visible">True</property>
<property name="label" translatable="yes">_Reset</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_reset_item_activate" last_modification_time="Fri, 05 Nov 2004 15:34:30 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image12">
<property name="visible">True</property>
<property name="stock">gtk-clear</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget> </widget>
</child> </child>
</widget> </widget>
@ -167,7 +188,7 @@
<property name="show_arrow">True</property> <property name="show_arrow">True</property>
<child> <child>
<widget class="GtkToolButton" id="start_button"> <widget class="GtkRadioToolButton" id="start_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">S_tart</property> <property name="label" translatable="yes">S_tart</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -175,6 +196,7 @@
<property name="visible_horizontal">True</property> <property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property> <property name="visible_vertical">True</property>
<property name="is_important">True</property> <property name="is_important">True</property>
<property name="active">False</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -183,7 +205,7 @@
</child> </child>
<child> <child>
<widget class="GtkToggleToolButton" id="profile_button"> <widget class="GtkRadioToolButton" id="profile_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Profile</property> <property name="label" translatable="yes">_Profile</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -192,6 +214,23 @@
<property name="visible_vertical">True</property> <property name="visible_vertical">True</property>
<property name="is_important">True</property> <property name="is_important">True</property>
<property name="active">False</property> <property name="active">False</property>
<property name="group">start_button</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<widget class="GtkToolButton" id="reset_button">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-clear</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
<property name="is_important">False</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -222,12 +261,12 @@
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="open_button"> <widget class="GtkToolButton" id="save_as_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock_id">gtk-open</property> <property name="stock_id">gtk-save-as</property>
<property name="visible_horizontal">True</property> <property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property> <property name="visible_vertical">True</property>
<property name="is_important">False</property> <property name="is_important">True</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -236,12 +275,16 @@
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="save_as_button"> <widget class="GtkRadioToolButton" id="dummy_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock_id">gtk-save-as</property> <property name="label" translatable="yes">dummy</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-about</property>
<property name="visible_horizontal">True</property> <property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property> <property name="visible_vertical">True</property>
<property name="is_important">True</property> <property name="is_important">False</property>
<property name="active">False</property>
<property name="group">start_button</property>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -263,17 +306,15 @@
<property name="spacing">0</property> <property name="spacing">0</property>
<child> <child>
<widget class="GtkHPaned" id="hpaned1"> <widget class="GtkHPaned" id="hpaned">
<property name="border_width">3</property> <property name="border_width">3</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="position">773</property>
<child> <child>
<widget class="GtkVPaned" id="vpaned1"> <widget class="GtkVPaned" id="vpaned">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="position">0</property>
<child> <child>
<widget class="GtkScrolledWindow" id="scrolledwindow1"> <widget class="GtkScrolledWindow" id="scrolledwindow1">