1 /*
   2  * Copyright (c) 2016, 2018, 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  */
  23 
  24 
  25 /*
  26  * @test
  27  *
  28  * @summary converted from VM Testbase vm/mlvm/indy/stress/jdi/breakpointInCompiledCode.
  29  * VM Testbase keywords: [feature_mlvm, nonconcurrent, fds, jdk]
  30  * VM Testbase readme:
  31  * DESCRIPTION
  32  *     Execute an invokedynamic instruction 10000 times to trigger Hotspot compilation. Set a debugger breakpoint to invokedynamic instruction.
  33  *     Make few debugger steps, obtaining various information from JVM
  34  *
  35  * @library /vmTestbase
  36  *          /test/lib
  37  * @run driver jdk.test.lib.FileInstaller . .
  38  *
  39  * @comment build debuggee class
  40  * @build vm.mlvm.share.jdi.IndyDebuggee
  41  *
  42  * @comment build test class and indify classes
  43  * @build vm.mlvm.indy.stress.jdi.breakpointInCompiledCode.Test
  44  * @run driver vm.mlvm.share.IndifiedClassesBuilder
  45  *
  46  * @run main/othervm PropertyResolvingWrapper
  47  *      vm.mlvm.indy.stress.jdi.breakpointInCompiledCode.Test
  48  *      -verbose
  49  *      -arch=${os.family}-${os.simpleArch}
  50  *      -waittime=5
  51  *      -debugee.vmkind=java
  52  *      -transport.address=dynamic
  53  *      -debugger.debuggeeClass vm.mlvm.share.jdi.IndyDebuggee
  54  *      -debuggee.iterations 20000
  55  *      -debugee.vmkeys="${test.vm.opts} ${test.java.opts}"
  56  */
  57 
  58 package vm.mlvm.indy.stress.jdi.breakpointInCompiledCode;
  59 
  60 import vm.mlvm.share.jdi.ArgumentHandler;
  61 import vm.mlvm.share.jdi.BreakpointInfo;
  62 import vm.mlvm.share.jdi.JDIBreakpointTest;
  63 
  64 import java.util.ArrayList;
  65 import java.util.List;
  66 
  67 public class Test extends JDIBreakpointTest {
  68     //  bootstrap,runDebuggee=>(indyWrapper:S5000,~target,stop)
  69     @Override
  70     protected List<BreakpointInfo> getBreakpoints(String debuggeeClassName)  {
  71         List<BreakpointInfo> result = new ArrayList<>();
  72         result.add(new BreakpointInfo("bootstrap"));
  73         {
  74             BreakpointInfo info = new BreakpointInfo("runDebuggee");
  75             // =>(indyWrapper:S5000,~target,stop)
  76             List<BreakpointInfo> subBreakpoints = new ArrayList<>();
  77             {
  78                 BreakpointInfo sub = new BreakpointInfo("indyWrapper", true);
  79                 sub.stepsToTrace = 5000;
  80                 subBreakpoints.add(sub);
  81             }
  82             {
  83                 BreakpointInfo sub = new BreakpointInfo("target", true);
  84                 sub.type = BreakpointInfo.Type.IMPLICIT;
  85                 subBreakpoints.add(sub);
  86             }
  87             subBreakpoints.add(new BreakpointInfo("stop", true));
  88 
  89             info.subBreakpoints = subBreakpoints;
  90             result.add(info);
  91         }
  92         return result;
  93     }
  94 
  95     public static void main(String[] args) {
  96         launch(new ArgumentHandler(args));
  97     }
  98 }