1 /*
2  * Copyright (c) 2002, 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 package nsk.jdi.EventSet.toString;
24 
25 import nsk.share.*;
26 import nsk.share.jpda.*;
27 import nsk.share.jdi.*;
28 
29 //    THIS TEST IS LINE NUMBER SENSITIVE
30 
31 /**
32  * The debugged application of the test.
33  */
34 public class tostring001a {
35 
36     //------------------------------------------------------- immutable common fields
37 
38     private static int exitStatus;
39     private static ArgumentHandler argHandler;
40     private static Log log;
41     private static IOPipe pipe;
42 
43     //------------------------------------------------------- immutable common methods
44 
display(String msg)45     static void display(String msg) {
46         log.display("debuggee > " + msg);
47     }
48 
complain(String msg)49     static void complain(String msg) {
50         log.complain("debuggee FAILURE > " + msg);
51     }
52 
receiveSignal(String signal)53     public static void receiveSignal(String signal) {
54         String line = pipe.readln();
55 
56         if ( !line.equals(signal) )
57             throw new Failure("UNEXPECTED debugger's signal " + line);
58 
59         display("debuger's <" + signal + "> signal received.");
60     }
61 
62     //------------------------------------------------------ mutable common fields
63 
64     //------------------------------------------------------ test specific fields
65 
66     public final static String brkpMethodName = "breakHere";
67     public final static int brkpLineNumber = 91;
68 
69     //------------------------------------------------------ mutable common method
70 
main(String argv[])71     public static void main (String argv[]) {
72         exitStatus = Consts.TEST_FAILED;
73         argHandler = new ArgumentHandler(argv);
74         log = new Log(System.err, argHandler);
75         pipe = argHandler.createDebugeeIOPipe(log);
76         try {
77             pipe.println(tostring001.SIGNAL_READY);
78             breakHere();
79             receiveSignal(tostring001.SIGNAL_QUIT);
80             display("completed succesfully.");
81             System.exit(Consts.TEST_PASSED + Consts.JCK_STATUS_BASE);
82         } catch (Failure e) {
83             log.complain(e.getMessage());
84             System.exit(Consts.TEST_FAILED + Consts.JCK_STATUS_BASE);
85         }
86     }
87 
88     //--------------------------------------------------------- test specific methods
breakHere()89     public static void breakHere () {
90         receiveSignal(tostring001.SIGNAL_GO);
91         log.display("breakpoint line"); // brkpLineNumber
92     }
93 }
94 
95 //--------------------------------------------------------- test specific classes
96