aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAkihiro Nagai <akihiro.nagai.hw@hitachi.com>2012-01-29 23:42:57 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-01-30 14:57:57 -0500
commit547a92e0aedb88129e7fbd804697a11949de2e5a (patch)
treedbe71c0161ef32186de12032f4f0238383517dc4 /tools
parentf9d36996564f91c517b75b02942015f7e09a6574 (diff)
perf script: Unify the expressions indicating "unknown"
The perf script command uses various expressions to indicate "unknown". It is unfriendly for user scripts to parse it. So, this patch unifies the expressions to "[unknown]". Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: yrl.pp-manager.tt@hitachi.com Link: http://lkml.kernel.org/r/20120130044257.2384.62905.stgit@linux3 Signed-off-by: Akihiro Nagai <akihiro.nagai.hw@hitachi.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-script.c20
-rw-r--r--tools/perf/util/map.c12
-rw-r--r--tools/perf/util/map.h1
-rw-r--r--tools/perf/util/session.c35
-rw-r--r--tools/perf/util/symbol.c12
-rw-r--r--tools/perf/util/symbol.h1
6 files changed, 42 insertions, 39 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index bb68ddf257b7..add13ec15977 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -300,7 +300,7 @@ static void print_sample_start(struct perf_sample *sample,
300 } else 300 } else
301 evname = __event_name(attr->type, attr->config); 301 evname = __event_name(attr->type, attr->config);
302 302
303 printf("%s: ", evname ? evname : "(unknown)"); 303 printf("%s: ", evname ? evname : "[unknown]");
304 } 304 }
305} 305}
306 306
@@ -323,7 +323,6 @@ static void print_sample_addr(union perf_event *event,
323{ 323{
324 struct addr_location al; 324 struct addr_location al;
325 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; 325 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
326 const char *symname, *dsoname;
327 326
328 printf("%16" PRIx64, sample->addr); 327 printf("%16" PRIx64, sample->addr);
329 328
@@ -343,21 +342,14 @@ static void print_sample_addr(union perf_event *event,
343 al.sym = map__find_symbol(al.map, al.addr, NULL); 342 al.sym = map__find_symbol(al.map, al.addr, NULL);
344 343
345 if (PRINT_FIELD(SYM)) { 344 if (PRINT_FIELD(SYM)) {
346 if (al.sym && al.sym->name) 345 printf(" ");
347 symname = al.sym->name; 346 symbol__fprintf_symname(al.sym, stdout);
348 else
349 symname = "";
350
351 printf(" %16s", symname);
352 } 347 }
353 348
354 if (PRINT_FIELD(DSO)) { 349 if (PRINT_FIELD(DSO)) {
355 if (al.map && al.map->dso && al.map->dso->name) 350 printf(" (");
356 dsoname = al.map->dso->name; 351 map__fprintf_dsoname(al.map, stdout);
357 else 352 printf(")");
358 dsoname = "";
359
360 printf(" (%s)", dsoname);
361 } 353 }
362} 354}
363 355
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 316aa0ab7122..11079607105b 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -212,6 +212,18 @@ size_t map__fprintf(struct map *self, FILE *fp)
212 self->start, self->end, self->pgoff, self->dso->name); 212 self->start, self->end, self->pgoff, self->dso->name);
213} 213}
214 214
215size_t map__fprintf_dsoname(struct map *map, FILE *fp)
216{
217 const char *dsoname;
218
219 if (map && map->dso && map->dso->name)
220 dsoname = map->dso->name;
221 else
222 dsoname = "[unknown]";
223
224 return fprintf(fp, "%s", dsoname);
225}
226
215/* 227/*
216 * objdump wants/reports absolute IPs for ET_EXEC, and RIPs for ET_DYN. 228 * objdump wants/reports absolute IPs for ET_EXEC, and RIPs for ET_DYN.
217 * map->dso->adjust_symbols==1 for ET_EXEC-like cases. 229 * map->dso->adjust_symbols==1 for ET_EXEC-like cases.
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 2b8017f8a930..b100c20b7f94 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -118,6 +118,7 @@ void map__delete(struct map *self);
118struct map *map__clone(struct map *self); 118struct map *map__clone(struct map *self);
119int map__overlap(struct map *l, struct map *r); 119int map__overlap(struct map *l, struct map *r);
120size_t map__fprintf(struct map *self, FILE *fp); 120size_t map__fprintf(struct map *self, FILE *fp);
121size_t map__fprintf_dsoname(struct map *map, FILE *fp);
121 122
122int map__load(struct map *self, symbol_filter_t filter); 123int map__load(struct map *self, symbol_filter_t filter);
123struct symbol *map__find_symbol(struct map *self, 124struct symbol *map__find_symbol(struct map *self,
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index b5ca2558c7bb..e5334a976536 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1296,7 +1296,6 @@ void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
1296 int print_sym, int print_dso) 1296 int print_sym, int print_dso)
1297{ 1297{
1298 struct addr_location al; 1298 struct addr_location al;
1299 const char *symname, *dsoname;
1300 struct callchain_cursor *cursor = &evsel->hists.callchain_cursor; 1299 struct callchain_cursor *cursor = &evsel->hists.callchain_cursor;
1301 struct callchain_cursor_node *node; 1300 struct callchain_cursor_node *node;
1302 1301
@@ -1324,20 +1323,13 @@ void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
1324 1323
1325 printf("\t%16" PRIx64, node->ip); 1324 printf("\t%16" PRIx64, node->ip);
1326 if (print_sym) { 1325 if (print_sym) {
1327 if (node->sym && node->sym->name) 1326 printf(" ");
1328 symname = node->sym->name; 1327 symbol__fprintf_symname(node->sym, stdout);
1329 else
1330 symname = "";
1331
1332 printf(" %s", symname);
1333 } 1328 }
1334 if (print_dso) { 1329 if (print_dso) {
1335 if (node->map && node->map->dso && node->map->dso->name) 1330 printf(" (");
1336 dsoname = node->map->dso->name; 1331 map__fprintf_dsoname(al.map, stdout);
1337 else 1332 printf(")");
1338 dsoname = "";
1339
1340 printf(" (%s)", dsoname);
1341 } 1333 }
1342 printf("\n"); 1334 printf("\n");
1343 1335
@@ -1347,21 +1339,14 @@ void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
1347 } else { 1339 } else {
1348 printf("%16" PRIx64, sample->ip); 1340 printf("%16" PRIx64, sample->ip);
1349 if (print_sym) { 1341 if (print_sym) {
1350 if (al.sym && al.sym->name) 1342 printf(" ");
1351 symname = al.sym->name; 1343 symbol__fprintf_symname(al.sym, stdout);
1352 else
1353 symname = "";
1354
1355 printf(" %s", symname);
1356 } 1344 }
1357 1345
1358 if (print_dso) { 1346 if (print_dso) {
1359 if (al.map && al.map->dso && al.map->dso->name) 1347 printf(" (");
1360 dsoname = al.map->dso->name; 1348 map__fprintf_dsoname(al.map, stdout);
1361 else 1349 printf(")");
1362 dsoname = "";
1363
1364 printf(" (%s)", dsoname);
1365 } 1350 }
1366 } 1351 }
1367} 1352}
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 0975438c3e72..b580fa82911a 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -263,6 +263,18 @@ static size_t symbol__fprintf(struct symbol *sym, FILE *fp)
263 sym->name); 263 sym->name);
264} 264}
265 265
266size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp)
267{
268 const char *symname;
269
270 if (sym && sym->name)
271 symname = sym->name;
272 else
273 symname = "[unknown]";
274
275 return fprintf(fp, "%s", symname);
276}
277
266void dso__set_long_name(struct dso *dso, char *name) 278void dso__set_long_name(struct dso *dso, char *name)
267{ 279{
268 if (name == NULL) 280 if (name == NULL)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 123c2e14353e..d349c7a00b04 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -241,6 +241,7 @@ void machines__destroy_guest_kernel_maps(struct rb_root *machines);
241 241
242int symbol__init(void); 242int symbol__init(void);
243void symbol__exit(void); 243void symbol__exit(void);
244size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp);
244bool symbol_type__is_a(char symbol_type, enum map_type map_type); 245bool symbol_type__is_a(char symbol_type, enum map_type map_type);
245 246
246size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp); 247size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);