Skip to content

Commit

Permalink
Merge origin/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik committed Nov 11, 2018
2 parents 587730f + fbbeafd commit 6587225
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ questions.
<dependency>
<groupId>com.sun.tools.btrace</groupId>
<artifactId>btrace-agent</artifactId>
<version>1.3.11</version>
<version>1.3.11.1</version>
</dependency>
<dependency>
<groupId>com.sun.tools.btrace</groupId>
Expand Down
15 changes: 13 additions & 2 deletions src/share/classes/com/sun/btrace/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,18 @@ public void attach(String pid, String agentPath, String sysCp, String bootCp) th
* to the command listener provided.
*/
public void submit(String fileName, byte[] code, String[] args,
CommandListener listener) throws IOException {
CommandListener listener) throws IOException {
submit("localhost", fileName,code, args, listener);
}

/**
* Submits the compiled BTrace .class to the VM
* attached and passes given command line arguments.
* Receives commands from the traced JVM and sends those
* to the command listener provided.
*/
public void submit(String host, String fileName, byte[] code, String[] args,
CommandListener listener) throws IOException {
if (sock != null) {
throw new IllegalStateException();
}
Expand All @@ -360,7 +371,7 @@ public void submit(String fileName, byte[] code, String[] args,
long timeout = System.currentTimeMillis() + 5000;
while (sock == null && System.currentTimeMillis() <= timeout) {
try {
sock = new Socket("localhost", port);
sock = new Socket(host, port);
} catch (ConnectException e) {
if (debug) {
debugPrint("server not yet available; retrying ...");
Expand Down
14 changes: 10 additions & 4 deletions src/share/classes/com/sun/btrace/client/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ public final class Main {
public static volatile boolean exiting;
private static boolean DEBUG;
private static boolean TRUSTED;
private static boolean DUMP_CLASSES;
private static boolean DUMP_CLASSES;
private static String OUTPUT_FILE;
private static String DUMP_DIR;
private static String PROBE_DESC_PATH;
public static final boolean TRACK_RETRANSFORM;
public static final int BTRACE_DEFAULT_PORT = 2020;
public static final String BTRACE_DEFAULT_HOST = "localhost";

private static final Console con;
private static final PrintWriter out;
Expand Down Expand Up @@ -84,10 +85,12 @@ private static PrintWriter getOutWriter(Console con) {

public static void main(String[] args) {
int port = BTRACE_DEFAULT_PORT;
String host = BTRACE_DEFAULT_HOST;
String classPath = ".";
String includePath = null;

int count = 0;
boolean hostDefined = false;
boolean portDefined = false;
boolean classpathDefined = false;
boolean includePathDefined = false;
Expand Down Expand Up @@ -149,6 +152,9 @@ public static void main(String[] args) {
statsdDef = args[++count];
} else if (args[count].equals("-v")) {
// already processed
} else if (args[count].equals("-host") && !hostDefined) {
host = args[++count];
hostDefined = true;
} else {
usage();
}
Expand Down Expand Up @@ -190,14 +196,14 @@ public static void main(String[] args) {
if (code == null) {
errorExit("BTrace compilation failed", 1);
}
client.attach(pid, null, classPath);
if (!hostDefined)
client.attach(pid, null, classPath);
registerExitHook(client);
if (con != null) {
registerSignalHandler(client);
}
if (isDebug()) debugPrint("submitting the BTrace program");
client.submit(fileName, code, btraceArgs,
createCommandListener(client));
client.submit(host, fileName, code, btraceArgs, createCommandListener(client));
} catch (IOException exp) {
errorExit(exp.getMessage(), 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ btrace.usage =\
-cp <path> Specify where to find user class files and annotation processors\n \
-I <path> Specify where to find include files\n \
-p <port> Specify port to which the btrace agent listens for clients\n \
-host <host> Specify host to which btrace client's socket connect \n \
-statsd <host[:port]> Specify the statsd server, if any

btrace.agent.usage =\
Expand Down

0 comments on commit 6587225

Please sign in to comment.