diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-01-11 15:11:29 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-01-11 21:02:52 -0500 |
| commit | aa893539b357eaffe97bd78afb40166c1a10329e (patch) | |
| tree | e6dd5e8f76ef02cf5c073caa0dd0db8469b55d13 | |
| parent | c6762b33dc678e0678b69b6b5307d8694911ab12 (diff) | |
trace-graph: Added loading of files
Modified trace-graph to open withoun any files loaded.
Added an "Load File" menu option to open a file dialog to load
a new file. Also allow to load new files.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-graph-main.c | 98 | ||||
| -rw-r--r-- | trace-graph.c | 164 | ||||
| -rw-r--r-- | trace-graph.h | 3 |
3 files changed, 204 insertions, 61 deletions
diff --git a/trace-graph-main.c b/trace-graph-main.c index 80907d2..fdf73fa 100644 --- a/trace-graph-main.c +++ b/trace-graph-main.c | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | #include <gtk/gtk.h> | 2 | #include <gtk/gtk.h> |
| 3 | #include <getopt.h> | 3 | #include <getopt.h> |
| 4 | #include <string.h> | 4 | #include <string.h> |
| 5 | #include <sys/types.h> | ||
| 6 | #include <sys/stat.h> | ||
| 7 | #include <unistd.h> | ||
| 5 | 8 | ||
| 6 | #include "trace-cmd.h" | 9 | #include "trace-cmd.h" |
| 7 | #include "trace-graph.h" | 10 | #include "trace-graph.h" |
| @@ -13,7 +16,7 @@ | |||
| 13 | #define TRACE_HEIGHT 600 | 16 | #define TRACE_HEIGHT 600 |
| 14 | 17 | ||
| 15 | #define default_input_file "trace.dat" | 18 | #define default_input_file "trace.dat" |
| 16 | static char *input_file = default_input_file; | 19 | static char *input_file; |
| 17 | static struct graph_info *ginfo; | 20 | static struct graph_info *ginfo; |
| 18 | 21 | ||
| 19 | void usage(char *prog) | 22 | void usage(char *prog) |
| @@ -23,6 +26,59 @@ void usage(char *prog) | |||
| 23 | printf(" -i input_file, default is %s\n", default_input_file); | 26 | printf(" -i input_file, default is %s\n", default_input_file); |
| 24 | } | 27 | } |
| 25 | 28 | ||
| 29 | static struct tracecmd_input *read_tracecmd(gchar *filename) | ||
| 30 | { | ||
| 31 | struct tracecmd_input *handle; | ||
| 32 | |||
| 33 | handle = tracecmd_open(filename); | ||
| 34 | |||
| 35 | if (!handle) { | ||
| 36 | warning("can not load %s", filename); | ||
| 37 | return NULL; | ||
| 38 | } | ||
| 39 | |||
| 40 | if (tracecmd_read_headers(handle) < 0) { | ||
| 41 | warning("can not read %s headers", filename); | ||
| 42 | goto failed; | ||
| 43 | } | ||
| 44 | |||
| 45 | if (tracecmd_init_data(handle) < 0) { | ||
| 46 | warning("can not init %s", filename); | ||
| 47 | goto failed; | ||
| 48 | } | ||
| 49 | |||
| 50 | return handle; | ||
| 51 | |||
| 52 | failed: | ||
| 53 | tracecmd_close(handle); | ||
| 54 | return NULL; | ||
| 55 | } | ||
| 56 | |||
| 57 | /* Callback for the clicked signal of the Load button */ | ||
| 58 | static void | ||
| 59 | load_clicked (gpointer data) | ||
| 60 | { | ||
| 61 | struct graph_info *ginfo = data; | ||
| 62 | struct tracecmd_input *handle; | ||
| 63 | GtkWidget *dialog; | ||
| 64 | gchar *filename; | ||
| 65 | |||
| 66 | dialog = gtk_file_chooser_dialog_new("Load File", | ||
| 67 | NULL, | ||
| 68 | GTK_FILE_CHOOSER_ACTION_OPEN, | ||
| 69 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | ||
| 70 | GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | ||
| 71 | NULL); | ||
| 72 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { | ||
| 73 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | ||
| 74 | handle = read_tracecmd(filename); | ||
| 75 | if (handle) | ||
| 76 | trace_graph_load_handle(ginfo, handle); | ||
| 77 | g_free(filename); | ||
| 78 | } | ||
| 79 | gtk_widget_destroy(dialog); | ||
| 80 | } | ||
| 81 | |||
| 26 | /* Callback for the clicked signal of the Exit button */ | 82 | /* Callback for the clicked signal of the Exit button */ |
| 27 | static void | 83 | static void |
| 28 | exit_clicked (GtkWidget *widget, gpointer data) | 84 | exit_clicked (GtkWidget *widget, gpointer data) |
| @@ -51,6 +107,9 @@ events_clicked (gpointer data) | |||
| 51 | gchar **systems = NULL; | 107 | gchar **systems = NULL; |
| 52 | gint *events = NULL; | 108 | gint *events = NULL; |
| 53 | 109 | ||
| 110 | if (!ginfo->handle) | ||
| 111 | return; | ||
| 112 | |||
| 54 | all_events = ginfo->all_events; | 113 | all_events = ginfo->all_events; |
| 55 | systems = ginfo->systems; | 114 | systems = ginfo->systems; |
| 56 | events = ginfo->event_ids; | 115 | events = ginfo->event_ids; |
| @@ -62,7 +121,8 @@ events_clicked (gpointer data) | |||
| 62 | 121 | ||
| 63 | void trace_graph(int argc, char **argv) | 122 | void trace_graph(int argc, char **argv) |
| 64 | { | 123 | { |
| 65 | struct tracecmd_input *handle; | 124 | struct tracecmd_input *handle = NULL; |
| 125 | struct stat st; | ||
| 66 | GtkWidget *window; | 126 | GtkWidget *window; |
| 67 | GtkWidget *vbox; | 127 | GtkWidget *vbox; |
| 68 | GtkWidget *hbox; | 128 | GtkWidget *hbox; |
| @@ -72,6 +132,7 @@ void trace_graph(int argc, char **argv) | |||
| 72 | GtkWidget *sub_item; | 132 | GtkWidget *sub_item; |
| 73 | GtkWidget *widget; | 133 | GtkWidget *widget; |
| 74 | int c; | 134 | int c; |
| 135 | int ret; | ||
| 75 | 136 | ||
| 76 | while ((c = getopt(argc, argv, "hi:")) != -1) { | 137 | while ((c = getopt(argc, argv, "hi:")) != -1) { |
| 77 | switch(c) { | 138 | switch(c) { |
| @@ -87,16 +148,14 @@ void trace_graph(int argc, char **argv) | |||
| 87 | } | 148 | } |
| 88 | } | 149 | } |
| 89 | 150 | ||
| 90 | handle = tracecmd_open(input_file); | 151 | if (!input_file) { |
| 91 | 152 | ret = stat(default_input_file, &st); | |
| 92 | if (!handle) | 153 | if (ret >= 0) |
| 93 | die("error reading header"); | 154 | input_file = default_input_file; |
| 94 | 155 | } | |
| 95 | if (tracecmd_read_headers(handle) < 0) | ||
| 96 | return; | ||
| 97 | 156 | ||
| 98 | if (tracecmd_init_data(handle) < 0) | 157 | if (input_file) |
| 99 | die("failed to init data"); | 158 | handle = read_tracecmd(input_file); |
| 100 | 159 | ||
| 101 | gtk_init(&argc, &argv); | 160 | gtk_init(&argc, &argv); |
| 102 | 161 | ||
| @@ -129,6 +188,22 @@ void trace_graph(int argc, char **argv) | |||
| 129 | menu = gtk_menu_new(); /* Don't need to show menus */ | 188 | menu = gtk_menu_new(); /* Don't need to show menus */ |
| 130 | 189 | ||
| 131 | 190 | ||
| 191 | /* --- File - Load Option --- */ | ||
| 192 | |||
| 193 | sub_item = gtk_menu_item_new_with_label("Load info"); | ||
| 194 | |||
| 195 | /* Add them to the menu */ | ||
| 196 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); | ||
| 197 | |||
| 198 | /* We can attach the Quit menu item to our exit function */ | ||
| 199 | g_signal_connect_swapped (G_OBJECT (sub_item), "activate", | ||
| 200 | G_CALLBACK (load_clicked), | ||
| 201 | (gpointer) ginfo); | ||
| 202 | |||
| 203 | /* We do need to show menu items */ | ||
| 204 | gtk_widget_show(sub_item); | ||
| 205 | |||
| 206 | |||
| 132 | /* --- File - Quit Option --- */ | 207 | /* --- File - Quit Option --- */ |
| 133 | 208 | ||
| 134 | sub_item = gtk_menu_item_new_with_label("Quit"); | 209 | sub_item = gtk_menu_item_new_with_label("Quit"); |
| @@ -144,6 +219,7 @@ void trace_graph(int argc, char **argv) | |||
| 144 | /* We do need to show menu items */ | 219 | /* We do need to show menu items */ |
| 145 | gtk_widget_show(sub_item); | 220 | gtk_widget_show(sub_item); |
| 146 | 221 | ||
| 222 | |||
| 147 | gtk_menu_item_set_submenu(GTK_MENU_ITEM (menu_item), menu); | 223 | gtk_menu_item_set_submenu(GTK_MENU_ITEM (menu_item), menu); |
| 148 | 224 | ||
| 149 | /* --- end File options --- */ | 225 | /* --- end File options --- */ |
diff --git a/trace-graph.c b/trace-graph.c index b478572..d31f7a5 100644 --- a/trace-graph.c +++ b/trace-graph.c | |||
| @@ -560,6 +560,9 @@ button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | |||
| 560 | { | 560 | { |
| 561 | struct graph_info *ginfo = data; | 561 | struct graph_info *ginfo = data; |
| 562 | 562 | ||
| 563 | if (!ginfo->handle) | ||
| 564 | return FALSE; | ||
| 565 | |||
| 563 | if (event->button == 3) | 566 | if (event->button == 3) |
| 564 | return do_pop_up(widget, event, data); | 567 | return do_pop_up(widget, event, data); |
| 565 | 568 | ||
| @@ -606,6 +609,9 @@ info_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data) | |||
| 606 | { | 609 | { |
| 607 | struct graph_info *ginfo = data; | 610 | struct graph_info *ginfo = data; |
| 608 | 611 | ||
| 612 | if (!ginfo->handle) | ||
| 613 | return FALSE; | ||
| 614 | |||
| 609 | if (event->button != 1) | 615 | if (event->button != 1) |
| 610 | return FALSE; | 616 | return FALSE; |
| 611 | 617 | ||
| @@ -630,6 +636,9 @@ info_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data | |||
| 630 | GdkModifierType state; | 636 | GdkModifierType state; |
| 631 | gint x, y; | 637 | gint x, y; |
| 632 | 638 | ||
| 639 | if (!ginfo->handle) | ||
| 640 | return FALSE; | ||
| 641 | |||
| 633 | if (!ginfo->line_active) | 642 | if (!ginfo->line_active) |
| 634 | return FALSE; | 643 | return FALSE; |
| 635 | 644 | ||
| @@ -668,6 +677,9 @@ info_button_release_event(GtkWidget *widget, GdkEventMotion *event, gpointer dat | |||
| 668 | struct graph_info *ginfo = data; | 677 | struct graph_info *ginfo = data; |
| 669 | gint x; | 678 | gint x; |
| 670 | 679 | ||
| 680 | if (!ginfo->handle) | ||
| 681 | return FALSE; | ||
| 682 | |||
| 671 | x = event->x - ginfo->scrollwin->allocation.x - ginfo->info_scrollwin->allocation.x; | 683 | x = event->x - ginfo->scrollwin->allocation.x - ginfo->info_scrollwin->allocation.x; |
| 672 | 684 | ||
| 673 | activate_zoom(ginfo, x); | 685 | activate_zoom(ginfo, x); |
| @@ -990,6 +1002,9 @@ motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | |||
| 990 | gint x, y; | 1002 | gint x, y; |
| 991 | gint cpu; | 1003 | gint cpu; |
| 992 | 1004 | ||
| 1005 | if (!ginfo->handle) | ||
| 1006 | return FALSE; | ||
| 1007 | |||
| 993 | update_with_backend(ginfo, ginfo->cpu_data_x, ginfo->cpu_data_y, | 1008 | update_with_backend(ginfo, ginfo->cpu_data_x, ginfo->cpu_data_y, |
| 994 | ginfo->cpu_data_w, ginfo->cpu_data_h); | 1009 | ginfo->cpu_data_w, ginfo->cpu_data_h); |
| 995 | if (event->is_hint) | 1010 | if (event->is_hint) |
| @@ -1188,7 +1203,6 @@ static void zoom_in_window(struct graph_info *ginfo, gint start, gint end) | |||
| 1188 | static gboolean | 1203 | static gboolean |
| 1189 | value_changed(GtkWidget *widget, gpointer data) | 1204 | value_changed(GtkWidget *widget, gpointer data) |
| 1190 | { | 1205 | { |
| 1191 | // struct graph_info *ginfo = data; | ||
| 1192 | GtkAdjustment *adj = GTK_ADJUSTMENT(widget); | 1206 | GtkAdjustment *adj = GTK_ADJUSTMENT(widget); |
| 1193 | 1207 | ||
| 1194 | dprintf(2, "value = %f\n", | 1208 | dprintf(2, "value = %f\n", |
| @@ -1295,6 +1309,9 @@ button_release_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | |||
| 1295 | { | 1309 | { |
| 1296 | struct graph_info *ginfo = data; | 1310 | struct graph_info *ginfo = data; |
| 1297 | 1311 | ||
| 1312 | if (!ginfo->handle) | ||
| 1313 | return FALSE; | ||
| 1314 | |||
| 1298 | activate_zoom(ginfo, event->x); | 1315 | activate_zoom(ginfo, event->x); |
| 1299 | 1316 | ||
| 1300 | return TRUE; | 1317 | return TRUE; |
| @@ -1305,6 +1322,9 @@ leave_notify_event(GtkWidget *widget, GdkEventCrossing *event, gpointer data) | |||
| 1305 | { | 1322 | { |
| 1306 | struct graph_info *ginfo = data; | 1323 | struct graph_info *ginfo = data; |
| 1307 | 1324 | ||
| 1325 | if (!ginfo->handle) | ||
| 1326 | return FALSE; | ||
| 1327 | |||
| 1308 | update_with_backend(ginfo, ginfo->cpu_data_x, ginfo->cpu_data_y, | 1328 | update_with_backend(ginfo, ginfo->cpu_data_x, ginfo->cpu_data_y, |
| 1309 | ginfo->cpu_data_w, ginfo->cpu_data_h); | 1329 | ginfo->cpu_data_w, ginfo->cpu_data_h); |
| 1310 | 1330 | ||
| @@ -1658,6 +1678,9 @@ static void draw_info(struct graph_info *ginfo, | |||
| 1658 | static int read_comms = 1; | 1678 | static int read_comms = 1; |
| 1659 | gint cpu; | 1679 | gint cpu; |
| 1660 | 1680 | ||
| 1681 | if (!ginfo->handle) | ||
| 1682 | return; | ||
| 1683 | |||
| 1661 | ginfo->resolution = (gdouble)new_width / (gdouble)(ginfo->view_end_time - | 1684 | ginfo->resolution = (gdouble)new_width / (gdouble)(ginfo->view_end_time - |
| 1662 | ginfo->view_start_time); | 1685 | ginfo->view_start_time); |
| 1663 | 1686 | ||
| @@ -1867,6 +1890,8 @@ destroy_event(GtkWidget *widget, gpointer data) | |||
| 1867 | { | 1890 | { |
| 1868 | struct graph_info *ginfo = data; | 1891 | struct graph_info *ginfo = data; |
| 1869 | 1892 | ||
| 1893 | trace_graph_free_info(ginfo); | ||
| 1894 | |||
| 1870 | graph_free_systems(ginfo); | 1895 | graph_free_systems(ginfo); |
| 1871 | graph_free_events(ginfo); | 1896 | graph_free_events(ginfo); |
| 1872 | 1897 | ||
| @@ -1920,20 +1945,16 @@ static void info_draw_cpu_label(struct graph_info *ginfo, gint cpu) | |||
| 1920 | static void info_draw_cpu_labels(struct graph_info *ginfo) | 1945 | static void info_draw_cpu_labels(struct graph_info *ginfo) |
| 1921 | { | 1946 | { |
| 1922 | gint cpu; | 1947 | gint cpu; |
| 1923 | #if 0 | 1948 | |
| 1924 | clear_old_cpu_labels(ginfo); | 1949 | if (!ginfo->handle) |
| 1925 | ginfo->cpu_x = gtk_adjustment_get_value(ginfo->hadj) + 5; | 1950 | return; |
| 1926 | #endif | ||
| 1927 | 1951 | ||
| 1928 | for (cpu = 0; cpu < ginfo->cpus; cpu++) | 1952 | for (cpu = 0; cpu < ginfo->cpus; cpu++) |
| 1929 | info_draw_cpu_label(ginfo, cpu); | 1953 | info_draw_cpu_label(ginfo, cpu); |
| 1930 | } | 1954 | } |
| 1931 | 1955 | ||
| 1932 | static gboolean | 1956 | static void update_cpu_window(struct graph_info *ginfo) |
| 1933 | info_configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | ||
| 1934 | { | 1957 | { |
| 1935 | struct graph_info *ginfo = data; | ||
| 1936 | |||
| 1937 | if (ginfo->info_pixmap) | 1958 | if (ginfo->info_pixmap) |
| 1938 | g_object_unref(ginfo->info_pixmap); | 1959 | g_object_unref(ginfo->info_pixmap); |
| 1939 | 1960 | ||
| @@ -1953,7 +1974,15 @@ info_configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | |||
| 1953 | 1974 | ||
| 1954 | gtk_widget_set_size_request(ginfo->info, largest_cpu_label + 10, | 1975 | gtk_widget_set_size_request(ginfo->info, largest_cpu_label + 10, |
| 1955 | ginfo->draw_height); | 1976 | ginfo->draw_height); |
| 1956 | 1977 | } | |
| 1978 | |||
| 1979 | static gboolean | ||
| 1980 | info_configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) | ||
| 1981 | { | ||
| 1982 | struct graph_info *ginfo = data; | ||
| 1983 | |||
| 1984 | update_cpu_window(ginfo); | ||
| 1985 | |||
| 1957 | return TRUE; | 1986 | return TRUE; |
| 1958 | } | 1987 | } |
| 1959 | 1988 | ||
| @@ -1984,28 +2013,93 @@ create_graph_info(struct graph_info *ginfo) | |||
| 1984 | return info; | 2013 | return info; |
| 1985 | } | 2014 | } |
| 1986 | 2015 | ||
| 1987 | struct graph_info * | 2016 | void trace_graph_free_info(struct graph_info *ginfo) |
| 1988 | trace_graph_create_with_callbacks(struct tracecmd_input *handle, | ||
| 1989 | struct graph_callbacks *cbs) | ||
| 1990 | { | 2017 | { |
| 1991 | struct graph_info *ginfo; | 2018 | tracecmd_close(ginfo->handle); |
| 2019 | ginfo->handle = NULL; | ||
| 2020 | } | ||
| 2021 | |||
| 2022 | static int load_handle(struct graph_info *ginfo, | ||
| 2023 | struct tracecmd_input *handle) | ||
| 2024 | { | ||
| 2025 | struct record *record; | ||
| 1992 | unsigned long sec, usec; | 2026 | unsigned long sec, usec; |
| 1993 | gint cpu; | 2027 | gint cpu; |
| 1994 | 2028 | ||
| 1995 | ginfo = g_new0(typeof(*ginfo), 1); | 2029 | if (!handle) |
| 1996 | g_assert(ginfo != NULL); | 2030 | return -1; |
| 2031 | |||
| 2032 | if (ginfo->handle) | ||
| 2033 | trace_graph_free_info(ginfo); | ||
| 1997 | 2034 | ||
| 1998 | ginfo->handle = handle; | 2035 | ginfo->handle = handle; |
| 2036 | |||
| 1999 | ginfo->pevent = tracecmd_get_pevent(handle); | 2037 | ginfo->pevent = tracecmd_get_pevent(handle); |
| 2000 | ginfo->cpus = tracecmd_cpus(handle); | 2038 | ginfo->cpus = tracecmd_cpus(handle); |
| 2001 | |||
| 2002 | ginfo->all_events = TRUE; | 2039 | ginfo->all_events = TRUE; |
| 2003 | 2040 | ||
| 2004 | ginfo->callbacks = cbs; | ||
| 2005 | |||
| 2006 | ginfo->start_time = -1ULL; | 2041 | ginfo->start_time = -1ULL; |
| 2007 | ginfo->end_time = 0; | 2042 | ginfo->end_time = 0; |
| 2008 | 2043 | ||
| 2044 | ginfo->draw_height = CPU_SPACE(ginfo->cpus); | ||
| 2045 | |||
| 2046 | for (cpu = 0; cpu < ginfo->cpus; cpu++) { | ||
| 2047 | record = tracecmd_read_cpu_first(handle, cpu); | ||
| 2048 | if (!record) | ||
| 2049 | continue; | ||
| 2050 | |||
| 2051 | if (record->ts < ginfo->start_time) | ||
| 2052 | ginfo->start_time = record->ts; | ||
| 2053 | |||
| 2054 | free_record(record); | ||
| 2055 | record = tracecmd_read_cpu_last(handle, cpu); | ||
| 2056 | |||
| 2057 | if (record->ts > ginfo->end_time) | ||
| 2058 | ginfo->end_time = record->ts; | ||
| 2059 | free_record(record); | ||
| 2060 | } | ||
| 2061 | |||
| 2062 | convert_nano(ginfo->start_time, &sec, &usec); | ||
| 2063 | dprintf(1, "start=%lu.%06lu ", sec, usec); | ||
| 2064 | |||
| 2065 | convert_nano(ginfo->end_time, &sec, &usec); | ||
| 2066 | dprintf(1, "end=%lu.%06lu\n", sec, usec); | ||
| 2067 | |||
| 2068 | ginfo->view_start_time = ginfo->start_time; | ||
| 2069 | ginfo->view_end_time = ginfo->end_time; | ||
| 2070 | |||
| 2071 | return 0; | ||
| 2072 | } | ||
| 2073 | |||
| 2074 | int trace_graph_load_handle(struct graph_info *ginfo, | ||
| 2075 | struct tracecmd_input *handle) | ||
| 2076 | { | ||
| 2077 | |||
| 2078 | if (load_handle(ginfo, handle) < 0) | ||
| 2079 | return -1; | ||
| 2080 | |||
| 2081 | update_cpu_window(ginfo); | ||
| 2082 | redraw_graph(ginfo); | ||
| 2083 | |||
| 2084 | return 0; | ||
| 2085 | } | ||
| 2086 | |||
| 2087 | struct graph_info * | ||
| 2088 | trace_graph_create_with_callbacks(struct tracecmd_input *handle, | ||
| 2089 | struct graph_callbacks *cbs) | ||
| 2090 | { | ||
| 2091 | struct graph_info *ginfo; | ||
| 2092 | |||
| 2093 | ginfo = g_new0(typeof(*ginfo), 1); | ||
| 2094 | g_assert(ginfo != NULL); | ||
| 2095 | |||
| 2096 | if (handle) | ||
| 2097 | load_handle(ginfo, handle); | ||
| 2098 | |||
| 2099 | ginfo->handle = handle; | ||
| 2100 | |||
| 2101 | ginfo->callbacks = cbs; | ||
| 2102 | |||
| 2009 | ginfo->task_filter = filter_task_hash_alloc(); | 2103 | ginfo->task_filter = filter_task_hash_alloc(); |
| 2010 | ginfo->hide_tasks = filter_task_hash_alloc(); | 2104 | ginfo->hide_tasks = filter_task_hash_alloc(); |
| 2011 | 2105 | ||
| @@ -2017,7 +2111,7 @@ trace_graph_create_with_callbacks(struct tracecmd_input *handle, | |||
| 2017 | GTK_POLICY_AUTOMATIC, | 2111 | GTK_POLICY_AUTOMATIC, |
| 2018 | GTK_POLICY_AUTOMATIC); | 2112 | GTK_POLICY_AUTOMATIC); |
| 2019 | gtk_widget_show(ginfo->scrollwin); | 2113 | gtk_widget_show(ginfo->scrollwin); |
| 2020 | 2114 | ginfo->hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(ginfo->scrollwin)); | |
| 2021 | 2115 | ||
| 2022 | ginfo->info_scrollwin = gtk_scrolled_window_new(NULL, | 2116 | ginfo->info_scrollwin = gtk_scrolled_window_new(NULL, |
| 2023 | gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(ginfo->scrollwin))); | 2117 | gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(ginfo->scrollwin))); |
| @@ -2036,39 +2130,9 @@ trace_graph_create_with_callbacks(struct tracecmd_input *handle, | |||
| 2036 | 2130 | ||
| 2037 | gtk_box_pack_start(GTK_BOX (ginfo->widget), ginfo->scrollwin, TRUE, TRUE, 0); | 2131 | gtk_box_pack_start(GTK_BOX (ginfo->widget), ginfo->scrollwin, TRUE, TRUE, 0); |
| 2038 | 2132 | ||
| 2039 | ginfo->draw_height = CPU_SPACE(ginfo->cpus); | ||
| 2040 | ginfo->hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(ginfo->scrollwin)); | ||
| 2041 | |||
| 2042 | gtk_signal_connect(GTK_OBJECT(ginfo->hadj), "value_changed", | 2133 | gtk_signal_connect(GTK_OBJECT(ginfo->hadj), "value_changed", |
| 2043 | (GtkSignalFunc) value_changed, ginfo); | 2134 | (GtkSignalFunc) value_changed, ginfo); |
| 2044 | 2135 | ||
| 2045 | for (cpu = 0; cpu < ginfo->cpus; cpu++) { | ||
| 2046 | struct record *record; | ||
| 2047 | |||
| 2048 | record = tracecmd_read_cpu_first(handle, cpu); | ||
| 2049 | if (!record) | ||
| 2050 | continue; | ||
| 2051 | |||
| 2052 | if (record->ts < ginfo->start_time) | ||
| 2053 | ginfo->start_time = record->ts; | ||
| 2054 | |||
| 2055 | free_record(record); | ||
| 2056 | record = tracecmd_read_cpu_last(handle, cpu); | ||
| 2057 | |||
| 2058 | if (record->ts > ginfo->end_time) | ||
| 2059 | ginfo->end_time = record->ts; | ||
| 2060 | free_record(record); | ||
| 2061 | } | ||
| 2062 | |||
| 2063 | convert_nano(ginfo->start_time, &sec, &usec); | ||
| 2064 | dprintf(1,"start=%lu.%06lu ", sec, usec); | ||
| 2065 | |||
| 2066 | convert_nano(ginfo->end_time, &sec, &usec); | ||
| 2067 | dprintf(1, "end=%lu.%06lu\n", sec, usec); | ||
| 2068 | |||
| 2069 | ginfo->view_start_time = ginfo->start_time; | ||
| 2070 | ginfo->view_end_time = ginfo->end_time; | ||
| 2071 | |||
| 2072 | ginfo->draw = gtk_drawing_area_new(); | 2136 | ginfo->draw = gtk_drawing_area_new(); |
| 2073 | 2137 | ||
| 2074 | gtk_signal_connect(GTK_OBJECT(ginfo->draw), "expose_event", | 2138 | gtk_signal_connect(GTK_OBJECT(ginfo->draw), "expose_event", |
diff --git a/trace-graph.h b/trace-graph.h index 33e7355..7cfe0a2 100644 --- a/trace-graph.h +++ b/trace-graph.h | |||
| @@ -114,5 +114,8 @@ void trace_graph_filter_add_remove_task(struct graph_info *info, | |||
| 114 | void trace_graph_filter_hide_show_task(struct graph_info *ginfo, | 114 | void trace_graph_filter_hide_show_task(struct graph_info *ginfo, |
| 115 | gint pid); | 115 | gint pid); |
| 116 | void trace_graph_clear_tasks(struct graph_info *ginfo); | 116 | void trace_graph_clear_tasks(struct graph_info *ginfo); |
| 117 | void trace_graph_free_info(struct graph_info *ginfo); | ||
| 118 | int trace_graph_load_handle(struct graph_info *ginfo, | ||
| 119 | struct tracecmd_input *handle); | ||
| 117 | 120 | ||
| 118 | #endif /* _TRACE_GRAPH_H */ | 121 | #endif /* _TRACE_GRAPH_H */ |
