aboutsummaryrefslogtreecommitdiffstats
path: root/trace-plot-cpu.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-09-17 15:37:20 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-09-17 15:37:20 -0400
commit86ca32746ce9384c7fee37bacb6e5b1490a39c74 (patch)
tree0be5394fb94578f63b73ab8144ec8596f74f2d49 /trace-plot-cpu.c
parenta12a227df2a7a93a7f037d3b33183eadc7254591 (diff)
trace-graph: Make zooming in on CPU plots stay filled
Currently when you zoom into a CPU plot, when there are no events in the viewable area, the line turns blank (as if it were just idle). This patch keeps the plot with a bar even if no events are visible. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'trace-plot-cpu.c')
-rw-r--r--trace-plot-cpu.c83
1 files changed, 56 insertions, 27 deletions
diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c
index d6800ef..0e7f5e8 100644
--- a/trace-plot-cpu.c
+++ b/trace-plot-cpu.c
@@ -46,15 +46,10 @@ static void convert_nano(unsigned long long time, unsigned long *sec,
46 *usec = (time / 1000) % 1000000; 46 *usec = (time / 1000) % 1000000;
47} 47}
48 48
49static int cpu_plot_match_time(struct graph_info *ginfo, struct graph_plot *plot, 49static struct record *get_record_from_time(struct graph_info *ginfo, int cpu,
50 unsigned long long time) 50 unsigned long long time)
51{ 51{
52 struct cpu_plot_info *cpu_info = plot->private;
53 struct record *record; 52 struct record *record;
54 long cpu;
55 int ret = 0;
56
57 cpu = cpu_info->cpu;
58 53
59 tracecmd_set_cpu_to_timestamp(ginfo->handle, cpu, time); 54 tracecmd_set_cpu_to_timestamp(ginfo->handle, cpu, time);
60 record = tracecmd_read_data(ginfo->handle, cpu); 55 record = tracecmd_read_data(ginfo->handle, cpu);
@@ -62,6 +57,18 @@ static int cpu_plot_match_time(struct graph_info *ginfo, struct graph_plot *plot
62 free_record(record); 57 free_record(record);
63 record = tracecmd_read_data(ginfo->handle, cpu); 58 record = tracecmd_read_data(ginfo->handle, cpu);
64 } 59 }
60
61 return record;
62}
63
64static int cpu_plot_match_time(struct graph_info *ginfo, struct graph_plot *plot,
65 unsigned long long time)
66{
67 struct cpu_plot_info *cpu_info = plot->private;
68 struct record *record;
69 int ret = 0;
70
71 record = get_record_from_time(ginfo, cpu_info->cpu, time);
65 if (record && record->ts == time) 72 if (record && record->ts == time)
66 ret = 1; 73 ret = 1;
67 free_record(record); 74 free_record(record);
@@ -196,13 +203,46 @@ static void cpu_plot_start(struct graph_info *ginfo, struct graph_plot *plot,
196 cpu_info->last_record = NULL; 203 cpu_info->last_record = NULL;
197} 204}
198 205
206static void update_last_record(struct graph_info *ginfo,
207 struct cpu_plot_info *cpu_info,
208 struct record *record)
209{
210 struct tracecmd_input *handle = ginfo->handle;
211 struct record *trecord;
212 int filter;
213 int sched_pid;
214 int orig_pid;
215 int is_sched_switch;
216
217 if (record)
218 tracecmd_record_ref(record);
219 else
220 record = get_record_from_time(ginfo, cpu_info->cpu,
221 ginfo->view_end_time);
222
223 trecord = tracecmd_read_prev(handle, record);
224 free_record(record);
225
226 if (!trecord)
227 return;
228
229 filter = filter_record(ginfo, trecord,
230 &orig_pid, &sched_pid,
231 &is_sched_switch);
232 cpu_info->last_pid = is_sched_switch ? sched_pid : orig_pid;
233 cpu_info->last_record = trecord;
234 cpu_info->last_time = trecord->ts;
235 /* We moved the cursor, put it back */
236 trecord = tracecmd_read_data(handle, cpu_info->cpu);
237 free_record(trecord);
238}
239
199static int cpu_plot_event(struct graph_info *ginfo, 240static int cpu_plot_event(struct graph_info *ginfo,
200 struct graph_plot *plot, 241 struct graph_plot *plot,
201 struct record *record, 242 struct record *record,
202 struct plot_info *info) 243 struct plot_info *info)
203{ 244{
204 struct cpu_plot_info *cpu_info = plot->private; 245 struct cpu_plot_info *cpu_info = plot->private;
205 struct tracecmd_input *handle = ginfo->handle;
206 int sched_pid; 246 int sched_pid;
207 int orig_pid; 247 int orig_pid;
208 int is_sched_switch; 248 int is_sched_switch;
@@ -215,10 +255,8 @@ static int cpu_plot_event(struct graph_info *ginfo,
215 cpu = cpu_info->cpu; 255 cpu = cpu_info->cpu;
216 256
217 if (!record) { 257 if (!record) {
218 if (cpu_info->last_record) { 258 if (!cpu_info->last_record)
219 free_record(cpu_info->last_record); 259 update_last_record(ginfo, cpu_info, record);
220 cpu_info->last_record = NULL;
221 }
222 260
223 /* Finish a box if the last record was not idle */ 261 /* Finish a box if the last record was not idle */
224 if (cpu_info->last_pid > 0) { 262 if (cpu_info->last_pid > 0) {
@@ -227,6 +265,10 @@ static int cpu_plot_event(struct graph_info *ginfo,
227 info->bend = ginfo->view_end_time; 265 info->bend = ginfo->view_end_time;
228 info->bcolor = hash_pid(cpu_info->last_pid); 266 info->bcolor = hash_pid(cpu_info->last_pid);
229 } 267 }
268 if (cpu_info->last_record) {
269 free_record(cpu_info->last_record);
270 cpu_info->last_record = NULL;
271 }
230 return 0; 272 return 0;
231 } 273 }
232 274
@@ -234,21 +276,8 @@ static int cpu_plot_event(struct graph_info *ginfo,
234 * If last record is NULL, then it may exist off the 276 * If last record is NULL, then it may exist off the
235 * viewable range. Search to see if one exists. 277 * viewable range. Search to see if one exists.
236 */ 278 */
237 if (!cpu_info->last_record) { 279 if (!cpu_info->last_record)
238 struct record *trecord; 280 update_last_record(ginfo, cpu_info, record);
239
240 trecord = tracecmd_read_prev(handle, record);
241 if (trecord) {
242 filter = filter_record(ginfo, trecord,
243 &orig_pid, &sched_pid,
244 &is_sched_switch);
245 cpu_info->last_pid = is_sched_switch ? sched_pid : orig_pid;
246 }
247 cpu_info->last_record = trecord;
248 /* We moved the cursor, put it back */
249 trecord = tracecmd_read_data(handle, record->cpu);
250 free_record(trecord);
251 }
252 281
253 free_record(cpu_info->last_record); 282 free_record(cpu_info->last_record);
254 cpu_info->last_record = record; 283 cpu_info->last_record = record;