perf report: add --dump-raw-trace option
To help the inspection of various data files, implement an ASCII dump method that just dumps the records as they are read in - then we exit. [ Impact: new feature ] Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: John Kacur <jkacur@redhat.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
abd54f6862
commit
97b07b699b
|
@ -20,6 +20,8 @@ static char const *input_name = "output.perf";
|
||||||
static int input;
|
static int input;
|
||||||
static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
|
static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
|
||||||
|
|
||||||
|
static int dump_trace = 0;
|
||||||
|
|
||||||
static unsigned long page_size;
|
static unsigned long page_size;
|
||||||
static unsigned long mmap_window = 32;
|
static unsigned long mmap_window = 32;
|
||||||
|
|
||||||
|
@ -643,7 +645,7 @@ static int __cmd_report(void)
|
||||||
char *buf;
|
char *buf;
|
||||||
event_t *event;
|
event_t *event;
|
||||||
int ret, rc = EXIT_FAILURE;
|
int ret, rc = EXIT_FAILURE;
|
||||||
unsigned long total = 0;
|
unsigned long total = 0, total_mmap = 0, total_comm = 0;
|
||||||
|
|
||||||
input = open(input_name, O_RDONLY);
|
input = open(input_name, O_RDONLY);
|
||||||
if (input < 0) {
|
if (input < 0) {
|
||||||
|
@ -706,6 +708,13 @@ more:
|
||||||
struct thread *thread = threads__findnew(event->ip.pid);
|
struct thread *thread = threads__findnew(event->ip.pid);
|
||||||
uint64_t ip = event->ip.ip;
|
uint64_t ip = event->ip.ip;
|
||||||
|
|
||||||
|
if (dump_trace) {
|
||||||
|
fprintf(stderr, "PERF_EVENT (IP, %d): %d: %p\n",
|
||||||
|
event->header.misc,
|
||||||
|
event->ip.pid,
|
||||||
|
(void *)event->ip.ip);
|
||||||
|
}
|
||||||
|
|
||||||
if (thread == NULL) {
|
if (thread == NULL) {
|
||||||
fprintf(stderr, "problem processing %d event, bailing out\n",
|
fprintf(stderr, "problem processing %d event, bailing out\n",
|
||||||
event->header.type);
|
event->header.type);
|
||||||
|
@ -743,23 +752,40 @@ more:
|
||||||
struct thread *thread = threads__findnew(event->mmap.pid);
|
struct thread *thread = threads__findnew(event->mmap.pid);
|
||||||
struct map *map = map__new(&event->mmap);
|
struct map *map = map__new(&event->mmap);
|
||||||
|
|
||||||
|
if (dump_trace) {
|
||||||
|
fprintf(stderr, "PERF_EVENT_MMAP: [%p(%p) @ %p]: %s\n",
|
||||||
|
(void *)event->mmap.start,
|
||||||
|
(void *)event->mmap.len,
|
||||||
|
(void *)event->mmap.pgoff,
|
||||||
|
event->mmap.filename);
|
||||||
|
}
|
||||||
if (thread == NULL || map == NULL) {
|
if (thread == NULL || map == NULL) {
|
||||||
fprintf(stderr, "problem processing PERF_EVENT_MMAP, bailing out\n");
|
fprintf(stderr, "problem processing PERF_EVENT_MMAP, bailing out\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
thread__insert_map(thread, map);
|
thread__insert_map(thread, map);
|
||||||
|
total_mmap++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PERF_EVENT_COMM: {
|
case PERF_EVENT_COMM: {
|
||||||
struct thread *thread = threads__findnew(event->comm.pid);
|
struct thread *thread = threads__findnew(event->comm.pid);
|
||||||
|
|
||||||
|
if (dump_trace) {
|
||||||
|
fprintf(stderr, "PERF_EVENT_COMM: %s:%d\n",
|
||||||
|
event->comm.comm, event->comm.pid);
|
||||||
|
}
|
||||||
if (thread == NULL ||
|
if (thread == NULL ||
|
||||||
thread__set_comm(thread, event->comm.comm)) {
|
thread__set_comm(thread, event->comm.comm)) {
|
||||||
fprintf(stderr, "problem processing PERF_EVENT_COMM, bailing out\n");
|
fprintf(stderr, "problem processing PERF_EVENT_COMM, bailing out\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
total_comm++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
fprintf(stderr, "skipping unknown header type: %d\n",
|
||||||
|
event->header.type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset + head < stat.st_size)
|
if (offset + head < stat.st_size)
|
||||||
|
@ -768,6 +794,15 @@ more:
|
||||||
rc = EXIT_SUCCESS;
|
rc = EXIT_SUCCESS;
|
||||||
done:
|
done:
|
||||||
close(input);
|
close(input);
|
||||||
|
|
||||||
|
if (dump_trace) {
|
||||||
|
fprintf(stderr, " IP events: %10ld\n", total);
|
||||||
|
fprintf(stderr, " mmap events: %10ld\n", total_mmap);
|
||||||
|
fprintf(stderr, " comm events: %10ld\n", total_comm);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//dsos__fprintf(stdout);
|
//dsos__fprintf(stdout);
|
||||||
threads__fprintf(stdout);
|
threads__fprintf(stdout);
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -796,6 +831,8 @@ static const char * const report_usage[] = {
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
OPT_STRING('i', "input", &input_name, "file",
|
OPT_STRING('i', "input", &input_name, "file",
|
||||||
"input file name"),
|
"input file name"),
|
||||||
|
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
|
||||||
|
"dump raw trace in ASCII"),
|
||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue