aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-12-30 15:35:27 -0500
committerSteven Rostedt <rostedt@goodmis.org>2009-12-30 15:35:27 -0500
commitcc99a8f739a019f9cbc5248f0f0454c200b9ed32 (patch)
treed933cf356d1e468a4da407c3120ccf7bcee61e95
parent41a33285f270f284aa44250e79d70372f68bce80 (diff)
trace-graph: Convert the printfs to dprintf for debugging
Too much output is being displayed in the graph output. Convert the printf to dprintf macro that can control the amount of output. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-graph.c68
1 files changed, 41 insertions, 27 deletions
diff --git a/trace-graph.c b/trace-graph.c
index d9a26e4..a92293f 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -30,6 +30,17 @@
30#include "trace-local.h" 30#include "trace-local.h"
31#include "trace-graph.h" 31#include "trace-graph.h"
32 32
33#define DEBUG_LEVEL 1
34#if DEBUG_LEVEL > 0
35# define dprintf(l, x...) \
36 do { \
37 if (l <= DEBUG_LEVEL) \
38 printf(x); \
39 } while (0)
40#else
41# define dprintf(x...) do { } while (0)
42#endif
43
33#define MAX_WIDTH 10000 44#define MAX_WIDTH 10000
34 45
35#define CPU_SIZE 10 46#define CPU_SIZE 10
@@ -62,6 +73,9 @@ static void print_time(unsigned long long time)
62{ 73{
63 unsigned long sec, usec; 74 unsigned long sec, usec;
64 75
76 if (!DEBUG_LEVEL)
77 return;
78
65 convert_nano(time, &sec, &usec); 79 convert_nano(time, &sec, &usec);
66 printf("%lu.%06lu", sec, usec); 80 printf("%lu.%06lu", sec, usec);
67} 81}
@@ -137,8 +151,6 @@ button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
137{ 151{
138 struct graph_info *ginfo = data; 152 struct graph_info *ginfo = data;
139 153
140 printf("button = %d\n", event->button);
141
142 if (event->button != 1) 154 if (event->button != 1)
143 return TRUE; 155 return TRUE;
144 156
@@ -184,6 +196,9 @@ static void print_rec_info(struct record *record, struct pevent *pevent, int cpu
184 unsigned long sec, usec; 196 unsigned long sec, usec;
185 gint type; 197 gint type;
186 198
199 if (DEBUG_LEVEL < 3)
200 return;
201
187 trace_seq_init(&s); 202 trace_seq_init(&s);
188 203
189 convert_nano(record->ts, &sec, &usec); 204 convert_nano(record->ts, &sec, &usec);
@@ -286,7 +301,6 @@ static void draw_cpu_info(struct graph_info *ginfo, gint cpu, gint x, gint y)
286 gdk_gc_set_foreground(pix_bg, &color); 301 gdk_gc_set_foreground(pix_bg, &color);
287 } 302 }
288 303
289 printf("res=%f\n", ginfo->resolution);
290 time = (x / ginfo->resolution) + ginfo->view_start_time; 304 time = (x / ginfo->resolution) + ginfo->view_start_time;
291 convert_nano(time, &sec, &usec); 305 convert_nano(time, &sec, &usec);
292 306
@@ -294,7 +308,7 @@ static void draw_cpu_info(struct graph_info *ginfo, gint cpu, gint x, gint y)
294 308
295 trace_seq_init(&s); 309 trace_seq_init(&s);
296 310
297 printf("start=%zu end=%zu time=%lu\n", ginfo->start_time, ginfo->end_time, time); 311 dprintf(3, "start=%zu end=%zu time=%lu\n", ginfo->start_time, ginfo->end_time, time);
298 tracecmd_set_cpu_to_timestamp(ginfo->handle, cpu, time); 312 tracecmd_set_cpu_to_timestamp(ginfo->handle, cpu, time);
299 do { 313 do {
300 if (record) { 314 if (record) {
@@ -307,7 +321,7 @@ static void draw_cpu_info(struct graph_info *ginfo, gint cpu, gint x, gint y)
307 if (record) { 321 if (record) {
308 322
309 if (record->ts > (time + 1 / ginfo->resolution) && offset) { 323 if (record->ts > (time + 1 / ginfo->resolution) && offset) {
310 printf("old ts = %llu!\n", record->ts); 324 dprintf(3, "old ts = %llu!\n", record->ts);
311 free_record(record); 325 free_record(record);
312 record = tracecmd_read_at(ginfo->handle, offset, NULL); 326 record = tracecmd_read_at(ginfo->handle, offset, NULL);
313 } 327 }
@@ -317,8 +331,8 @@ static void draw_cpu_info(struct graph_info *ginfo, gint cpu, gint x, gint y)
317 comm = pevent_data_comm_from_pid(ginfo->pevent, pid); 331 comm = pevent_data_comm_from_pid(ginfo->pevent, pid);
318 } 332 }
319 333
320 printf("record->ts=%llu time=%zu-%zu\n", 334 dprintf(3, "record->ts=%llu time=%zu-%zu\n",
321 record->ts, time, time-(gint)(1/ginfo->resolution)); 335 record->ts, time, time-(gint)(1/ginfo->resolution));
322 print_rec_info(record, pevent, cpu); 336 print_rec_info(record, pevent, cpu);
323 337
324 /* 338 /*
@@ -496,9 +510,9 @@ static void zoom_in_window(struct graph_info *ginfo, gint start, gint end)
496 g_assert(start < end); 510 g_assert(start < end);
497 g_assert(ginfo->vadj); 511 g_assert(ginfo->vadj);
498 512
499 printf("*** started with "); 513 dprintf(1, "*** started with ");
500 print_time(start / ginfo->resolution + ginfo->view_start_time); 514 print_time(start / ginfo->resolution + ginfo->view_start_time);
501 printf("\n"); 515 dprintf(1, "\n");
502 516
503 view_width = gtk_adjustment_get_page_size(ginfo->vadj); 517 view_width = gtk_adjustment_get_page_size(ginfo->vadj);
504 select_width = end - start; 518 select_width = end - start;
@@ -509,15 +523,15 @@ static void zoom_in_window(struct graph_info *ginfo, gint start, gint end)
509 curr_width = ginfo->draw->allocation.width; 523 curr_width = ginfo->draw->allocation.width;
510 new_width = curr_width * percent; 524 new_width = curr_width * percent;
511 525
512 printf("width=%d\n", ginfo->draw->allocation.width); 526 dprintf(1, "width=%d\n", ginfo->draw->allocation.width);
513 if (ginfo->vadj) { 527 if (ginfo->vadj) {
514 printf("adj:%f-%f\n", gtk_adjustment_get_upper(ginfo->vadj), 528 dprintf(1, "adj:%f-%f\n", gtk_adjustment_get_upper(ginfo->vadj),
515 gtk_adjustment_get_lower(ginfo->vadj)); 529 gtk_adjustment_get_lower(ginfo->vadj));
516 } else 530 } else
517 printf("no adjustment\n"); 531 dprintf(1, "no adjustment\n");
518 532
519 ginfo->draw_width = new_width; 533 ginfo->draw_width = new_width;
520 printf("zoom in draw_width=%d full_width=%d\n", 534 dprintf(1, "zoom in draw_width=%d full_width=%d\n",
521 ginfo->draw_width, ginfo->full_width); 535 ginfo->draw_width, ginfo->full_width);
522 536
523 if (ginfo->draw_width > MAX_WIDTH) { 537 if (ginfo->draw_width > MAX_WIDTH) {
@@ -576,10 +590,10 @@ static void zoom_in_window(struct graph_info *ginfo, gint start, gint end)
576 590
577 update_graph_to_start_x(ginfo); 591 update_graph_to_start_x(ginfo);
578 592
579 printf("new start/end =%d/%d full:%d start_time:", 593 dprintf(1, "new start/end =%d/%d full:%d start_time:",
580 new_start, new_end, ginfo->full_width); 594 new_start, new_end, ginfo->full_width);
581 print_time(ginfo->view_start_time); 595 print_time(ginfo->view_start_time);
582 printf("\n"); 596 dprintf(1, "\n");
583 597
584 /* Adjust start to be the location for the vadj */ 598 /* Adjust start to be the location for the vadj */
585 start = (mid - new_start) / percent - (end - start) / 2; 599 start = (mid - new_start) / percent - (end - start) / 2;
@@ -589,7 +603,7 @@ static void zoom_in_window(struct graph_info *ginfo, gint start, gint end)
589 if (ginfo->vadj_value > (ginfo->draw_width - view_width)) 603 if (ginfo->vadj_value > (ginfo->draw_width - view_width))
590 ginfo->vadj_value = ginfo->draw_width - view_width; 604 ginfo->vadj_value = ginfo->draw_width - view_width;
591 605
592 printf("new width=%d\n", ginfo->draw_width); 606 dprintf(1, "new width=%d\n", ginfo->draw_width);
593 607
594 /* make sure the width is sent */ 608 /* make sure the width is sent */
595 if (ginfo->draw_width == old_width) 609 if (ginfo->draw_width == old_width)
@@ -597,12 +611,12 @@ static void zoom_in_window(struct graph_info *ginfo, gint start, gint end)
597 ginfo->draw_height); 611 ginfo->draw_height);
598 gtk_widget_set_size_request(ginfo->draw, ginfo->draw_width, ginfo->draw_height); 612 gtk_widget_set_size_request(ginfo->draw, ginfo->draw_width, ginfo->draw_height);
599 613
600 printf("set val %f\n", ginfo->vadj_value); 614 dprintf(1, "set val %f\n", ginfo->vadj_value);
601 615
602 616
603 printf("*** ended with with "); 617 dprintf(1, "*** ended with with ");
604 print_time(ginfo->vadj_value / ginfo->resolution + ginfo->view_start_time); 618 print_time(ginfo->vadj_value / ginfo->resolution + ginfo->view_start_time);
605 printf("\n"); 619 dprintf(1, "\n");
606 620
607} 621}
608 622
@@ -648,11 +662,11 @@ static void zoom_out_window(struct graph_info *ginfo, gint start, gint end)
648 662
649 update_graph(ginfo, 1 / divider); 663 update_graph(ginfo, 1 / divider);
650 664
651 printf("width=%d\n", ginfo->draw->allocation.width); 665 dprintf(1, "width=%d\n", ginfo->draw->allocation.width);
652 666
653 ginfo->draw_width = new_width; 667 ginfo->draw_width = new_width;
654 668
655 printf("draw_width=%d full_width=%d\n", ginfo->draw_width, ginfo->full_width); 669 dprintf(1, "draw_width=%d full_width=%d\n", ginfo->draw_width, ginfo->full_width);
656 if (ginfo->full_width < view_width) { 670 if (ginfo->full_width < view_width) {
657 reset_graph(ginfo, view_width); 671 reset_graph(ginfo, view_width);
658 time = ginfo->view_start_time; 672 time = ginfo->view_start_time;
@@ -677,7 +691,7 @@ static void zoom_out_window(struct graph_info *ginfo, gint start, gint end)
677 } 691 }
678 } 692 }
679 693
680 printf("new width=%d\n", ginfo->draw_width); 694 dprintf(1, "new width=%d\n", ginfo->draw_width);
681 695
682 /* make sure the width is sent */ 696 /* make sure the width is sent */
683 if (ginfo->draw_width == old_width) 697 if (ginfo->draw_width == old_width)
@@ -731,7 +745,7 @@ static void set_color_by_pid(GtkWidget *widget, GdkGC *gc, gint pid)
731 745
732 if (!(hash & 0xffffff) && last_pid != pid) { 746 if (!(hash & 0xffffff) && last_pid != pid) {
733 last_pid = pid; 747 last_pid = pid;
734 printf("pid=%d is black\n", pid); 748 dprintf(2, "pid=%d is black\n", pid);
735 } 749 }
736 color.red = (hash & 0xff)*(65535/255); 750 color.red = (hash & 0xff)*(65535/255);
737 color.blue = ((hash >> 8) & 0xff)*(65535/255); 751 color.blue = ((hash >> 8) & 0xff)*(65535/255);
@@ -1139,7 +1153,7 @@ configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
1139 1153
1140 /* debug */ 1154 /* debug */
1141 ginfo->vadj_value = gtk_adjustment_get_value(ginfo->vadj); 1155 ginfo->vadj_value = gtk_adjustment_get_value(ginfo->vadj);
1142 printf("get val %f\n", ginfo->vadj_value); 1156 dprintf(2, "get val %f\n", ginfo->vadj_value);
1143 ginfo->vadj_value = 0.0; 1157 ginfo->vadj_value = 0.0;
1144 1158
1145 return TRUE; 1159 return TRUE;
@@ -1151,7 +1165,7 @@ destroy_event(GtkWidget *widget, gpointer data)
1151 struct graph_info *ginfo = data; 1165 struct graph_info *ginfo = data;
1152 1166
1153 if (ginfo->test) 1167 if (ginfo->test)
1154 printf("test = %s\n", ginfo->test); 1168 dprintf(1, "test = %s\n", ginfo->test);
1155 1169
1156 return TRUE; 1170 return TRUE;
1157} 1171}
@@ -1327,10 +1341,10 @@ trace_graph_create_with_callbacks(struct tracecmd_input *handle,
1327 } 1341 }
1328 1342
1329 convert_nano(ginfo->start_time, &sec, &usec); 1343 convert_nano(ginfo->start_time, &sec, &usec);
1330 printf("start=%lu.%06lu ", sec, usec); 1344 dprintf(1,"start=%lu.%06lu ", sec, usec);
1331 1345
1332 convert_nano(ginfo->end_time, &sec, &usec); 1346 convert_nano(ginfo->end_time, &sec, &usec);
1333 printf("end=%lu.%06lu\n", sec, usec); 1347 dprintf(1, "end=%lu.%06lu\n", sec, usec);
1334 1348
1335 ginfo->view_start_time = ginfo->start_time; 1349 ginfo->view_start_time = ginfo->start_time;
1336 ginfo->view_end_time = ginfo->end_time; 1350 ginfo->view_end_time = ginfo->end_time;