1 /*
2 * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
80 * Find a connector by name
81 */
82 private static Connector findConnector(String name) {
83 List connectors = Bootstrap.virtualMachineManager().allConnectors();
84 Iterator iter = connectors.iterator();
85 while (iter.hasNext()) {
86 Connector connector = (Connector)iter.next();
87 if (connector.name().equals(name)) {
88 return connector;
89 }
90 }
91 return null;
92 }
93
94 /*
95 * Launch (in server mode) a debuggee with the given address and
96 * suspend mode.
97 */
98 private static Process launch(String address, boolean suspend, String class_name) throws IOException {
99 String exe = System.getProperty("java.home") + File.separator + "bin" +
100 File.separator;
101 String arch = System.getProperty("os.arch");
102 String osname = System.getProperty("os.name");
103 if (osname.equals("SunOS") && arch.equals("sparcv9")) {
104 exe += "sparcv9/java";
105 } else if (osname.equals("SunOS") && arch.equals("amd64")) {
106 exe += "amd64/java";
107 } else {
108 exe += "java";
109 }
110 String cmd = exe + " " + VMConnection.getDebuggeeVMOptions() +
111 " -agentlib:jdwp=transport=dt_socket,server=y,suspend=";
112 if (suspend) {
113 cmd += "y";
114 } else {
115 cmd += "n";
116 }
117 cmd += ",address=" + address + " " + class_name;
118
119 System.out.println("Starting: " + cmd);
120
121 Process p = Runtime.getRuntime().exec(cmd);
122 IOHandler.handle(p.getInputStream());
123 IOHandler.handle(p.getErrorStream());
124
125 return p;
126 }
127
128 /*
129 * - pick a TCP port
|
1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
80 * Find a connector by name
81 */
82 private static Connector findConnector(String name) {
83 List connectors = Bootstrap.virtualMachineManager().allConnectors();
84 Iterator iter = connectors.iterator();
85 while (iter.hasNext()) {
86 Connector connector = (Connector)iter.next();
87 if (connector.name().equals(name)) {
88 return connector;
89 }
90 }
91 return null;
92 }
93
94 /*
95 * Launch (in server mode) a debuggee with the given address and
96 * suspend mode.
97 */
98 private static Process launch(String address, boolean suspend, String class_name) throws IOException {
99 String exe = System.getProperty("java.home") + File.separator + "bin" +
100 File.separator + "java";
101 String cmd = exe + " " + VMConnection.getDebuggeeVMOptions() +
102 " -agentlib:jdwp=transport=dt_socket,server=y,suspend=";
103 if (suspend) {
104 cmd += "y";
105 } else {
106 cmd += "n";
107 }
108 cmd += ",address=" + address + " " + class_name;
109
110 System.out.println("Starting: " + cmd);
111
112 Process p = Runtime.getRuntime().exec(cmd);
113 IOHandler.handle(p.getInputStream());
114 IOHandler.handle(p.getErrorStream());
115
116 return p;
117 }
118
119 /*
120 * - pick a TCP port
|