aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-02-10 19:23:57 -0500
committerSteven Rostedt <rostedt@goodmis.org>2010-02-10 19:23:57 -0500
commit05e14e9fa3a392719c7cd01f4ea45b6912c2a13d (patch)
treea68554bc6745f5e9bac4f11c6b9c2fa5187f2db5
parentd3e8c138b5fc9dca6f03fc31660117417e9ca321 (diff)
trace-graph: Iterate over all records for all plots
Change the code to iterate once down all records to create all plots. Use the cpu_hash, task_hash and all_recs to find what plot cares about what data. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-graph.c167
-rw-r--r--trace-graph.h38
-rw-r--r--trace-plot-cpu.c31
-rw-r--r--trace-plot-task.c97
-rw-r--r--trace-plot.c43
5 files changed, 204 insertions, 172 deletions
diff --git a/trace-graph.c b/trace-graph.c
index f1f0a2c..2ad7c2f 100644
--- a/trace-graph.c
+++ b/trace-graph.c
@@ -1406,25 +1406,13 @@ static void draw_plot_box(struct graph_info *ginfo, int i,
1406 x2 - x1, PLOT_BOX_SIZE); 1406 x2 - x1, PLOT_BOX_SIZE);
1407} 1407}
1408 1408
1409static void draw_plot(struct graph_info *ginfo, gint i, 1409static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot,
1410 gint new_width, gboolean read_comms) 1410 struct record *record)
1411{ 1411{
1412 static PangoFontDescription *font; 1412 static PangoFontDescription *font;
1413 PangoLayout *layout; 1413 PangoLayout *layout;
1414 gint height = PLOT_LINE(i);
1415 struct graph_plot *plot = ginfo->plot_array[i];
1416 static GdkGC *gc;
1417 static gint width_16; 1414 static gint width_16;
1418 guint64 ts; 1415 struct plot_info info;
1419 gint lcolor;
1420 gint bcolor;
1421 gint last_color = -1;
1422 gboolean box;
1423 gboolean line;
1424 unsigned long long ltime;
1425 unsigned long long bstart;
1426 unsigned long long bend;
1427 gint p1 = 0, p2 = 0, p3 = 0;
1428 gint x; 1416 gint x;
1429 1417
1430 /* Calculate the size of 16 characters */ 1418 /* Calculate the size of 16 characters */
@@ -1442,87 +1430,117 @@ static void draw_plot(struct graph_info *ginfo, gint i,
1442 g_object_unref(layout); 1430 g_object_unref(layout);
1443 } 1431 }
1444 1432
1445 if (!gc) 1433 trace_graph_plot_event(ginfo, plot, record, &info);
1446 gc = gdk_gc_new(ginfo->draw->window);
1447 1434
1448 gdk_draw_line(ginfo->curr_pixmap, ginfo->draw->style->black_gc, 1435 if (info.box) {
1449 0, height, new_width, height); 1436 if (info.bcolor != plot->last_color) {
1437 plot->last_color = info.bcolor;
1438 set_color(ginfo->draw, plot->gc, plot->last_color);
1439 }
1450 1440
1451 ts = ginfo->view_start_time; 1441 draw_plot_box(ginfo, plot->pos, info.bstart, info.bend, plot->gc);
1442 }
1452 1443
1453 trace_graph_plot_start(ginfo, plot, ts); 1444 if (info.line) {
1445 if (info.lcolor != plot->last_color) {
1446 plot->last_color = info.lcolor;
1447 set_color(ginfo->draw, plot->gc, plot->last_color);
1448 }
1454 1449
1455 set_color(ginfo->draw, gc, last_color); 1450 x = draw_plot_line(ginfo, plot->pos, info.ltime, plot->gc);
1456 1451
1457 while (trace_graph_plot_event(ginfo, plot, 1452 /* Figure out if we can show the text for the previous record */
1458 &line, &lcolor, &ltime,
1459 &box, &bcolor, &bstart, &bend)) {
1460 1453
1461 /* really should not happen */ 1454 plot->p3 = x;
1462 if (!line && !box)
1463 continue;
1464 1455
1465 if (box) { 1456 /* Make sure p2 will be non-zero the next iteration */
1466 if (bcolor != last_color) { 1457 if (!plot->p3)
1467 last_color = bcolor; 1458 plot->p3 = 1;
1468 set_color(ginfo->draw, gc, last_color);
1469 }
1470 1459
1471 draw_plot_box(ginfo, i, bstart, bend, gc); 1460 /* first record, continue */
1472 } 1461 if (plot->p2)
1462 plot->p2 = draw_event_label(ginfo, plot->pos,
1463 plot->p1, plot->p2, plot->p3, width_16, font);
1473 1464
1474 if (line) { 1465 plot->p1 = plot->p2;
1466 plot->p2 = plot->p3;
1467 }
1475 1468
1476 if (lcolor != last_color) { 1469 if (!record && plot->p2)
1477 last_color = lcolor; 1470 draw_event_label(ginfo, plot->pos,
1478 set_color(ginfo->draw, gc, last_color); 1471 plot->p1, plot->p2, ginfo->draw_width, width_16, font);
1479 } 1472}
1480 1473
1481 x = draw_plot_line(ginfo, i, ltime, gc); 1474static void draw_plots(struct graph_info *ginfo, gint new_width)
1475{
1476 struct plot_list *list;
1477 struct graph_plot *plot;
1478 struct record *record;
1479 struct plot_hash *hash;
1480 gint pid;
1481 gint cpu;
1482 gint i;
1482 1483
1483 /* Figure out if we can show the text for the previous record */ 1484 /* Initialize plots */
1485 for (i = 0; i < ginfo->plots; i++) {
1486 plot = ginfo->plot_array[i];
1484 1487
1485 p3 = x; 1488 if (!plot->gc)
1489 plot->gc = gdk_gc_new(ginfo->draw->window);
1490 plot->p1 = 0;
1491 plot->p2 = 0;
1492 plot->p3 = 0;
1493 plot->last_color = -1;
1486 1494
1487 /* Make sure p2 will be non-zero the next iteration */ 1495 gdk_draw_line(ginfo->curr_pixmap, ginfo->draw->style->black_gc,
1488 if (!p3) 1496 0, PLOT_LINE(i), new_width, PLOT_LINE(i));
1489 p3 = 1;
1490 1497
1491 /* first record, continue */ 1498 trace_graph_plot_start(ginfo, plot, ginfo->view_start_time);
1492 if (p2)
1493 p2 = draw_event_label(ginfo, i,
1494 p1, p2, p3, width_16, font);
1495 1499
1496 p1 = p2; 1500 set_color(ginfo->draw, plot->gc, plot->last_color);
1497 p2 = p3;
1498 }
1499 } 1501 }
1500 1502
1501 if (box) { 1503 /* Shortcut if we don't have any task plots */
1502 if (bcolor != last_color) { 1504 if (!ginfo->nr_task_hash && !ginfo->all_recs) {
1503 last_color = bcolor; 1505 for (cpu = 0; cpu < ginfo->cpus; cpu++) {
1504 set_color(ginfo->draw, gc, last_color); 1506 hash = trace_graph_plot_find_cpu(ginfo, cpu);
1507 if (!hash)
1508 continue;
1509
1510 while ((record = tracecmd_read_data(ginfo->handle, cpu))) {
1511 for (list = hash->plots; list; list = list->next)
1512 draw_plot(ginfo, list->plot, record);
1513 free_record(record);
1514 }
1505 } 1515 }
1506 1516 goto out;
1507 draw_plot_box(ginfo, i, bstart, bend, gc);
1508 } 1517 }
1509 1518
1510 if (line) { 1519 while ((record = tracecmd_read_next_data(ginfo->handle, &cpu))) {
1511 if (lcolor != last_color) { 1520 hash = trace_graph_plot_find_cpu(ginfo, cpu);
1512 last_color = lcolor; 1521 if (hash) {
1513 set_color(ginfo->draw, gc, last_color); 1522 for (list = hash->plots; list; list = list->next)
1523 draw_plot(ginfo, list->plot, record);
1514 } 1524 }
1515 1525 pid = pevent_data_pid(ginfo->pevent, record);
1516 draw_plot_line(ginfo, i, ltime, gc); 1526 hash = trace_graph_plot_find_task(ginfo, pid);
1527 if (hash) {
1528 for (list = hash->plots; list; list = list->next)
1529 draw_plot(ginfo, list->plot, record);
1530 }
1531 for (list = ginfo->all_recs; list; list = list->next)
1532 draw_plot(ginfo, list->plot, record);
1533 free_record(record);
1517 } 1534 }
1518 1535
1519 if (p2) 1536out:
1520 draw_event_label(ginfo, i, 1537 for (i = 0; i < ginfo->plots; i++) {
1521 p1, p2, ginfo->draw_width, width_16, font); 1538 plot = ginfo->plot_array[i];
1522 1539 draw_plot(ginfo, plot, NULL);
1523 trace_graph_plot_end(ginfo, plot); 1540 trace_graph_plot_end(ginfo, plot);
1524 1541 gdk_gc_unref(plot->gc);
1525 return; 1542 plot->gc = NULL;
1543 }
1526} 1544}
1527 1545
1528 1546
@@ -1614,8 +1632,6 @@ static void draw_timeline(struct graph_info *ginfo, gint width)
1614static void draw_info(struct graph_info *ginfo, 1632static void draw_info(struct graph_info *ginfo,
1615 gint new_width) 1633 gint new_width)
1616{ 1634{
1617 gint i;
1618
1619 if (!ginfo->handle) 1635 if (!ginfo->handle)
1620 return; 1636 return;
1621 1637
@@ -1626,8 +1642,7 @@ static void draw_info(struct graph_info *ginfo,
1626 1642
1627 draw_timeline(ginfo, new_width); 1643 draw_timeline(ginfo, new_width);
1628 1644
1629 for (i = 0; i < ginfo->plots; i++) 1645 draw_plots(ginfo, new_width);
1630 draw_plot(ginfo, i, new_width, ginfo->read_comms);
1631 1646
1632 ginfo->read_comms = FALSE; 1647 ginfo->read_comms = FALSE;
1633} 1648}
diff --git a/trace-graph.h b/trace-graph.h
index f8d582c..1703ba1 100644
--- a/trace-graph.h
+++ b/trace-graph.h
@@ -14,6 +14,16 @@ typedef void (graph_filter_cb)(struct graph_info *ginfo,
14 14
15struct graph_plot; 15struct graph_plot;
16 16
17struct plot_info {
18 gboolean line;
19 int lcolor;
20 unsigned long long ltime;
21 gboolean box;
22 int bcolor;
23 unsigned long long bstart;
24 unsigned long long bend;
25};
26
17/* 27/*
18 * match_time: 28 * match_time:
19 * Return true if a selected time should expose plot. 29 * Return true if a selected time should expose plot.
@@ -25,8 +35,7 @@ struct graph_plot;
25 * to start plotting. 35 * to start plotting.
26 * 36 *
27 * plot_event: 37 * plot_event:
28 * This is called by the plotter. Return 1 to plot an event or 38 * This is called by the plotter.
29 * 0 to stop the plotting.
30 * color returns the color that should be printed. 39 * color returns the color that should be printed.
31 * line returns 1 or 0 if a line should be drawn. 40 * line returns 1 or 0 if a line should be drawn.
32 * ltime returns the time that the line should be drawn at 41 * ltime returns the time that the line should be drawn at
@@ -36,7 +45,6 @@ struct graph_plot;
36 * bend is the time the box ends at 45 * bend is the time the box ends at
37 * (bstart and bend are ignored if box is 0) 46 * (bstart and bend are ignored if box is 0)
38 * time is the time of the current event 47 * time is the time of the current event
39 * (box and line can be true and processed even if the func returns 0)
40 * 48 *
41 * end: 49 * end:
42 * called at the end of the plotting in case the plotter needs to 50 * called at the end of the plotting in case the plotter needs to
@@ -64,11 +72,8 @@ struct plot_callbacks {
64 unsigned long long time); 72 unsigned long long time);
65 int (*plot_event)(struct graph_info *ginfo, 73 int (*plot_event)(struct graph_info *ginfo,
66 struct graph_plot *plot, 74 struct graph_plot *plot,
67 gboolean *line, int *lcolor, 75 struct record *record,
68 unsigned long long *ltime, 76 struct plot_info *info);
69 gboolean *box, int *bcolor,
70 unsigned long long *bstart,
71 unsigned long long *bend);
72 void (*end)(struct graph_info *, struct graph_plot *); 77 void (*end)(struct graph_info *, struct graph_plot *);
73 int (*display_last_event)(struct graph_info *ginfo, struct graph_plot *plot, 78 int (*display_last_event)(struct graph_info *ginfo, struct graph_plot *plot,
74 struct trace_seq *s, unsigned long long time); 79 struct trace_seq *s, unsigned long long time);
@@ -85,6 +90,11 @@ struct graph_plot {
85 char *label; 90 char *label;
86 const struct plot_callbacks *cb; 91 const struct plot_callbacks *cb;
87 void *private; 92 void *private;
93
94 /* Used for drawing */
95 gint last_color;
96 gint p1, p2, p3;
97 GdkGC *gc;
88}; 98};
89 99
90struct graph_callbacks { 100struct graph_callbacks {
@@ -117,6 +127,7 @@ struct graph_info {
117 gint nr_task_hash; 127 gint nr_task_hash;
118 struct plot_hash *task_hash[PLOT_HASH_SIZE]; 128 struct plot_hash *task_hash[PLOT_HASH_SIZE];
119 struct plot_hash *cpu_hash[PLOT_HASH_SIZE]; 129 struct plot_hash *cpu_hash[PLOT_HASH_SIZE];
130 struct plot_list *all_recs;
120 131
121 GtkWidget *widget; /* Box to hold graph */ 132 GtkWidget *widget; /* Box to hold graph */
122 GtkWidget *scrollwin; /* graph scroll window */ 133 GtkWidget *scrollwin; /* graph scroll window */
@@ -263,6 +274,10 @@ void trace_graph_plot_add_cpu(struct graph_info *ginfo, struct graph_plot *plot,
263 gint cpu); 274 gint cpu);
264void trace_graph_plot_remove_cpu(struct graph_info *ginfo, struct graph_plot *plot, 275void trace_graph_plot_remove_cpu(struct graph_info *ginfo, struct graph_plot *plot,
265 gint cpu); 276 gint cpu);
277void trace_graph_plot_add_all_recs(struct graph_info *ginfo,
278 struct graph_plot *plot);
279void trace_graph_plot_remove_all_recs(struct graph_info *ginfo,
280 struct graph_plot *plot);
266 281
267/* plot callbacks */ 282/* plot callbacks */
268int trace_graph_plot_match_time(struct graph_info *ginfo, 283int trace_graph_plot_match_time(struct graph_info *ginfo,
@@ -280,11 +295,8 @@ void trace_graph_plot_start(struct graph_info *ginfo,
280 295
281int trace_graph_plot_event(struct graph_info *ginfo, 296int trace_graph_plot_event(struct graph_info *ginfo,
282 struct graph_plot *plot, 297 struct graph_plot *plot,
283 gboolean *line, int *lcolor, 298 struct record *record,
284 unsigned long long *ltime, 299 struct plot_info *info);
285 gboolean *box, int *bcolor,
286 unsigned long long *bstart,
287 unsigned long long *bend);
288 300
289void trace_graph_plot_end(struct graph_info *ginfo, 301void trace_graph_plot_end(struct graph_info *ginfo,
290 struct graph_plot *plot); 302 struct graph_plot *plot);
diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c
index 2690155..ccc2bff 100644
--- a/trace-plot-cpu.c
+++ b/trace-plot-cpu.c
@@ -204,14 +204,10 @@ static void cpu_plot_start(struct graph_info *ginfo, struct graph_plot *plot,
204 204
205static int cpu_plot_event(struct graph_info *ginfo, 205static int cpu_plot_event(struct graph_info *ginfo,
206 struct graph_plot *plot, 206 struct graph_plot *plot,
207 gboolean *line, int *lcolor, 207 struct record *record,
208 unsigned long long *ltime, 208 struct plot_info *info)
209 gboolean *box, int *bcolor,
210 unsigned long long *bstart,
211 unsigned long long *bend)
212{ 209{
213 struct cpu_plot_info *cpu_info = plot->private; 210 struct cpu_plot_info *cpu_info = plot->private;
214 struct record *record;
215 int sched_pid; 211 int sched_pid;
216 int orig_pid; 212 int orig_pid;
217 int is_sched_switch; 213 int is_sched_switch;
@@ -222,14 +218,13 @@ static int cpu_plot_event(struct graph_info *ginfo,
222 int ret = 1; 218 int ret = 1;
223 219
224 cpu = cpu_info->cpu; 220 cpu = cpu_info->cpu;
225 record = tracecmd_read_data(ginfo->handle, cpu);
226 221
227 if (!record) { 222 if (!record) {
228 /* Finish a box if the last record was not idle */ 223 /* Finish a box if the last record was not idle */
229 if (cpu_info->last_pid > 0) { 224 if (cpu_info->last_pid > 0) {
230 *box = TRUE; 225 info->box = TRUE;
231 *bstart = cpu_info->last_time; 226 info->bstart = cpu_info->last_time;
232 *bend = ginfo->view_end_time; 227 info->bend = ginfo->view_end_time;
233 } 228 }
234 return 0; 229 return 0;
235 } 230 }
@@ -255,19 +250,19 @@ static int cpu_plot_event(struct graph_info *ginfo,
255 box_filter = trace_graph_filter_on_task(ginfo, orig_pid); 250 box_filter = trace_graph_filter_on_task(ginfo, orig_pid);
256 251
257 if (!box_filter && cpu_info->last_pid) { 252 if (!box_filter && cpu_info->last_pid) {
258 *bcolor = hash_pid(cpu_info->last_pid); 253 info->bcolor = hash_pid(cpu_info->last_pid);
259 *box = TRUE; 254 info->box = TRUE;
260 *bstart = cpu_info->last_time; 255 info->bstart = cpu_info->last_time;
261 *bend = record->ts; 256 info->bend = record->ts;
262 } 257 }
263 258
264 cpu_info->last_time = record->ts; 259 cpu_info->last_time = record->ts;
265 } 260 }
266 261
267 if (!filter && !trace_graph_filter_on_event(ginfo, record)) { 262 if (!filter && !trace_graph_filter_on_event(ginfo, record)) {
268 *line = TRUE; 263 info->line = TRUE;
269 *ltime = record->ts; 264 info->ltime = record->ts;
270 *lcolor = hash_pid(pid); 265 info->lcolor = hash_pid(pid);
271 } 266 }
272 267
273 cpu_info->last_pid = pid; 268 cpu_info->last_pid = pid;
@@ -275,8 +270,6 @@ static int cpu_plot_event(struct graph_info *ginfo,
275 if (record->ts > ginfo->view_end_time) 270 if (record->ts > ginfo->view_end_time)
276 ret = 0; 271 ret = 0;
277 272
278 free_record(record);
279
280 return ret; 273 return ret;
281} 274}
282 275
diff --git a/trace-plot-task.c b/trace-plot-task.c
index 6b35586..45a0a32 100644
--- a/trace-plot-task.c
+++ b/trace-plot-task.c
@@ -256,16 +256,11 @@ static void task_plot_start(struct graph_info *ginfo, struct graph_plot *plot,
256 256
257static int task_plot_event(struct graph_info *ginfo, 257static int task_plot_event(struct graph_info *ginfo,
258 struct graph_plot *plot, 258 struct graph_plot *plot,
259 gboolean *line, int *lcolor, 259 struct record *record,
260 unsigned long long *ltime, 260 struct plot_info *info)
261 gboolean *box, int *bcolor,
262 unsigned long long *bstart,
263 unsigned long long *bend)
264{ 261{
265 struct task_plot_info *task_info = plot->private; 262 struct task_plot_info *task_info = plot->private;
266 struct record *record = NULL;
267 gboolean match; 263 gboolean match;
268 int next_cpu;
269 int sched_pid; 264 int sched_pid;
270 int rec_pid; 265 int rec_pid;
271 int is_wakeup; 266 int is_wakeup;
@@ -274,91 +269,83 @@ static int task_plot_event(struct graph_info *ginfo,
274 269
275 pid = task_info->pid; 270 pid = task_info->pid;
276 271
277 do { 272 if (!record) {
278 free_record(record); 273 /* no more records, finish a box if one was started */
279 274 if (task_info->last_cpu >= 0) {
280 record = tracecmd_read_next_data(ginfo->handle, &next_cpu); 275 info->box = TRUE;
281 276 info->bstart = task_info->last_time;
282 if (!record) { 277 info->bend = ginfo->view_end_time;
283 /* no more records, finish a box if one was started */ 278 info->bcolor = hash_cpu(task_info->last_cpu);
284 if (task_info->last_cpu >= 0) {
285 *box = TRUE;
286 *bstart = task_info->last_time;
287 *bend = ginfo->view_end_time;
288 *bcolor = hash_cpu(task_info->last_cpu);
289 }
290 return 0;
291 } 279 }
280 return 0;
281 }
292 282
293 match = record_matches_pid(ginfo, record, pid, &rec_pid, 283 match = record_matches_pid(ginfo, record, pid, &rec_pid,
294 &sched_pid, &is_sched, &is_wakeup); 284 &sched_pid, &is_sched, &is_wakeup);
295 285
296 } while (!match && next_cpu != task_info->last_cpu); 286 if (!match && record->cpu != task_info->last_cpu)
287 return 0;
297 288
298 if (match) { 289 if (match) {
299 *line = TRUE; 290 info->line = TRUE;
300 *lcolor = hash_pid(rec_pid); 291 info->lcolor = hash_pid(rec_pid);
301 *ltime = record->ts; 292 info->ltime = record->ts;
302 293
303 if (is_wakeup) { 294 if (is_wakeup) {
304 /* Wake up but not task */ 295 /* Wake up but not task */
305 *ltime = hash_pid(rec_pid); 296 info->ltime = hash_pid(rec_pid);
306 free_record(record);
307 297
308 /* Another task ? */ 298 /* Another task ? */
309 if (task_info->last_cpu == next_cpu) { 299 if (task_info->last_cpu == record->cpu) {
310 *box = TRUE; 300 info->box = TRUE;
311 *bcolor = hash_cpu(task_info->last_cpu); 301 info->bcolor = hash_cpu(task_info->last_cpu);
312 *bstart = task_info->last_time; 302 info->bstart = task_info->last_time;
313 *bend = record->ts; 303 info->bend = record->ts;
314 task_info->last_cpu = -1; 304 task_info->last_cpu = -1;
315 } 305 }
316 306
317 return 1; 307 return 1;
318 } 308 }
319 309
320 if (task_info->last_cpu != next_cpu) { 310 if (task_info->last_cpu != record->cpu) {
321 if (task_info->last_cpu >= 0) { 311 if (task_info->last_cpu >= 0) {
322 /* Switched CPUs */ 312 /* Switched CPUs */
323 *box = TRUE; 313 info->box = TRUE;
324 *bcolor = hash_cpu(task_info->last_cpu); 314 info->bcolor = hash_cpu(task_info->last_cpu);
325 *bstart = task_info->last_time; 315 info->bstart = task_info->last_time;
326 *bend = record->ts; 316 info->bend = record->ts;
327 } 317 }
328 task_info->last_time = record->ts; 318 task_info->last_time = record->ts;
329 } 319 }
330 320
331 task_info->last_cpu = next_cpu; 321 task_info->last_cpu = record->cpu;
332 if (is_sched) { 322 if (is_sched) {
333 if (rec_pid != pid) { 323 if (rec_pid != pid) {
334 /* Just got scheduled in */ 324 /* Just got scheduled in */
335 task_info->last_cpu = next_cpu; 325 task_info->last_cpu = record->cpu;
336 task_info->last_time = record->ts; 326 task_info->last_time = record->ts;
337 } else if (!*box) { 327 } else if (!info->box) {
338 /* just got scheduled out */ 328 /* just got scheduled out */
339 *box = TRUE; 329 info->box = TRUE;
340 *bcolor = hash_cpu(task_info->last_cpu); 330 info->bcolor = hash_cpu(task_info->last_cpu);
341 *bstart = task_info->last_time; 331 info->bstart = task_info->last_time;
342 *bend = record->ts; 332 info->bend = record->ts;
343 task_info->last_cpu = -1; 333 task_info->last_cpu = -1;
344 } 334 }
345 } 335 }
346 336
347 free_record(record);
348 return 1; 337 return 1;
349 } 338 }
350 339
351 /* not a match, and on the last CPU, scheduled out? */ 340 /* not a match, and on the last CPU, scheduled out? */
352 if (task_info->last_cpu >= 0) { 341 if (task_info->last_cpu >= 0) {
353 *box = TRUE; 342 info->box = TRUE;
354 *bcolor = hash_cpu(task_info->last_cpu); 343 info->bcolor = hash_cpu(task_info->last_cpu);
355 *bstart = task_info->last_time; 344 info->bstart = task_info->last_time;
356 *bend = record->ts; 345 info->bend = record->ts;
357 task_info->last_cpu = -1; 346 task_info->last_cpu = -1;
358 } 347 }
359 348
360 free_record(record);
361
362 return 1; 349 return 1;
363} 350}
364 351
@@ -536,7 +523,7 @@ void task_plot_destroy(struct graph_info *ginfo, struct graph_plot *plot)
536{ 523{
537 struct task_plot_info *task_info = plot->private; 524 struct task_plot_info *task_info = plot->private;
538 525
539 trace_graph_plot_remove_task(ginfo, plot, task_info->pid); 526 trace_graph_plot_remove_all_recs(ginfo, plot);
540 527
541 free(task_info); 528 free(task_info);
542} 529}
@@ -587,5 +574,5 @@ void graph_plot_task(struct graph_info *ginfo, int pid)
587 snprintf(label, 100, "TASK %d", pid); 574 snprintf(label, 100, "TASK %d", pid);
588 plot = trace_graph_plot_append(ginfo, label, &task_plot_cb, task_info); 575 plot = trace_graph_plot_append(ginfo, label, &task_plot_cb, task_info);
589 576
590 trace_graph_plot_add_task(ginfo, plot, pid); 577 trace_graph_plot_add_all_recs(ginfo, plot);
591} 578}
diff --git a/trace-plot.c b/trace-plot.c
index 5ba2ec1..ec76d52 100644
--- a/trace-plot.c
+++ b/trace-plot.c
@@ -262,6 +262,35 @@ void trace_graph_plot_remove_cpu(struct graph_info *ginfo,
262 remove_hash(ginfo->cpu_hash, plot, cpu); 262 remove_hash(ginfo->cpu_hash, plot, cpu);
263} 263}
264 264
265void trace_graph_plot_add_all_recs(struct graph_info *ginfo,
266 struct graph_plot *plot)
267{
268 struct plot_list *list;
269
270 list = malloc_or_die(sizeof(*list));
271 list->next = ginfo->all_recs;
272 list->plot = plot;
273
274 ginfo->all_recs = list;
275}
276
277void trace_graph_plot_remove_all_recs(struct graph_info *ginfo,
278 struct graph_plot *plot)
279{
280 struct plot_list **pplot;
281 struct plot_list *list;
282
283 pplot = &ginfo->all_recs;
284
285 while ((list = *pplot)) {
286 if (list->plot == plot) {
287 *pplot = list->next;
288 free(list);
289 break;
290 }
291 pplot = &list->next;
292 }
293}
265 294
266/* Plot callback helpers */ 295/* Plot callback helpers */
267 296
@@ -287,20 +316,16 @@ void trace_graph_plot_start(struct graph_info *ginfo,
287 316
288int trace_graph_plot_event(struct graph_info *ginfo, 317int trace_graph_plot_event(struct graph_info *ginfo,
289 struct graph_plot *plot, 318 struct graph_plot *plot,
290 gboolean *line, int *lcolor, 319 struct record *record,
291 unsigned long long *ltime, 320 struct plot_info *info)
292 gboolean *box, int *bcolor,
293 unsigned long long *bstart,
294 unsigned long long *bend)
295{ 321{
296 *line = FALSE; 322 info->line = FALSE;
297 *box = FALSE; 323 info->box = FALSE;
298 324
299 if (!plot->cb->plot_event) 325 if (!plot->cb->plot_event)
300 return 0; 326 return 0;
301 327
302 return plot->cb->plot_event(ginfo, plot, line, lcolor, ltime, 328 return plot->cb->plot_event(ginfo, plot, record, info);
303 box, bcolor, bstart, bend);
304} 329}
305 330
306void trace_graph_plot_end(struct graph_info *ginfo, 331void trace_graph_plot_end(struct graph_info *ginfo,