Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147533
b: refs/heads/master
c: 97b07b6
h: refs/heads/master
i:
  147531: e13139e
v: v3
  • Loading branch information
Ingo Molnar committed May 26, 2009
1 parent d2ccea2 commit 164f394
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: abd54f68629fa73ed4fa040d433196211a9bbed2
refs/heads/master: 97b07b699b11d4bd1218a841e5dfed16bd53de06
39 changes: 38 additions & 1 deletion trunk/Documentation/perf_counter/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ static char const *input_name = "output.perf";
static int input;
static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;

static int dump_trace = 0;

static unsigned long page_size;
static unsigned long mmap_window = 32;

Expand Down Expand Up @@ -643,7 +645,7 @@ static int __cmd_report(void)
char *buf;
event_t *event;
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);
if (input < 0) {
Expand Down Expand Up @@ -706,6 +708,13 @@ static int __cmd_report(void)
struct thread *thread = threads__findnew(event->ip.pid);
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) {
fprintf(stderr, "problem processing %d event, bailing out\n",
event->header.type);
Expand Down Expand Up @@ -743,23 +752,40 @@ static int __cmd_report(void)
struct thread *thread = threads__findnew(event->mmap.pid);
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) {
fprintf(stderr, "problem processing PERF_EVENT_MMAP, bailing out\n");
goto done;
}
thread__insert_map(thread, map);
total_mmap++;
break;
}
case PERF_EVENT_COMM: {
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 ||
thread__set_comm(thread, event->comm.comm)) {
fprintf(stderr, "problem processing PERF_EVENT_COMM, bailing out\n");
goto done;
}
total_comm++;
break;
}
default: {
fprintf(stderr, "skipping unknown header type: %d\n",
event->header.type);
}
}

if (offset + head < stat.st_size)
Expand All @@ -768,6 +794,15 @@ static int __cmd_report(void)
rc = EXIT_SUCCESS;
done:
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);
threads__fprintf(stdout);
#if 0
Expand Down Expand Up @@ -796,6 +831,8 @@ static const char * const report_usage[] = {
static const struct option options[] = {
OPT_STRING('i', "input", &input_name, "file",
"input file name"),
OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
"dump raw trace in ASCII"),
OPT_END()
};

Expand Down

0 comments on commit 164f394

Please sign in to comment.