Skip to content

Commit ce569bd

Browse files
committed
update README with new workings and add license header everywhere
1 parent 08a35fe commit ce569bd

5 files changed

+68
-8
lines changed

AttachOnce.java

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* libperfmap: a JVM agent to create perf-<pid>.map files for consumption
3+
* with linux perf-tools
4+
* Copyright (C) 2013 Johannes Rudolph<[email protected]>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program; if not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*/
20+
121
package net.virtualvoid.perf;
222

323
import java.io.File;

README.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A java agent to generate /tmp/perf-<pid>.map files for JITted methods for use with `perf`
1+
A java agent to generate `/tmp/perf-<pid>.map` files for JITted methods for use with `perf`.
22

33
## Build
44

@@ -7,16 +7,15 @@ A java agent to generate /tmp/perf-<pid>.map files for JITted methods for use wi
77

88
## Use
99

10-
Add `-agentpath:<dir>/libperfmap.so` to the java command line.
10+
Use `./perf-java <pid> <options>` to create a `perf-<pid>.map` file for the current state of the JVM and
11+
run `perf top -p <pid>` for this process afterwards. `perf-java` expects `libperfmap.so` in the current directory.
12+
13+
Over time the JVM will JIT compile more methods and the `perf-<pid>.map` file will become stale. You need to
14+
rerun `perf-java` to generate a new and current map.
1115

1216
Note: If `perf top` still doesn't show any detailled info it's probably because of a permission problem. A common solution is
1317
to run the java program as a regular user with the agent enabled and then run a `chown root /tmp/perf-<pid>.map` to make
14-
the file accessible for the root user. Then run `perf top` as root. You could use the following script to do that:
15-
16-
```sh
17-
sudo chown root /tmp/perf-$1.map
18-
sudo perf top
19-
```
18+
the file accessible for the root user. Then run `perf top` as root. The `perf-java` script tries to do that.
2019

2120
## Disclaimer
2221

perf-map-agent.c

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* with this program; if not, write to the Free Software Foundation, Inc.,
1818
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1919
*/
20+
2021
#include <stdio.h>
2122

2223
#include <sys/types.h>

perf-map-file.c

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* libperfmap: a JVM agent to create perf-<pid>.map files for consumption
3+
* with linux perf-tools
4+
* Copyright (C) 2013 Johannes Rudolph<[email protected]>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program; if not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*/
20+
121
#include <sys/types.h>
222
#include <stdio.h>
323

perf-map-file.h

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/*
2+
* libperfmap: a JVM agent to create perf-<pid>.map files for consumption
3+
* with linux perf-tools
4+
* Copyright (C) 2013 Johannes Rudolph<[email protected]>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License along
17+
* with this program; if not, write to the Free Software Foundation, Inc.,
18+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*/
20+
121
FILE *perf_map_open(pid_t pid);
222
void perf_map_write_entry(FILE *method_file, const void* code_addr, unsigned int code_size, const char* entry);
323

0 commit comments

Comments
 (0)