Thread (28 messages) 28 messages, 5 authors, 2016-09-14
STALE3583d REVIEWED: 1 (0M)
Revisions (8)
  1. v14 [diff vs current]
  2. v15 [diff vs current]
  3. v16 [diff vs current]
  4. v17 [diff vs current]
  5. v17 [diff vs current]
  6. v19 [diff vs current]
  7. v20 current
  8. v21 [diff vs current]

[PATCH v20 15/20] perf, tools: Handle header line in mapfile

From: Sukadev Bhattiprolu <hidden>
Date: 2016-06-21 06:08:17
Also in: lkml
Subsystem: performance events subsystem, the rest · Maintainers: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Linus Torvalds

From: Andi Kleen <redacted>

To work with existing mapfiles, assume that the first line in
'mapfile.csv' is a header line and skip over it.

Signed-off-by: Andi Kleen <redacted>
Signed-off-by: Sukadev Bhattiprolu <redacted>
Acked-by: Jiri Olsa <redacted>
---

Changelog[v2]
	All architectures may not use the "Family" to identify. So,
	assume first line is header.
---
 tools/perf/pmu-events/jevents.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
index a4f117c..b701d77 100644
--- a/tools/perf/pmu-events/jevents.c
+++ b/tools/perf/pmu-events/jevents.c
@@ -463,7 +463,12 @@ static int process_mapfile(FILE *outfp, char *fpath)
 
 	print_mapping_table_prefix(outfp);
 
-	line_num = 0;
+	/* Skip first line (header) */
+	p = fgets(line, n, mapfp);
+	if (!p)
+		goto out;
+
+	line_num = 1;
 	while (1) {
 		char *cpuid, *version, *type, *fname;
 
@@ -507,8 +512,8 @@ static int process_mapfile(FILE *outfp, char *fpath)
 		fprintf(outfp, "},\n");
 	}
 
+out:
 	print_mapping_table_suffix(outfp);
-
 	return 0;
 }
 
-- 
2.5.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help