Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 339025
b: refs/heads/master
c: 6064803
h: refs/heads/master
i:
  339023: fe72095
v: v3
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Nov 14, 2012
1 parent bce02ba commit 8bb56b1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 44 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: 0020ce23864d16f66e5667013b8b43d1df3e142e
refs/heads/master: 6064803313bad9ae4cae233a9d56678adb2b6e7c
74 changes: 31 additions & 43 deletions trunk/tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,55 +193,43 @@ static int perf_event__synthesize_mmap_events(struct perf_tool *tool,
event->header.misc = PERF_RECORD_MISC_USER;

while (1) {
char bf[BUFSIZ], *pbf = bf;
int n;
char bf[BUFSIZ];
char prot[5];
char execname[PATH_MAX];
char anonstr[] = "//anon";
size_t size;

if (fgets(bf, sizeof(bf), fp) == NULL)
break;

/* ensure null termination since stack will be reused. */
strcpy(execname, "");

/* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */
n = hex2u64(pbf, &event->mmap.start);
if (n < 0)
continue;
pbf += n + 1;
n = hex2u64(pbf, &event->mmap.len);
if (n < 0)
sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %*x:%*x %*u %s\n",
&event->mmap.start, &event->mmap.len, prot,
&event->mmap.pgoff, execname);

if (prot[2] != 'x')
continue;
pbf += n + 3;
if (*pbf == 'x') { /* vm_exec */
char anonstr[] = "//anon\n";
char *execname = strchr(bf, '/');

/* Catch VDSO */
if (execname == NULL)
execname = strstr(bf, "[vdso]");

/* Catch anonymous mmaps */
if ((execname == NULL) && !strstr(bf, "["))
execname = anonstr;

if (execname == NULL)
continue;

pbf += 3;
n = hex2u64(pbf, &event->mmap.pgoff);

size = strlen(execname);
execname[size - 1] = '\0'; /* Remove \n */
memcpy(event->mmap.filename, execname, size);
size = PERF_ALIGN(size, sizeof(u64));
event->mmap.len -= event->mmap.start;
event->mmap.header.size = (sizeof(event->mmap) -
(sizeof(event->mmap.filename) - size));
memset(event->mmap.filename + size, 0, machine->id_hdr_size);
event->mmap.header.size += machine->id_hdr_size;
event->mmap.pid = tgid;
event->mmap.tid = pid;

if (process(tool, event, &synth_sample, machine) != 0) {
rc = -1;
break;
}

if (!strcmp(execname, ""))
strcpy(execname, anonstr);

size = strlen(execname) + 1;
memcpy(event->mmap.filename, execname, size);
size = PERF_ALIGN(size, sizeof(u64));
event->mmap.len -= event->mmap.start;
event->mmap.header.size = (sizeof(event->mmap) -
(sizeof(event->mmap.filename) - size));
memset(event->mmap.filename + size, 0, machine->id_hdr_size);
event->mmap.header.size += machine->id_hdr_size;
event->mmap.pid = tgid;
event->mmap.tid = pid;

if (process(tool, event, &synth_sample, machine) != 0) {
rc = -1;
break;
}
}

Expand Down

0 comments on commit 8bb56b1

Please sign in to comment.