]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
perf tools: Add fprintf methods for thread_map and cpu_map classes
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 19 Jan 2012 16:07:23 +0000 (14:07 -0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 24 Jan 2012 21:46:48 +0000 (19:46 -0200)
For helping with debugging.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-m06n4rp7pwr6dlzwoq89cl69@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/cpumap.c
tools/perf/util/cpumap.h
tools/perf/util/thread_map.c
tools/perf/util/thread_map.h

index 6893eec693abad5ad8e5af88f1c8ee107c63e713..adc72f09914d0c8089bd104784284928da3cd1f9 100644 (file)
@@ -166,6 +166,17 @@ out:
        return cpus;
 }
 
+size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp)
+{
+       int i;
+       size_t printed = fprintf(fp, "%d cpu%s: ",
+                                map->nr, map->nr > 1 ? "s" : "");
+       for (i = 0; i < map->nr; ++i)
+               printed += fprintf(fp, "%s%d", i ? ", " : "", map->map[i]);
+
+       return printed + fprintf(fp, "\n");
+}
+
 struct cpu_map *cpu_map__dummy_new(void)
 {
        struct cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int));
index 072c0a374794eafcdbfd628ae80c9fe1b0e88240..c41518573c6af013e5de3c16d916bfac84e92897 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __PERF_CPUMAP_H
 #define __PERF_CPUMAP_H
 
+#include <stdio.h>
+
 struct cpu_map {
        int nr;
        int map[];
@@ -10,4 +12,6 @@ struct cpu_map *cpu_map__new(const char *cpu_list);
 struct cpu_map *cpu_map__dummy_new(void);
 void cpu_map__delete(struct cpu_map *map);
 
+size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);
+
 #endif /* __PERF_CPUMAP_H */
index a5df131b77c322f673ba0edd1bf16352744d9122..894d52f65166edbf37392f89284849d3440d3e5e 100644 (file)
@@ -62,3 +62,14 @@ void thread_map__delete(struct thread_map *threads)
 {
        free(threads);
 }
+
+size_t thread_map__fprintf(struct thread_map *threads, FILE *fp)
+{
+       int i;
+       size_t printed = fprintf(fp, "%d thread%s: ",
+                                threads->nr, threads->nr > 1 ? "s" : "");
+       for (i = 0; i < threads->nr; ++i)
+               printed += fprintf(fp, "%s%d", i ? ", " : "", threads->map[i]);
+
+       return printed + fprintf(fp, "\n");
+}
index 3cb907311409fb6e62c3ffb8c147607e2c055e69..736ab4a26210c730eef3877e9c6af3eecab3c086 100644 (file)
@@ -2,6 +2,7 @@
 #define __PERF_THREAD_MAP_H
 
 #include <sys/types.h>
+#include <stdio.h>
 
 struct thread_map {
        int nr;
@@ -12,4 +13,7 @@ struct thread_map *thread_map__new_by_pid(pid_t pid);
 struct thread_map *thread_map__new_by_tid(pid_t tid);
 struct thread_map *thread_map__new(pid_t pid, pid_t tid);
 void thread_map__delete(struct thread_map *threads);
+
+size_t thread_map__fprintf(struct thread_map *threads, FILE *fp);
+
 #endif /* __PERF_THREAD_MAP_H */