test/com/sun/jdi/RunToExit.java

Print this page


   1 /*
   2  * Copyright (c) 2004, 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  */


  96     /*
  97      * Find a connector by name
  98      */
  99     private static Connector findConnector(String name) {
 100         List connectors = Bootstrap.virtualMachineManager().allConnectors();
 101         Iterator iter = connectors.iterator();
 102         while (iter.hasNext()) {
 103             Connector connector = (Connector)iter.next();
 104             if (connector.name().equals(name)) {
 105                 return connector;
 106             }
 107         }
 108         return null;
 109     }
 110 
 111     /*
 112      * Launch a server debuggee with the given address
 113      */
 114     private static Process launch(String address, String class_name) throws IOException {
 115         String exe =   System.getProperty("java.home")
 116                      + File.separator + "bin" + File.separator;
 117         String arch = System.getProperty("os.arch");
 118         String osname = System.getProperty("os.name");
 119         if (osname.equals("SunOS") && arch.equals("sparcv9")) {
 120             exe += "sparcv9/java";
 121         } else if (osname.equals("SunOS") && arch.equals("amd64")) {
 122             exe += "amd64/java";
 123         } else {
 124             exe += "java";
 125         }
 126         String cmd = exe + " " + VMConnection.getDebuggeeVMOptions() +
 127             " -agentlib:jdwp=transport=dt_socket" +
 128             ",server=y" + ",suspend=y" + ",address=" + address +
 129             " " + class_name;
 130 
 131         System.out.println("Starting: " + cmd);
 132 
 133         Process p = Runtime.getRuntime().exec(cmd);
 134 
 135         IOHandler.handle("Input Stream", p.getInputStream());
 136         IOHandler.handle("Error Stream", p.getErrorStream());
 137 
 138         return p;
 139     }
 140 
 141     /*
 142      * - pick a TCP port
 143      * - Launch a server debuggee: server=y,suspend=y,address=${port}
 144      * - run it to VM death
 145      * - verify we saw no error


   1 /*
   2  * Copyright (c) 2004, 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  */


  96     /*
  97      * Find a connector by name
  98      */
  99     private static Connector findConnector(String name) {
 100         List connectors = Bootstrap.virtualMachineManager().allConnectors();
 101         Iterator iter = connectors.iterator();
 102         while (iter.hasNext()) {
 103             Connector connector = (Connector)iter.next();
 104             if (connector.name().equals(name)) {
 105                 return connector;
 106             }
 107         }
 108         return null;
 109     }
 110 
 111     /*
 112      * Launch a server debuggee with the given address
 113      */
 114     private static Process launch(String address, String class_name) throws IOException {
 115         String exe =   System.getProperty("java.home")
 116                      + File.separator + "bin" + File.separator + "java";









 117         String cmd = exe + " " + VMConnection.getDebuggeeVMOptions() +
 118             " -agentlib:jdwp=transport=dt_socket" +
 119             ",server=y" + ",suspend=y" + ",address=" + address +
 120             " " + class_name;
 121 
 122         System.out.println("Starting: " + cmd);
 123 
 124         Process p = Runtime.getRuntime().exec(cmd);
 125 
 126         IOHandler.handle("Input Stream", p.getInputStream());
 127         IOHandler.handle("Error Stream", p.getErrorStream());
 128 
 129         return p;
 130     }
 131 
 132     /*
 133      * - pick a TCP port
 134      * - Launch a server debuggee: server=y,suspend=y,address=${port}
 135      * - run it to VM death
 136      * - verify we saw no error