< prev index next >

test/com/sun/jdi/PopAndStepTest.java

Print this page
rev 11832 : 8078896: Add @modules as needed to the jdk_svc tests
Reviewed-by: alanb, mchung
   1 /* /nodynamiccopyright/ */  // DO NOT DELETE ANY LINES!!!!
   2 //    THIS TEST IS LINE NUMBER SENSITIVE
   3 /**
   4  *  @test
   5  *  @bug 4530424
   6  *  @summary Hin says that doing a step over after a popframe acts like a resume.
   7  *
   8  *  @author jjh
   9  *
  10  *  @library ..

  11  *  @run build TestScaffold VMConnection TargetListener TargetAdapter
  12  *  @run compile -g PopAndStepTest.java
  13  *  @run driver PopAndStepTest
  14  */
  15 import com.sun.jdi.*;
  16 import com.sun.jdi.event.*;
  17 import com.sun.jdi.request.*;
  18 
  19 import java.util.*;
  20 
  21     /********** LINE NUMBER SENSITIVE! *****************************************************************/
  22 
  23 class PopAndStepTarg {
  24     public void B() {
  25         System.out.println("debuggee: in B");
  26         System.out.println("debuggee: in B, back to A");   // add line breakpoint here line 26 !!!
  27     }
  28 
  29     public void A() {
  30         System.out.println("debuggee: in A, about to call B");  // line 30
  31         B();
  32         System.out.println("debuggee: in A, back from B");      // line 32
  33         throw new RuntimeException("debuggee: Got to line 33");
  34     }
  35 
  36     public static void main(String[] args) {
  37         System.out.println("debuggee: Howdy!");      // line 37
  38         PopAndStepTarg xxx = new PopAndStepTarg();   // line 39
  39         xxx.A();                                     // line 40
  40         System.out.println("debugee: Goodbye from PopAndStepTarg!");
  41     }
  42 }
  43 
  44 
  45     /********** test program **********/
  46 
  47 public class PopAndStepTest extends TestScaffold {
  48     ReferenceType targetClass;
  49     ThreadReference mainThread;
  50 
  51     PopAndStepTest (String args[]) {
  52         super(args);
  53     }
  54 
  55     public static void main(String[] args)      throws Exception {
  56         new PopAndStepTest(args).startTests();
  57     }
  58 
  59 


  98     }
  99 
 100     /********** test core **********/
 101 
 102     protected void runTests() throws Exception {
 103         /*
 104          * Get to the top of main()
 105          * to determine targetClass and mainThread
 106          */
 107         runOnce();
 108     }
 109 
 110     void runOnce() throws Exception{
 111         /*
 112          * Get to the top of main()
 113          * to determine targetClass and mainThread
 114          */
 115         BreakpointEvent bpe = startToMain("PopAndStepTarg");
 116         targetClass = bpe.location().declaringType();
 117         mainThread = bpe.thread();
 118         getDebuggeeLineNum(37);
 119 
 120         println("Resuming to line 26");
 121         bpe = resumeTo("PopAndStepTarg", 26); getDebuggeeLineNum(26);
 122 
 123         // The failure is this:
 124         //   create step request
 125         //   enable step request
 126         //   pop frame
 127         //   do the step
 128         //   do another step - This step runs to completion
 129         EventRequestManager erm = eventRequestManager();
 130         StepRequest srInto = erm.createStepRequest(mainThread, StepRequest.STEP_LINE,
 131                                                    StepRequest.STEP_INTO);
 132         srInto.addClassExclusionFilter("java.*");
 133         srInto.addClassExclusionFilter("javax.*");
 134         srInto.addClassExclusionFilter("sun.*");
 135         srInto.addClassExclusionFilter("com.sun.*");
 136         srInto.addClassExclusionFilter("com.oracle.*");
 137         srInto.addClassExclusionFilter("oracle.*");
 138         srInto.addClassExclusionFilter("jdk.internal.*");
 139         srInto.addCountFilter(1);
 140         srInto.enable(); // This fails
 141         mainThread.popFrames(frameFor("A"));
 142         //srInto.enable();   // if the enable is moved here, it passes
 143         println("Popped back to line 40 in main, the call to A()");
 144         println("Stepping into line 30");
 145         waitForRequestedEvent(srInto);   // println
 146         srInto.disable();
 147 
 148         getDebuggeeLineNum(30);
 149 
 150         // The failure occurs here.
 151         println("Stepping over to line 31");
 152         stepOverLine(mainThread);   // println
 153         getDebuggeeLineNum(31);
 154 
 155         println("Stepping over to line 32");
 156         stepOverLine(mainThread);        // call to B()
 157         getDebuggeeLineNum(32);
 158 
 159         vm().exit(0);
 160 
 161         if (testFailed) {
 162             throw new Exception("PopAndStepTest failed");
 163         }
 164         println("Passed:");
 165     }
 166 }
   1 /* /nodynamiccopyright/ */  // DO NOT DELETE ANY LINES!!!!
   2 //    THIS TEST IS LINE NUMBER SENSITIVE
   3 /**
   4  *  @test
   5  *  @bug 4530424
   6  *  @summary Hin says that doing a step over after a popframe acts like a resume.
   7  *
   8  *  @author jjh
   9  *
  10  *  @library ..
  11  *  @modules jdk.jdi
  12  *  @run build TestScaffold VMConnection TargetListener TargetAdapter
  13  *  @run compile -g PopAndStepTest.java
  14  *  @run driver PopAndStepTest
  15  */
  16 import com.sun.jdi.*;
  17 import com.sun.jdi.event.*;
  18 import com.sun.jdi.request.*;
  19 
  20 import java.util.*;
  21 
  22     /********** LINE NUMBER SENSITIVE! *****************************************************************/
  23 
  24 class PopAndStepTarg {
  25     public void B() {
  26         System.out.println("debuggee: in B");
  27         System.out.println("debuggee: in B, back to A");   // add line breakpoint here line 27 !!!
  28     }
  29 
  30     public void A() {
  31         System.out.println("debuggee: in A, about to call B");  // line 31
  32         B();
  33         System.out.println("debuggee: in A, back from B");      // line 33
  34         throw new RuntimeException("debuggee: Got to line 34");
  35     }
  36 
  37     public static void main(String[] args) {
  38         System.out.println("debuggee: Howdy!");      // line 38
  39         PopAndStepTarg xxx = new PopAndStepTarg();   // line 40
  40         xxx.A();                                     // line 41
  41         System.out.println("debugee: Goodbye from PopAndStepTarg!");
  42     }
  43 }
  44 
  45 
  46     /********** test program **********/
  47 
  48 public class PopAndStepTest extends TestScaffold {
  49     ReferenceType targetClass;
  50     ThreadReference mainThread;
  51 
  52     PopAndStepTest (String args[]) {
  53         super(args);
  54     }
  55 
  56     public static void main(String[] args)      throws Exception {
  57         new PopAndStepTest(args).startTests();
  58     }
  59 
  60 


  99     }
 100 
 101     /********** test core **********/
 102 
 103     protected void runTests() throws Exception {
 104         /*
 105          * Get to the top of main()
 106          * to determine targetClass and mainThread
 107          */
 108         runOnce();
 109     }
 110 
 111     void runOnce() throws Exception{
 112         /*
 113          * Get to the top of main()
 114          * to determine targetClass and mainThread
 115          */
 116         BreakpointEvent bpe = startToMain("PopAndStepTarg");
 117         targetClass = bpe.location().declaringType();
 118         mainThread = bpe.thread();
 119         getDebuggeeLineNum(38);
 120 
 121         println("Resuming to line 27");
 122         bpe = resumeTo("PopAndStepTarg", 27); getDebuggeeLineNum(27);
 123 
 124         // The failure is this:
 125         //   create step request
 126         //   enable step request
 127         //   pop frame
 128         //   do the step
 129         //   do another step - This step runs to completion
 130         EventRequestManager erm = eventRequestManager();
 131         StepRequest srInto = erm.createStepRequest(mainThread, StepRequest.STEP_LINE,
 132                                                    StepRequest.STEP_INTO);
 133         srInto.addClassExclusionFilter("java.*");
 134         srInto.addClassExclusionFilter("javax.*");
 135         srInto.addClassExclusionFilter("sun.*");
 136         srInto.addClassExclusionFilter("com.sun.*");
 137         srInto.addClassExclusionFilter("com.oracle.*");
 138         srInto.addClassExclusionFilter("oracle.*");
 139         srInto.addClassExclusionFilter("jdk.internal.*");
 140         srInto.addCountFilter(1);
 141         srInto.enable(); // This fails
 142         mainThread.popFrames(frameFor("A"));
 143         //srInto.enable();   // if the enable is moved here, it passes
 144         println("Popped back to line 41 in main, the call to A()");
 145         println("Stepping into line 31");
 146         waitForRequestedEvent(srInto);   // println
 147         srInto.disable();
 148 
 149         getDebuggeeLineNum(31);
 150 
 151         // The failure occurs here.
 152         println("Stepping over to line 32");
 153         stepOverLine(mainThread);   // println
 154         getDebuggeeLineNum(32);
 155 
 156         println("Stepping over to line 33");
 157         stepOverLine(mainThread);        // call to B()
 158         getDebuggeeLineNum(33);
 159 
 160         vm().exit(0);
 161 
 162         if (testFailed) {
 163             throw new Exception("PopAndStepTest failed");
 164         }
 165         println("Passed:");
 166     }
 167 }
< prev index next >