| 1 |
# chainagent |
| 2 |
|
| 3 |
The chainagents agent is a JVMTI agent that chain loads other agents from a file found at a |
| 4 |
location relative to a passed in path. It can be used in combination with android startup_agents |
| 5 |
in order to implement more complicated agent-loading rules. |
| 6 |
|
| 7 |
It will open the file `chain_agents.txt` from the directory passed in as an argument and read it |
| 8 |
line-by-line loading the agents (with the arguments) listed in the file. |
| 9 |
|
| 10 |
Errors in loading are logged then ignored. |
| 11 |
|
| 12 |
# Usage |
| 13 |
### Build |
| 14 |
> `m libchainagents` |
| 15 |
|
| 16 |
The libraries will be built for 32-bit, 64-bit, host and target. Below examples |
| 17 |
assume you want to use the 64-bit version. |
| 18 |
|
| 19 |
### Command Line |
| 20 |
#### ART |
| 21 |
> `art -Xplugin:$ANDROID_HOST_OUT/lib64/libopenjdkjvmti.so -agentpath:$ANDROID_HOST_OUT/lib64/libchainagents.so=/some/path/here -Xint helloworld` |
| 22 |
|
| 23 |
* `-Xplugin` and `-agentpath` need to be used, otherwise libtitrace agent will fail during init. |
| 24 |
* If using `libartd.so`, make sure to use the debug version of jvmti. |
| 25 |
|
| 26 |
### chain_agents.txt file format. |
| 27 |
|
| 28 |
The chain-agents file is a list of agent files and arguments to load in the same format as the |
| 29 |
`-agentpath` argument. |
| 30 |
|
| 31 |
#### Example chain_agents.txt file |
| 32 |
|
| 33 |
``` |
| 34 |
/data/data/com.android.launcher3/code_cache/libtifast32.so=ClassLoad |
| 35 |
/data/data/com.android.launcher3/code_cache/libtifast64.so=ClassLoad |
| 36 |
``` |