Mercurial > hg > graal-compiler
diff agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java @ 11054:38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
Reviewed-by: sla, dsamersoff
author | kevinw |
---|---|
date | Wed, 26 Jun 2013 00:01:20 +0100 |
parents | 5ed317b25e23 |
children | 7fe6ef09d242 |
line wrap: on
line diff
--- a/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java Tue Jun 25 14:11:57 2013 +0200 +++ b/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java Wed Jun 26 00:01:20 2013 +0100 @@ -35,6 +35,7 @@ public abstract class Tool implements Runnable { private HotSpotAgent agent; + private JVMDebugger jvmDebugger; private int debugeeType; // debugeeType is one of constants below @@ -42,6 +43,13 @@ protected static final int DEBUGEE_CORE = 1; protected static final int DEBUGEE_REMOTE = 2; + public Tool() { + } + + public Tool(JVMDebugger d) { + jvmDebugger = d; + } + public String getName() { return getClass().getName(); } @@ -90,7 +98,6 @@ protected void usage() { printUsage(); - System.exit(1); } /* @@ -106,13 +113,13 @@ protected void stop() { if (agent != null) { agent.detach(); - System.exit(0); } } protected void start(String[] args) { if ((args.length < 1) || (args.length > 2)) { usage(); + return; } // Attempt to handle -h or -help or some invalid flag @@ -185,13 +192,31 @@ } if (e.getMessage() != null) { err.print(e.getMessage()); + e.printStackTrace(); } err.println(); - System.exit(1); + return; } err.println("Debugger attached successfully."); + startInternal(); + } + // When using an existing JVMDebugger. + public void start() { + + if (jvmDebugger == null) { + throw new RuntimeException("Tool.start() called with no JVMDebugger set."); + } + agent = new HotSpotAgent(); + agent.attach(jvmDebugger); + startInternal(); + } + + // Remains of the start mechanism, common to both start methods. + private void startInternal() { + + PrintStream err = System.err; VM vm = VM.getVM(); if (vm.isCore()) { err.println("Core build detected.");