author | iignatyev |
Wed, 30 May 2018 20:54:45 -0700 | |
changeset 50317 | cf71bff5f533 |
permissions | -rw-r--r-- |
50317
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
1 |
/* |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
4 |
* |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
8 |
* |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
14 |
* |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
18 |
* |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
22 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
23 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
24 |
package nsk.jdwp.ThreadReference.Stop; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
25 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
26 |
import java.io.*; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
27 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
28 |
import nsk.share.*; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
29 |
import nsk.share.jpda.*; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
30 |
import nsk.share.jdwp.*; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
31 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
32 |
/** |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
33 |
* Test for JDWP command: ThreadReference.Stop. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
34 |
* |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
35 |
* See stop001.README for description of test execution. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
36 |
* |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
37 |
* This class represents debugger part of the test. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
38 |
* Test is executed by invoking method runIt(). |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
39 |
* JDWP command is tested in the method testCommand(). |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
40 |
* |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
41 |
* @see #runIt() |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
42 |
* @see #testCommand() |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
43 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
44 |
public class stop001 { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
45 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
46 |
// exit status constants |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
47 |
static final int JCK_STATUS_BASE = 95; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
48 |
static final int PASSED = 0; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
49 |
static final int FAILED = 2; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
50 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
51 |
// communication signals constants |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
52 |
static final String READY = "ready"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
53 |
static final String ERROR = "error"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
54 |
static final String RUN = "run"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
55 |
static final String STOPPED = "stopped"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
56 |
static final String NOT_STOPPED = "not_stopped"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
57 |
static final String QUIT = "quit"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
58 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
59 |
// package and classes names constants |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
60 |
static final String PACKAGE_NAME = "nsk.jdwp.ThreadReference.Stop"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
61 |
static final String TEST_CLASS_NAME = PACKAGE_NAME + "." + "stop001"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
62 |
static final String DEBUGEE_CLASS_NAME = TEST_CLASS_NAME + "a"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
63 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
64 |
// tested JDWP command constants |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
65 |
static final String JDWP_COMMAND_NAME = "ThreadReference.Stop"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
66 |
static final int JDWP_COMMAND_ID = JDWP.Command.ThreadReference.Stop; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
67 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
68 |
// tested class name and signature constants |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
69 |
static final String TESTED_CLASS_NAME = DEBUGEE_CLASS_NAME + "$" + "TestedClass"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
70 |
static final String TESTED_CLASS_SIGNATURE = "L" + TESTED_CLASS_NAME.replace('.', '/') + ";"; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
71 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
72 |
// name of the tested thread and statioc field with thread value |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
73 |
static final String TESTED_THREAD_NAME = stop001a.THREAD_NAME; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
74 |
static final String THREAD_FIELD_NAME = stop001a.THREAD_FIELD_NAME; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
75 |
static final String THROWABLE_FIELD_NAME = stop001a.THROWABLE_FIELD_NAME; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
76 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
77 |
// usual scaffold objects |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
78 |
ArgumentHandler argumentHandler = null; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
79 |
Log log = null; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
80 |
Binder binder = null; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
81 |
Debugee debugee = null; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
82 |
Transport transport = null; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
83 |
IOPipe pipe = null; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
84 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
85 |
// test passed or not |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
86 |
boolean success = true; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
87 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
88 |
// ------------------------------------------------------------------- |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
89 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
90 |
/** |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
91 |
* Start test from command line. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
92 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
93 |
public static void main (String argv[]) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
94 |
System.exit(run(argv,System.out) + JCK_STATUS_BASE); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
95 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
96 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
97 |
/** |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
98 |
* Start JCK-compilant test. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
99 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
100 |
public static int run(String argv[], PrintStream out) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
101 |
return new stop001().runIt(argv, out); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
102 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
103 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
104 |
// ------------------------------------------------------------------- |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
105 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
106 |
/** |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
107 |
* Perform test execution. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
108 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
109 |
public int runIt(String argv[], PrintStream out) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
110 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
111 |
// make log for debugger messages |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
112 |
argumentHandler = new ArgumentHandler(argv); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
113 |
log = new Log(out, argumentHandler); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
114 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
115 |
// execute test and display results |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
116 |
try { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
117 |
log.display("\n>>> Preparing debugee for testing \n"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
118 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
119 |
// launch debuggee |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
120 |
binder = new Binder(argumentHandler, log); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
121 |
log.display("Launching debugee"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
122 |
debugee = binder.bindToDebugee(DEBUGEE_CLASS_NAME); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
123 |
transport = debugee.getTransport(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
124 |
pipe = debugee.createIOPipe(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
125 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
126 |
// make debuggee ready for testing |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
127 |
prepareDebugee(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
128 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
129 |
// work with prepared debuggee |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
130 |
try { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
131 |
log.display("\n>>> Obtaining requred data from debugee \n"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
132 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
133 |
// query debuggee for classID of tested class |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
134 |
log.display("Getting classID by signature:\n" |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
135 |
+ " " + TESTED_CLASS_SIGNATURE); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
136 |
long classID = debugee.getReferenceTypeID(TESTED_CLASS_SIGNATURE); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
137 |
log.display(" got classID: " + classID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
138 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
139 |
// query debuggee for threadID value from a static field |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
140 |
log.display("Getting threadID value from static field: " |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
141 |
+ THREAD_FIELD_NAME); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
142 |
long threadID = queryObjectID(classID, THREAD_FIELD_NAME, JDWP.Tag.THREAD); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
143 |
log.display(" got threadID: " + threadID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
144 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
145 |
// query debuggee for throwable objectID value from a static field |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
146 |
log.display("Getting throwable objectID value from static field: " |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
147 |
+ THROWABLE_FIELD_NAME); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
148 |
long objectID = queryObjectID(classID, THROWABLE_FIELD_NAME, JDWP.Tag.OBJECT); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
149 |
log.display(" got objectID: " + objectID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
150 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
151 |
// perform testing JDWP command |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
152 |
log.display("\n>>> Testing JDWP command \n"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
153 |
testCommand(threadID, objectID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
154 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
155 |
log.display("\n>>> Checking that tested thread was really stopped \n"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
156 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
157 |
// check if the thread was really stopped |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
158 |
confirmThreadStopped(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
159 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
160 |
} finally { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
161 |
log.display("\n>>> Finishing test \n"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
162 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
163 |
// quit debugee |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
164 |
quitDebugee(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
165 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
166 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
167 |
} catch (Failure e) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
168 |
log.complain("TEST FAILED: " + e.getMessage()); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
169 |
success = false; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
170 |
} catch (Exception e) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
171 |
e.printStackTrace(out); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
172 |
log.complain("Caught unexpected exception while running the test:\n\t" + e); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
173 |
success = false; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
174 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
175 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
176 |
if (!success) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
177 |
log.complain("TEST FAILED"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
178 |
return FAILED; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
179 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
180 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
181 |
out.println("TEST PASSED"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
182 |
return PASSED; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
183 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
184 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
185 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
186 |
/** |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
187 |
* Prepare debugee for testing and waiting for ready signal. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
188 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
189 |
void prepareDebugee() { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
190 |
// wait for VM_INIT event from debugee |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
191 |
log.display("Waiting for VM_INIT event"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
192 |
debugee.waitForVMInit(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
193 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
194 |
// query debugee for VM-dependent ID sizes |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
195 |
log.display("Querying for IDSizes"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
196 |
debugee.queryForIDSizes(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
197 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
198 |
// resume initially suspended debugee |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
199 |
log.display("Resuming debugee VM"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
200 |
debugee.resume(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
201 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
202 |
// wait for READY signal from debugee |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
203 |
log.display("Waiting for signal from debugee: " + READY); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
204 |
String signal = pipe.readln(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
205 |
log.display("Received signal from debugee: " + signal); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
206 |
if (signal == null) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
207 |
throw new TestBug("Null signal received from debugee: " + signal |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
208 |
+ " (expected: " + READY + ")"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
209 |
} else if (signal.equals(ERROR)) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
210 |
throw new TestBug("Debugee was not able to start tested thread" |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
211 |
+ " (received signal: " + signal + ")"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
212 |
} else if (!signal.equals(READY)) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
213 |
throw new TestBug("Unexpected signal received from debugee: " + signal |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
214 |
+ " (expected: " + READY + ")"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
215 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
216 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
217 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
218 |
/** |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
219 |
* Sending debugee signal to quit and waiting for it exits. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
220 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
221 |
void quitDebugee() { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
222 |
// send debugee signal to quit |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
223 |
log.display("Sending signal to debugee: " + QUIT); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
224 |
pipe.println(QUIT); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
225 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
226 |
// wait for debugee exits |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
227 |
log.display("Waiting for debugee exits"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
228 |
int code = debugee.waitFor(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
229 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
230 |
// analize debugee exit status code |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
231 |
if (code == JCK_STATUS_BASE + PASSED) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
232 |
log.display("Debugee PASSED with exit code: " + code); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
233 |
} else { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
234 |
log.complain("Debugee FAILED with exit code: " + code); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
235 |
success = false; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
236 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
237 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
238 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
239 |
/** |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
240 |
* Query debuggee for objectID value from the class static field. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
241 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
242 |
long queryObjectID(long classID, String fieldName, byte tag) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
243 |
// get fieledID for static field (declared in the class) |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
244 |
long fieldID = debugee.getClassFieldID(classID, fieldName, true); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
245 |
// get value of the field |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
246 |
JDWP.Value value = debugee.getStaticFieldValue(classID, fieldID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
247 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
248 |
// check that value has THREAD tag |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
249 |
if (value.getTag() != tag) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
250 |
throw new Failure("Not threadID value returned from debuggee: " + value); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
251 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
252 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
253 |
// extract threadID from the value |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
254 |
long objectID = ((Long)value.getValue()).longValue(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
255 |
return objectID; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
256 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
257 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
258 |
/** |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
259 |
* Perform testing JDWP command for specified threadID and throwable objectID. |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
260 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
261 |
void testCommand(long threadID, long objectID) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
262 |
// create command packet and fill requred out data |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
263 |
log.display("Create command packet:"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
264 |
log.display("Command: " + JDWP_COMMAND_NAME); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
265 |
CommandPacket command = new CommandPacket(JDWP_COMMAND_ID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
266 |
log.display(" threadID: " + threadID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
267 |
command.addObjectID(threadID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
268 |
log.display(" throwable: " + objectID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
269 |
command.addObjectID(objectID); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
270 |
command.setLength(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
271 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
272 |
// send command packet to debugee |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
273 |
try { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
274 |
log.display("Sending command packet:\n" + command); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
275 |
transport.write(command); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
276 |
} catch (IOException e) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
277 |
log.complain("Unable to send command packet:\n\t" + e); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
278 |
success = false; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
279 |
return; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
280 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
281 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
282 |
ReplyPacket reply = new ReplyPacket(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
283 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
284 |
// receive reply packet from debugee |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
285 |
try { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
286 |
log.display("Waiting for reply packet"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
287 |
transport.read(reply); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
288 |
log.display("Reply packet received:\n" + reply); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
289 |
} catch (IOException e) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
290 |
log.complain("Unable to read reply packet:\n\t" + e); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
291 |
success = false; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
292 |
return; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
293 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
294 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
295 |
// check reply packet header |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
296 |
try{ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
297 |
log.display("Checking reply packet header"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
298 |
reply.checkHeader(command.getPacketID()); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
299 |
} catch (BoundException e) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
300 |
log.complain("Bad header of reply packet:\n\t" + e.getMessage()); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
301 |
success = false; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
302 |
return; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
303 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
304 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
305 |
// start parsing reply packet data |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
306 |
log.display("Parsing reply packet:"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
307 |
reply.resetPosition(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
308 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
309 |
// there are no data to extract |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
310 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
311 |
// check for extra data in reply packet |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
312 |
if (!reply.isParsed()) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
313 |
log.complain("Extra trailing bytes found in reply packet at: " |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
314 |
+ reply.offsetString()); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
315 |
success = false; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
316 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
317 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
318 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
319 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
320 |
/** |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
321 |
* Wait for signal from debugee that thread was really stopped |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
322 |
*/ |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
323 |
void confirmThreadStopped() { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
324 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
325 |
// send debugee signal to run |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
326 |
log.display("Sending signal to debugee: " + RUN); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
327 |
pipe.println(RUN); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
328 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
329 |
// wait for signal DONE from debuggee |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
330 |
log.display("Waiting for signal from debugee: " + STOPPED); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
331 |
String signal = pipe.readln(); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
332 |
log.display("Received signal from debugee: " + signal); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
333 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
334 |
// check received signal |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
335 |
if (signal == null) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
336 |
throw new TestBug("Null signal received from debugee: " + signal |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
337 |
+ " (expected: " + STOPPED + ")"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
338 |
} else if (signal.equals(STOPPED)) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
339 |
log.display("Tested thread was really stopped into debuggee"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
340 |
} else if (signal.equals(NOT_STOPPED)) { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
341 |
log.complain("Tested thread was NOT really stopped into debuggee"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
342 |
success = false; |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
343 |
} else { |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
344 |
throw new TestBug("Unexpected signal received from debugee: " + signal |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
345 |
+ " (expected: " + STOPPED + ")"); |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
346 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
347 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
348 |
} |
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
349 |
|
cf71bff5f533
8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff
changeset
|
350 |
} |