diff options
Diffstat (limited to 'rt-plot-task.c')
-rw-r--r-- | rt-plot-task.c | 83 |
1 files changed, 64 insertions, 19 deletions
diff --git a/rt-plot-task.c b/rt-plot-task.c index 852f323..48bcdde 100644 --- a/rt-plot-task.c +++ b/rt-plot-task.c | |||
@@ -1,10 +1,7 @@ | |||
1 | #include "trace-graph.h" | 1 | #include "trace-graph.h" |
2 | #include "trace-filter.h" | 2 | #include "trace-filter.h" |
3 | 3 | ||
4 | #define LLABEL 30 | 4 | #define DEBUG_LEVEL 0 |
5 | #define SEARCH_PERIODS 3 | ||
6 | |||
7 | #define DEBUG_LEVEL 3 | ||
8 | #if DEBUG_LEVEL > 0 | 5 | #if DEBUG_LEVEL > 0 |
9 | #define dprintf(l, x...) \ | 6 | #define dprintf(l, x...) \ |
10 | do { \ | 7 | do { \ |
@@ -59,12 +56,10 @@ next_box_record(struct graph_info *ginfo, struct rt_task_info *rtt_info, | |||
59 | max_ts = ginfo->view_end_time + | 56 | max_ts = ginfo->view_end_time + |
60 | SEARCH_PERIODS * rtg_info->max_period; | 57 | SEARCH_PERIODS * rtg_info->max_period; |
61 | set_cpus_to_rts(ginfo, time); | 58 | set_cpus_to_rts(ginfo, time); |
62 | do { | 59 | while ((record = tracecmd_read_next_data(ginfo->handle, &cpu))) { |
63 | free_record(record); | 60 | if (get_rts(ginfo, record) > max_ts) { |
64 | record = tracecmd_read_next_data(ginfo->handle, &cpu); | ||
65 | if (!record || get_rts(ginfo, record) > max_ts) { | ||
66 | free_record(record); | 61 | free_record(record); |
67 | goto out; | 62 | break; |
68 | } | 63 | } |
69 | 64 | ||
70 | /* Sorry mother */ | 65 | /* Sorry mother */ |
@@ -79,10 +74,10 @@ next_box_record(struct graph_info *ginfo, struct rt_task_info *rtt_info, | |||
79 | if (eid && pid == rtt_info->pid) { | 74 | if (eid && pid == rtt_info->pid) { |
80 | ret = record; | 75 | ret = record; |
81 | *out_eid = eid; | 76 | *out_eid = eid; |
82 | goto out; | 77 | break; |
83 | } | 78 | } |
84 | } while (get_rts(ginfo, record) < max_ts); | 79 | free_record(record); |
85 | out: | 80 | }; |
86 | return ret; | 81 | return ret; |
87 | } | 82 | } |
88 | 83 | ||
@@ -561,8 +556,9 @@ static void rt_task_plot_destroy(struct graph_info *ginfo, struct graph_plot *pl | |||
561 | { | 556 | { |
562 | struct rt_task_info *rtt_info = plot->private; | 557 | struct rt_task_info *rtt_info = plot->private; |
563 | dprintf(4,"%s\n", __FUNCTION__); | 558 | dprintf(4,"%s\n", __FUNCTION__); |
559 | trace_graph_plot_remove_all_recs(ginfo, plot); | ||
564 | free(rtt_info->label); | 560 | free(rtt_info->label); |
565 | task_plot_destroy(ginfo, plot); | 561 | free(rtt_info); |
566 | } | 562 | } |
567 | 563 | ||
568 | static int rt_task_plot_display_last_event(struct graph_info *ginfo, | 564 | static int rt_task_plot_display_last_event(struct graph_info *ginfo, |
@@ -716,8 +712,61 @@ void rt_plot_task_update_callback(gboolean accept, | |||
716 | gint *non_select, | 712 | gint *non_select, |
717 | gpointer data) | 713 | gpointer data) |
718 | { | 714 | { |
719 | graph_tasks_update_callback(PLOT_TYPE_RT_TASK, rt_plot_task, | 715 | struct graph_info *ginfo = data; |
720 | accept, selected, non_select, data); | 716 | struct rt_task_info *rtt_info; |
717 | struct graph_plot *plot; | ||
718 | gint select_size = 0; | ||
719 | gint *ptr; | ||
720 | int i; | ||
721 | |||
722 | if (!accept) | ||
723 | return; | ||
724 | |||
725 | /* The selected and non_select are sorted */ | ||
726 | if (selected) { | ||
727 | for (i = 0; selected[i] >= 0; i++) | ||
728 | ; | ||
729 | select_size = i; | ||
730 | } | ||
731 | |||
732 | /* | ||
733 | * Remove and add task plots. | ||
734 | * Go backwards, since removing a plot shifts the | ||
735 | * array from current position back. | ||
736 | */ | ||
737 | for (i = ginfo->plots - 1; i >= 0; i--) { | ||
738 | plot = ginfo->plot_array[i]; | ||
739 | if (plot->type != PLOT_TYPE_RT_TASK) | ||
740 | continue; | ||
741 | rtt_info = plot->private; | ||
742 | |||
743 | /* If non are selected, then remove all */ | ||
744 | if (!select_size) { | ||
745 | trace_graph_plot_remove(ginfo, plot); | ||
746 | continue; | ||
747 | } | ||
748 | ptr = bsearch(&rtt_info->pid, selected, select_size, | ||
749 | sizeof(gint), id_cmp); | ||
750 | if (ptr) { | ||
751 | /* | ||
752 | * This plot plot already exists, remove it | ||
753 | * from the selected array. | ||
754 | */ | ||
755 | memmove(ptr, ptr + 1, | ||
756 | (unsigned long)(selected + select_size) - | ||
757 | (unsigned long)(ptr + 1)); | ||
758 | select_size--; | ||
759 | continue; | ||
760 | } | ||
761 | /* Remove the plot */ | ||
762 | trace_graph_plot_remove(ginfo, plot); | ||
763 | } | ||
764 | |||
765 | /* Now add any plots that need to be added */ | ||
766 | for (i = 0; i < select_size; i++) | ||
767 | rt_plot_task(ginfo, selected[i], ginfo->plots); | ||
768 | |||
769 | trace_graph_refresh(ginfo); | ||
721 | } | 770 | } |
722 | 771 | ||
723 | void rt_plot_task_plotted(struct graph_info *ginfo, gint **plotted) | 772 | void rt_plot_task_plotted(struct graph_info *ginfo, gint **plotted) |
@@ -774,9 +823,5 @@ void rt_plot_task(struct graph_info *ginfo, int pid, int pos) | |||
774 | TIME_TYPE_RT, | 823 | TIME_TYPE_RT, |
775 | &rt_task_cb, rtt_info); | 824 | &rt_task_cb, rtt_info); |
776 | free(plot_label); | 825 | free(plot_label); |
777 | |||
778 | printf("Created plot for %s-%d / %d %p\n", comm, pid, rtt_info->pid, | ||
779 | rtt_info); | ||
780 | |||
781 | trace_graph_plot_add_all_recs(ginfo, plot); | 826 | trace_graph_plot_add_all_recs(ginfo, plot); |
782 | } | 827 | } |