aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/perf/ui/hist.c40
-rw-r--r--tools/perf/ui/stdio/hist.c41
-rw-r--r--tools/perf/util/hist.h2
3 files changed, 41 insertions, 42 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index dc900d7a190e..0a193281eba8 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -236,46 +236,6 @@ void perf_hpp__column_enable(unsigned col)
236 perf_hpp__column_register(&perf_hpp__format[col]); 236 perf_hpp__column_register(&perf_hpp__format[col]);
237} 237}
238 238
239static inline void advance_hpp(struct perf_hpp *hpp, int inc)
240{
241 hpp->buf += inc;
242 hpp->size -= inc;
243}
244
245int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,
246 bool color)
247{
248 const char *sep = symbol_conf.field_sep;
249 struct perf_hpp_fmt *fmt;
250 char *start = hpp->buf;
251 int ret;
252 bool first = true;
253
254 if (symbol_conf.exclude_other && !he->parent)
255 return 0;
256
257 perf_hpp__for_each_format(fmt) {
258 /*
259 * If there's no field_sep, we still need
260 * to display initial ' '.
261 */
262 if (!sep || !first) {
263 ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " ");
264 advance_hpp(hpp, ret);
265 } else
266 first = false;
267
268 if (color && fmt->color)
269 ret = fmt->color(fmt, hpp, he);
270 else
271 ret = fmt->entry(fmt, hpp, he);
272
273 advance_hpp(hpp, ret);
274 }
275
276 return hpp->buf - start;
277}
278
279int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size, 239int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size,
280 struct hists *hists) 240 struct hists *hists)
281{ 241{
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index ee703720649d..5b4fb330f656 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -308,6 +308,47 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
308 return hist_entry_callchain__fprintf(he, total_period, left_margin, fp); 308 return hist_entry_callchain__fprintf(he, total_period, left_margin, fp);
309} 309}
310 310
311static inline void advance_hpp(struct perf_hpp *hpp, int inc)
312{
313 hpp->buf += inc;
314 hpp->size -= inc;
315}
316
317static int hist_entry__period_snprintf(struct perf_hpp *hpp,
318 struct hist_entry *he,
319 bool color)
320{
321 const char *sep = symbol_conf.field_sep;
322 struct perf_hpp_fmt *fmt;
323 char *start = hpp->buf;
324 int ret;
325 bool first = true;
326
327 if (symbol_conf.exclude_other && !he->parent)
328 return 0;
329
330 perf_hpp__for_each_format(fmt) {
331 /*
332 * If there's no field_sep, we still need
333 * to display initial ' '.
334 */
335 if (!sep || !first) {
336 ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " ");
337 advance_hpp(hpp, ret);
338 } else
339 first = false;
340
341 if (color && fmt->color)
342 ret = fmt->color(fmt, hpp, he);
343 else
344 ret = fmt->entry(fmt, hpp, he);
345
346 advance_hpp(hpp, ret);
347 }
348
349 return hpp->buf - start;
350}
351
311static int hist_entry__fprintf(struct hist_entry *he, size_t size, 352static int hist_entry__fprintf(struct hist_entry *he, size_t size,
312 struct hists *hists, FILE *fp) 353 struct hists *hists, FILE *fp)
313{ 354{
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index bfcbb11c2648..1329b6b6ffe6 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -174,8 +174,6 @@ enum {
174void perf_hpp__init(void); 174void perf_hpp__init(void);
175void perf_hpp__column_register(struct perf_hpp_fmt *format); 175void perf_hpp__column_register(struct perf_hpp_fmt *format);
176void perf_hpp__column_enable(unsigned col); 176void perf_hpp__column_enable(unsigned col);
177int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,
178 bool color);
179 177
180struct perf_evlist; 178struct perf_evlist;
181 179