-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tool to attach at runtime the agent
OpenJDK based, depends on: - JAVA_HOME set to a JDK instalation - OpenJDK tools.jar available locally for compilation
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
AGENT_PATH=`ls -1 $DIR/target/jvm-profiler-*.jar` | ||
echo $AGENT_PATH | ||
|
||
java -cp $AGENT_PATH:$JAVA_HOME/lib/tools.jar com.uber.profiling.tools.AttachClient $AGENT_PATH $* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.uber.profiling.tools; | ||
|
||
import com.sun.tools.attach.VirtualMachine; | ||
|
||
public class AttachClient { | ||
|
||
public static void main(String[] args) throws Exception { | ||
if (args.length != 3) { | ||
System.out.println("Usage: com.uber.profiling.tools.AttachClient <agent_jar_full_path> <agent_args> <vm_pid>"); | ||
return; | ||
} | ||
String agent_path = args[0]; | ||
String agent_args = args[1]; | ||
String pid = args[2]; | ||
VirtualMachine vm = VirtualMachine.attach(pid); | ||
System.out.println("vm = " + vm); | ||
vm.loadAgent(agent_path, agent_args); | ||
vm.detach(); | ||
} | ||
} |