aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2012-09-21 11:14:41 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2012-09-21 11:14:41 -0400
commit15f952eca67215e7bf1b28ae323635b0882135e2 (patch)
treef1315b4b83149eacb12ad4ae63825ff910160ec4
parent096d4a1070fd067ab6e36f272c812616f266bb5e (diff)
cleanup
-rw-r--r--kernel-shark.c16
-rw-r--r--rt-graph.h3
-rw-r--r--rt-plot-task.c11
-rw-r--r--rt-plot.c38
-rw-r--r--trace-graph.c82
5 files changed, 72 insertions, 78 deletions
diff --git a/kernel-shark.c b/kernel-shark.c
index 5961e30..069a9c0 100644
--- a/kernel-shark.c
+++ b/kernel-shark.c
@@ -66,6 +66,8 @@ void usage(char *prog)
66 printf(" -v Display version and exit\n"); 66 printf(" -v Display version and exit\n");
67 printf(" -i input_file, default is %s\n", default_input_file); 67 printf(" -i input_file, default is %s\n", default_input_file);
68 printf(" -c Ignore records before system release\n"); 68 printf(" -c Ignore records before system release\n");
69 printf(" -s (float) Seconds after first record to begin displaying\n");
70 printf(" -d (float) Seconds of data to display\n");
69} 71}
70 72
71static gboolean display_warnings; 73static gboolean display_warnings;
@@ -1831,6 +1833,9 @@ void kernel_shark(int argc, char **argv)
1831 int ret; 1833 int ret;
1832 int c; 1834 int c;
1833 int clean; 1835 int clean;
1836 double start = 0.0;
1837 double duration = 0.0;
1838
1834 1839
1835 g_thread_init(NULL); 1840 g_thread_init(NULL);
1836 gdk_threads_init(); 1841 gdk_threads_init();
@@ -1838,7 +1843,7 @@ void kernel_shark(int argc, char **argv)
1838 gtk_init(&argc, &argv); 1843 gtk_init(&argc, &argv);
1839 1844
1840 clean = 0; 1845 clean = 0;
1841 while ((c = getopt(argc, argv, "hcvi:")) != -1) { 1846 while ((c = getopt(argc, argv, "hcvs:d:i:")) != -1) {
1842 switch(c) { 1847 switch(c) {
1843 case 'h': 1848 case 'h':
1844 usage(basename(argv[0])); 1849 usage(basename(argv[0]));
@@ -1854,6 +1859,12 @@ void kernel_shark(int argc, char **argv)
1854 case 'c': 1859 case 'c':
1855 clean = 1; 1860 clean = 1;
1856 break; 1861 break;
1862 case 's':
1863 start = atof(optarg);
1864 break;
1865 case 'd':
1866 duration = atof(optarg);
1867 break;
1857 default: 1868 default:
1858 /* assume the other options are for gtk */ 1869 /* assume the other options are for gtk */
1859 break; 1870 break;
@@ -2408,6 +2419,9 @@ void kernel_shark(int argc, char **argv)
2408 2419
2409 info->ginfo = trace_graph_create_with_callbacks(handle, &info->graph_cbs); 2420 info->ginfo = trace_graph_create_with_callbacks(handle, &info->graph_cbs);
2410 info->ginfo->rtg_info.clean_records = clean; 2421 info->ginfo->rtg_info.clean_records = clean;
2422 info->ginfo->rtg_info.start_offset = start;
2423 info->ginfo->rtg_info.duration = duration;
2424
2411 widget = trace_graph_get_window(info->ginfo); 2425 widget = trace_graph_get_window(info->ginfo);
2412 gtk_paned_add1(GTK_PANED(vpaned), widget); 2426 gtk_paned_add1(GTK_PANED(vpaned), widget);
2413 gtk_widget_show(widget); 2427 gtk_widget_show(widget);
diff --git a/rt-graph.h b/rt-graph.h
index 2b77c6e..b1453fd 100644
--- a/rt-graph.h
+++ b/rt-graph.h
@@ -24,6 +24,9 @@ struct rt_graph_info {
24 /* For ignoring records before system release */ 24 /* For ignoring records before system release */
25 gboolean clean_records; 25 gboolean clean_records;
26 long long start_time; 26 long long start_time;
27 long long end_time;
28 gdouble start_offset;
29 gdouble duration;
27 30
28 /* List of all real-time tasks */ 31 /* List of all real-time tasks */
29 struct task_list *tasks[TASK_HASH_SIZE]; 32 struct task_list *tasks[TASK_HASH_SIZE];
diff --git a/rt-plot-task.c b/rt-plot-task.c
index ec13313..2acf18f 100644
--- a/rt-plot-task.c
+++ b/rt-plot-task.c
@@ -512,12 +512,12 @@ rt_task_plot_write_header(struct rt_plot_common *rt,
512 } 512 }
513 trace_seq_putc(s, '\n'); 513 trace_seq_putc(s, '\n');
514 514
515 if (in_res(ginfo, deadline, time)) { 515 if (is_high_res(ginfo) && in_res(ginfo, deadline, time)) {
516 trace_seq_printf(s, "\nlitmus_deadline\n" 516 trace_seq_printf(s, "\nlitmus_deadline\n"
517 "deadline(job(%d,%d)): %llu\n", 517 "deadline(job(%d,%d)): %llu\n",
518 pid, job, deadline); 518 pid, job, deadline);
519 } 519 }
520 if (in_res(ginfo, release, time)) { 520 if (is_high_res(ginfo) && in_res(ginfo, release, time)) {
521 trace_seq_printf(s, "\nlitmus_release\n" 521 trace_seq_printf(s, "\nlitmus_release\n"
522 "release(job(%d,%d)): %llu\n", 522 "release(job(%d,%d)): %llu\n",
523 pid, job, release); 523 pid, job, release);
@@ -563,8 +563,7 @@ void rt_plot_task_update_callback(gboolean accept,
563 select_size = i; 563 select_size = i;
564 } 564 }
565 565
566 /* 566 /* Remove and add task plots.
567 * Remove and add task plots.
568 * Go backwards, since removing a plot shifts the 567 * Go backwards, since removing a plot shifts the
569 * array from current position back. 568 * array from current position back.
570 */ 569 */
@@ -582,8 +581,7 @@ void rt_plot_task_update_callback(gboolean accept,
582 ptr = bsearch(&rtt_info->pid, selected, select_size, 581 ptr = bsearch(&rtt_info->pid, selected, select_size,
583 sizeof(gint), id_cmp); 582 sizeof(gint), id_cmp);
584 if (ptr) { 583 if (ptr) {
585 /* 584 /* This plot plot already exists, remove it
586 * This plot plot already exists, remove it
587 * from the selected array. 585 * from the selected array.
588 */ 586 */
589 memmove(ptr, ptr + 1, 587 memmove(ptr, ptr + 1,
@@ -683,6 +681,7 @@ void rt_plot_add_all_tasks(struct graph_info *ginfo)
683 int i, j, len, tmp; 681 int i, j, len, tmp;
684 tasks = task_list_pids(ginfo->rtg_info.tasks); 682 tasks = task_list_pids(ginfo->rtg_info.tasks);
685 683
684 /* Awful sort */
686 for (i = 0; tasks[i] != -1; ++i) { 685 for (i = 0; tasks[i] != -1; ++i) {
687 for (j = i; tasks[j] != -1; ++j) { 686 for (j = i; tasks[j] != -1; ++j) {
688 if (tasks[i] > tasks[j]) { 687 if (tasks[i] > tasks[j]) {
diff --git a/rt-plot.c b/rt-plot.c
index dd7535e..4065424 100644
--- a/rt-plot.c
+++ b/rt-plot.c
@@ -19,7 +19,6 @@ void insert_record(struct graph_info *ginfo, struct record_list *list,
19 if (node->next) 19 if (node->next)
20 die("Node is in use!"); 20 die("Node is in use!");
21 if (!record) { 21 if (!record) {
22 printf("No record\n");
23 return; 22 return;
24 } 23 }
25 24
@@ -134,7 +133,6 @@ prev_display_iterator(struct graph_info *ginfo, struct record *record, void *dat
134 if (!ignored && args->common->record_matches(args->common, ginfo, record)) { 133 if (!ignored && args->common->record_matches(args->common, ginfo, record)) {
135 args->result = record; 134 args->result = record;
136 ++record->ref_count; 135 ++record->ref_count;
137 printf("success!\n");
138 return 0; 136 return 0;
139 } else { 137 } else {
140 return 1; 138 return 1;
@@ -250,22 +248,14 @@ rt_plot_display_info(struct graph_info *ginfo, struct graph_plot *plot,
250 long long pdiff, rdiff; 248 long long pdiff, rdiff;
251 int eid; 249 int eid;
252 250
253 /* printf("\nBegin display\n"); */
254
255 /* Write plot-specific data */ 251 /* Write plot-specific data */
256 data_record = rt_info->write_header(rt_info, ginfo, s, time); 252 data_record = rt_info->write_header(rt_info, ginfo, s, time);
257 /* printf("Data record: "); print_record(data_record); */
258 253
259 /* Select closest relevant record */ 254 /* Select closest relevant record */
260 range = 2 / ginfo->resolution; 255 range = 2 / ginfo->resolution;
261 256
262
263 record = __find_rt_record(ginfo, rt_info, time, 1, range); 257 record = __find_rt_record(ginfo, rt_info, time, 1, range);
264 prev_record = find_prev_display_record(ginfo, rt_info, time, range); 258 prev_record = find_prev_display_record(ginfo, rt_info, time, range);
265 //prev_record = NULL;
266
267 /* printf("Next: "); print_record(record); */
268 /* printf("Prev: "); print_record(prev_record); */
269 259
270 if (!record) { 260 if (!record) {
271 record = prev_record; 261 record = prev_record;
@@ -284,21 +274,20 @@ rt_plot_display_info(struct graph_info *ginfo, struct graph_plot *plot,
284 274
285 /* Write event info */ 275 /* Write event info */
286 if (record) { 276 if (record) {
287 /* rts = get_rts(ginfo, record); */ 277 rts = get_rts(ginfo, record);
288 /* eid = pevent_data_type(ginfo->pevent, record); */ 278 eid = pevent_data_type(ginfo->pevent, record);
289 279
290 /* if (in_res(ginfo, rts, time)) { */ 280 if (in_res(ginfo, rts, time)) {
291 /* event = pevent_data_event_from_type(ginfo->pevent, eid); */ 281 event = pevent_data_event_from_type(ginfo->pevent, eid);
292 /* if (event) { */ 282 if (event) {
293 /* trace_seq_putc(s, '\n'); */ 283 trace_seq_putc(s, '\n');
294 /* trace_seq_puts(s, event->name); */ 284 trace_seq_puts(s, event->name);
295 /* trace_seq_putc(s, '\n'); */ 285 trace_seq_putc(s, '\n');
296 /* pevent_event_info(s, event, record); */ 286 pevent_event_info(s, event, record);
297 /* } else */ 287 } else
298 /* trace_seq_printf(s, "\nUNKNOWN EVENT %d\n", eid); */ 288 trace_seq_printf(s, "\nUNKNOWN EVENT %d\n", eid);
299 /* } */ 289 }
300 free_record(record); 290 free_record(record);
301 /* printf("Freed record: "); print_record(record); */
302 } 291 }
303 292
304 /* Metadata */ 293 /* Metadata */
@@ -309,7 +298,6 @@ rt_plot_display_info(struct graph_info *ginfo, struct graph_plot *plot,
309 if (data_record) { 298 if (data_record) {
310 trace_seq_printf(s, " CPU: %03d", data_record->cpu); 299 trace_seq_printf(s, " CPU: %03d", data_record->cpu);
311 free_record(data_record); 300 free_record(data_record);
312 /* printf("Freed data: "); print_record(data_record); */
313 } 301 }
314 302
315 return 1; 303 return 1;
diff --git a/trace-graph.c b/trace-graph.c
index 66c2722..0b2b7cf 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -1149,8 +1149,9 @@ static void draw_plot_info(struct graph_info *ginfo, struct graph_plot *plot,
1149 1149
1150 trace_seq_init(&s); 1150 trace_seq_init(&s);
1151 1151
1152 dprintf(3, "start=%llu end=%llu time=%llu\n", 1152 dprintf(3, "start=%llu end=%llu time=%llu, vstart: %llu, vend: %llu\n",
1153 (u64)ginfo->start_time, (u64)ginfo->end_time, (u64)time); 1153 (u64)ginfo->start_time, (u64)ginfo->end_time, (u64)time,
1154 (u64)ginfo->view_start_time, (u64)ginfo->view_end_time);
1154 1155
1155 if (!trace_graph_plot_display_info(ginfo, plot, &s, time)) { 1156 if (!trace_graph_plot_display_info(ginfo, plot, &s, time)) {
1156 /* Just display the current time */ 1157 /* Just display the current time */
@@ -1381,7 +1382,6 @@ static void zoom_in_window(struct graph_info *ginfo, gint start, gint end)
1381 dprintf(1, "*** ended with with "); 1382 dprintf(1, "*** ended with with ");
1382 print_time(convert_x_to_time(ginfo, ginfo->hadj_value)); 1383 print_time(convert_x_to_time(ginfo, ginfo->hadj_value));
1383 dprintf(1, "\n"); 1384 dprintf(1, "\n");
1384
1385} 1385}
1386 1386
1387static gboolean 1387static gboolean
@@ -1859,32 +1859,43 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot,
1859 plot->p1, plot->p2, ginfo->draw_width, width_16, font); 1859 plot->p1, plot->p2, ginfo->draw_width, width_16, font);
1860} 1860}
1861 1861
1862int tries = 0; 1862/*
1863 1863 * TODO: this method needs refactoring
1864 */
1864static void draw_hashed_plots(struct graph_info *ginfo) 1865static void draw_hashed_plots(struct graph_info *ginfo)
1865{ 1866{
1866 gint cpu, pid; 1867 gint cpu, pid, clean;
1867 struct record *record; 1868 struct record *record;
1868 struct plot_hash *hash; 1869 struct plot_hash *hash;
1869 struct plot_list *list; 1870 struct plot_list *list;
1870 unsigned long long old_start; 1871 unsigned long long old_start, max_time, min_time;
1872 gdouble duration, start;
1873
1874 start = ginfo->rtg_info.start_offset;
1875 duration = ginfo->rtg_info.duration;
1876 clean = ginfo->rtg_info.clean_records;
1871 1877
1872 set_cpus_to_rts(ginfo, ginfo->view_start_time); 1878 set_cpus_to_rts(ginfo, ginfo->view_start_time);
1879
1880 max_time = ginfo->view_end_time;
1881 min_time = ginfo->view_start_time;
1873 1882
1874 while ((record = tracecmd_read_next_data(ginfo->handle, &cpu))) { 1883 while ((record = tracecmd_read_next_data(ginfo->handle, &cpu))) {
1875 int first = ginfo->rtg_info.start_time == 0; 1884 int first = ginfo->rtg_info.start_time == 0;
1876 if (get_rts(ginfo, record) < ginfo->view_start_time) { 1885
1886 if (get_rts(ginfo, record) < min_time) {
1877 free_record(record); 1887 free_record(record);
1878 continue; 1888 continue;
1879 } 1889 }
1880 if (get_rts(ginfo, record) > ginfo->view_end_time) { 1890
1891 if (get_rts(ginfo, record) > max_time) {
1881 free_record(record); 1892 free_record(record);
1882 break; 1893 break;
1883 } 1894 }
1884 1895
1885 // TODO: hack to clean up until first release, make unhacky 1896 // TODO: hack to clean up until first release, make unhacky
1886 if (ginfo->rtg_info.clean_records && 1897 if (ginfo->rtg_info.clean_records &&
1887 (ginfo->rtg_info.start_time == 0 || ginfo->view_start_time < ginfo->rtg_info.start_time)) { 1898 (ginfo->rtg_info.start_time == 0 || get_rts(ginfo, record) < ginfo->rtg_info.start_time)) {
1888 unsigned long long dull, rel = 0; 1899 unsigned long long dull, rel = 0;
1889 char *dchar; 1900 char *dchar;
1890 int dint; 1901 int dint;
@@ -1900,12 +1911,20 @@ static void draw_hashed_plots(struct graph_info *ginfo)
1900 rt_graph_check_server_param(ARG, &dint, &dull, &dull); 1911 rt_graph_check_server_param(ARG, &dint, &dull, &dull);
1901#undef ARG 1912#undef ARG
1902 if (rt_graph_check_sys_release(ginfo, record, &rel)) { 1913 if (rt_graph_check_sys_release(ginfo, record, &rel)) {
1903 dull = rel - .1 * (ginfo->view_end_time - rel); 1914 min_time = rel + ginfo->rtg_info.start_offset * NSECS_PER_SEC;
1904 ginfo->rtg_info.start_time = get_rts(ginfo, record); 1915 ginfo->rtg_info.start_time = min_time;
1905 //ginfo->view_end_time -= get_rts(ginfo, record) - ginfo->view_start_time; 1916 ginfo->view_start_time = min_time;
1906 ginfo->view_start_time = get_rts(ginfo, record); 1917 ginfo->start_time = min_time;
1907 if (first) 1918
1919 if (ginfo->rtg_info.duration) {
1920 max_time = MIN(max_time, min_time + ginfo->rtg_info.duration * NSECS_PER_SEC);
1921 ginfo->view_end_time = max_time;
1922 ginfo->end_time = max_time;
1923 }
1924 if (first) {
1925 free_record(record);
1908 return; 1926 return;
1927 }
1909 } 1928 }
1910 1929
1911 free_record(record); 1930 free_record(record);
@@ -1913,6 +1932,7 @@ static void draw_hashed_plots(struct graph_info *ginfo)
1913 continue; 1932 continue;
1914 } 1933 }
1915 1934
1935
1916 hash = trace_graph_plot_find_cpu(ginfo, cpu); 1936 hash = trace_graph_plot_find_cpu(ginfo, cpu);
1917 if (hash) { 1937 if (hash) {
1918 for (list = hash->plots; list; list = list->next) { 1938 for (list = hash->plots; list; list = list->next) {
@@ -1970,38 +1990,10 @@ static void draw_plots(struct graph_info *ginfo, gint new_width)
1970 set_color(ginfo->draw, plot->gc, plot->last_color); 1990 set_color(ginfo->draw, plot->gc, plot->last_color);
1971 } 1991 }
1972 1992
1973 printf("we here1\n");
1974
1975 trace_set_cursor(GDK_WATCH); 1993 trace_set_cursor(GDK_WATCH);
1976 /* /\* Shortcut if we don't have any task plots *\/ */
1977 /* if (!ginfo->nr_task_hash && !ginfo->all_recs) { */
1978 /* tracecmd_set_all_cpus_to_timestamp(ginfo->handle, */
1979 /* ginfo->view_start_time); */
1980 /* for (cpu = 0; cpu < ginfo->cpus; cpu++) { */
1981 /* hash = trace_graph_plot_find_cpu(ginfo, cpu); */
1982 /* if (!hash) */
1983 /* continue; */
1984
1985 /* while ((record = tracecmd_read_data(ginfo->handle, cpu))) { */
1986 /* if (record->ts < ginfo->view_start_time) { */
1987 /* free_record(record); */
1988 /* continue; */
1989 /* } */
1990 /* if (record->ts > ginfo->view_end_time) { */
1991 /* free_record(record); */
1992 /* break; */
1993 /* } */
1994 /* for (list = hash->plots; list; list = list->next) */
1995 /* draw_plot(ginfo, list->plot, record); */
1996 /* free_record(record); */
1997 /* } */
1998 /* } */
1999 /* goto out; */
2000 /* } */
2001 1994
2002 draw_hashed_plots(ginfo); 1995 draw_hashed_plots(ginfo);
2003 1996
2004out:
2005 for (i = 0; i < ginfo->plots; i++) { 1997 for (i = 0; i < ginfo->plots; i++) {
2006 plot = ginfo->plot_array[i]; 1998 plot = ginfo->plot_array[i];
2007 draw_plot(ginfo, plot, NULL); 1999 draw_plot(ginfo, plot, NULL);
@@ -2010,6 +2002,7 @@ out:
2010 gdk_gc_unref(plot->gc); 2002 gdk_gc_unref(plot->gc);
2011 plot->gc = NULL; 2003 plot->gc = NULL;
2012 } 2004 }
2005
2013 trace_put_cursor(); 2006 trace_put_cursor();
2014} 2007}
2015 2008
@@ -2105,10 +2098,8 @@ static void draw_timeline(struct graph_info *ginfo, gint width)
2105static void draw_info(struct graph_info *ginfo, 2098static void draw_info(struct graph_info *ginfo,
2106 gint new_width) 2099 gint new_width)
2107{ 2100{
2108 printf("we going?\n");
2109 if (!ginfo->handle) 2101 if (!ginfo->handle)
2110 return; 2102 return;
2111 printf("we gone\n");
2112 2103
2113 ginfo->resolution = (gdouble)new_width / (gdouble)(ginfo->view_end_time - 2104 ginfo->resolution = (gdouble)new_width / (gdouble)(ginfo->view_end_time -
2114 ginfo->view_start_time); 2105 ginfo->view_start_time);
@@ -2117,7 +2108,6 @@ static void draw_info(struct graph_info *ginfo,
2117 2108
2118 draw_timeline(ginfo, new_width); 2109 draw_timeline(ginfo, new_width);
2119 2110
2120 printf("drawing plots\n");
2121 draw_plots(ginfo, new_width); 2111 draw_plots(ginfo, new_width);
2122 2112
2123 ginfo->read_comms = FALSE; 2113 ginfo->read_comms = FALSE;