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