All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	David Ahern <dsahern@gmail.com>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 4/5] perf tools stdio: Display multiple header lines
Date: Sun,  7 Aug 2016 17:28:29 +0200	[thread overview]
Message-ID: <1470583710-1649-5-git-send-email-jolsa@kernel.org> (raw)
In-Reply-To: <1470583710-1649-1-git-send-email-jolsa@kernel.org>

Display multiple header lines in stdio output , if it's
configured within struct perf_hpp_list::nr_header_lines.

Link: http://lkml.kernel.org/n/tip-7zjyhlkjwibmxwt0ku50cs4v@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/stdio/hist.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 91b8e10cabd5..9b807cbb56b1 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -639,13 +639,10 @@ hists__fprintf_hierarchy_headers(struct hists *hists,
 	return print_hierarchy_header(hists, hpp, symbol_conf.field_sep, fp);
 }
 
-static int
-hists__fprintf_standard_headers(struct hists *hists,
-				struct perf_hpp *hpp,
-				FILE *fp)
+static void fprintf_line(struct hists *hists, struct perf_hpp *hpp,
+			 int line, FILE *fp)
 {
 	struct perf_hpp_fmt *fmt;
-	unsigned int width;
 	const char *sep = symbol_conf.field_sep;
 	bool first = true;
 
@@ -658,14 +655,33 @@ hists__fprintf_standard_headers(struct hists *hists,
 		else
 			first = false;
 
-		fmt->header(fmt, hpp, hists, 0);
+		fmt->header(fmt, hpp, hists, line);
 		fprintf(fp, "%s", hpp->buf);
 	}
+}
 
-	fprintf(fp, "\n");
+static int
+hists__fprintf_standard_headers(struct hists *hists,
+				struct perf_hpp *hpp,
+				FILE *fp)
+{
+	struct perf_hpp_list *hpp_list = hists->hpp_list;
+	struct perf_hpp_fmt *fmt;
+	unsigned int width;
+	const char *sep = symbol_conf.field_sep;
+	bool first = true;
+	int line;
+
+	for (line = 0; line < hpp_list->nr_header_lines; line++) {
+		/* first # is displayed one level up */
+		if (line)
+			fprintf(fp, "# ");
+		fprintf_line(hists, hpp, line, fp);
+		fprintf(fp, "\n");
+	}
 
 	if (sep)
-		return 1;
+		return hpp_list->nr_header_lines;
 
 	first = true;
 
@@ -689,7 +705,7 @@ hists__fprintf_standard_headers(struct hists *hists,
 
 	fprintf(fp, "\n");
 	fprintf(fp, "#\n");
-	return 3;
+	return hpp_list->nr_header_lines + 2;
 }
 
 static int hists__fprintf_headers(struct hists *hists, FILE *fp)
-- 
2.4.11

  parent reply	other threads:[~2016-08-07 15:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-07 15:28 [PATCH 0/5] perf tools: Add support for multiline headers and spans Jiri Olsa
2016-08-07 15:28 ` [PATCH 1/5] perf tools: Introduce nr_header_lines into struct perf_hpp_list Jiri Olsa
2016-08-24  9:19   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-08-07 15:28 ` [PATCH 2/5] perf tools: Add line argument into perf_hpp_fmt's header callback Jiri Olsa
2016-08-24  9:19   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa
2016-08-07 15:28 ` [PATCH 3/5] perf tools tui: Display multiple header lines Jiri Olsa
2016-08-24  9:20   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-08-07 15:28 ` Jiri Olsa [this message]
2016-08-24  9:20   ` [tip:perf/core] perf tools stdio: " tip-bot for Jiri Olsa
2016-08-07 15:28 ` [PATCH 5/5] perf tools: Add support for header span Jiri Olsa
2016-08-24  9:21   ` [tip:perf/core] perf hists: " tip-bot for Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470583710-1649-5-git-send-email-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.