jdk/test/com/sun/jdi/FetchLocals.java
author iignatyev
Mon, 03 Apr 2017 17:07:27 -0700
changeset 44529 c1e6dd7a7326
parent 24973 8c4bc3fa4c4e
permissions -rw-r--r--
8177507: line number sensitive tests for jdi should be unified Reviewed-by: dholmes, mseledtsov, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44529
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
     1
/*
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
     2
 * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
     4
 *
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
     7
 * published by the Free Software Foundation.
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
     8
 *
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    13
 * accompanied this code).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
44529
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
44529
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    21
 * questions.
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    22
 */
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    23
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    24
//    THIS TEST IS LINE NUMBER SENSITIVE
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    25
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    26
/**
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    27
 * @test
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    28
 * @bug 4386002 4429245
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    29
 * @summary Test fix for: Incorrect values reported for some locals of type long
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    30
 * @author Tim Bell
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    31
 *
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    32
 * @run build TestScaffold VMConnection TargetListener TargetAdapter
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    33
 * @run compile -g FetchLocals.java
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    34
 * @run driver FetchLocals
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jdi.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
class FetchLocalsDebugee {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    public long testMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        short s = 12345;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        int i = 8675309;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        boolean pt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        long w = 973230999L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        byte b = 0x3b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        long x = w * 1000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        char c = '\u005A';      // 005A = "Z"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        long y = 22;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        float f = 6.66f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        double d = 7.77;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        System.out.print("pt is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        System.out.println(pt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        System.out.print("b is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        System.out.println(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        System.out.print("c is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        System.out.println(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        System.out.print("s is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        System.out.println(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        System.out.print("i is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        System.out.println(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        System.out.print("w is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        System.out.print(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        System.out.print("     (0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        System.out.print(Long.toHexString(w));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        System.out.println(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        System.out.print("x is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        System.out.print(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        System.out.print("  (0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        System.out.print(Long.toHexString(x));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        System.out.println(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        System.out.print("y is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        System.out.print(y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        System.out.print("            (0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        System.out.print(Long.toHexString(y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        System.out.println(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        System.out.print("f is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        System.out.println(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        System.out.print("d is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        System.out.println(d);
44529
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
    86
        System.out.println();   // This is FetchLocals::LINE
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        if (w == 0xde00ad00be00ef00L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
          System.out.print  ("The debugger was here.  w modified to: 0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
          System.out.println(Long.toHexString(w));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
          System.out.print  ("w contains : 0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
          System.out.println(Long.toHexString(w));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        System.out.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        return x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        System.out.print  ("FetchLocalsDebugee");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        System.out.println(" Starting up...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        FetchLocalsDebugee my = new FetchLocalsDebugee ();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        long result = my.testMethod();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        System.out.print  ("testMethod() returned: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        System.out.print  (result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        System.out.print  (" (0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        System.out.print  (Long.toHexString(result));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        System.out.println(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        System.out.print  ("FetchLocalsDebugee");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        System.out.println(" Shutting down...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
public class FetchLocals extends TestScaffold {
44529
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
   114
    static final int LINE = 86;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    FetchLocals (String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        super(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public static void main(String[] args)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        new FetchLocals (args).startTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /** Express a 64 bit double as a hex string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    private static String hexify(double d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        long bits = Double.doubleToLongBits(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        return (" (0x" + java.lang.Long.toHexString(bits) + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /** Express a 32 bit float as a hex string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    private static String hexify(float f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        int bits = Float.floatToIntBits(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        return (" (0x" + java.lang.Integer.toHexString(bits) + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    protected void test(String name, BooleanValue testV, boolean expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    protected void test(String name, ByteValue testV, byte expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    protected void test(String name, CharValue testV, char expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    protected void test(String name, ShortValue testV, short expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    protected void test(String name, IntegerValue testV, int expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    protected void test(String name, LongValue testV, long expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            System.out.println("Error for " + name + " = 0x" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                                 Long.toHexString(testV.value()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                 " should be: 0x" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                 Long.toHexString(expectV));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    protected void test(String name, FloatValue testV, float expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                               hexify(testV.value()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                               " should be: " + expectV +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                               hexify(expectV));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    protected void test(String name, DoubleValue testV, double expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                               hexify(testV.value()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                               " should be: " + expectV +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                               hexify(expectV));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    protected void testLocalVariables (StackFrame sf)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
         * Test values in the local method testMethod ():
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
         *   1) Read current data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
         *   2) Test against the expected value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
         *   3) Set to a new value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
         *   4) Read again
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
         *   5) Test against the expected value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        LocalVariable lv = sf.visibleVariableByName("pt");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        BooleanValue booleanV = (BooleanValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        test("pt", booleanV, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        booleanV = vm().mirrorOf(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        sf.setValue(lv, booleanV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        booleanV = (BooleanValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        test("pt", booleanV, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        lv = sf.visibleVariableByName("b");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        ByteValue byteV = (ByteValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        byte bTmp = 0x3b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        test("b", byteV, bTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        bTmp = 0x7e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        byteV = vm().mirrorOf(bTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        sf.setValue(lv, byteV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        byteV = (ByteValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        test("b", byteV, bTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        lv = sf.visibleVariableByName("c");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        CharValue charV = (CharValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        char cTmp = '\u005A';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        test("c", charV, cTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        cTmp = 'A';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        charV = vm().mirrorOf(cTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        sf.setValue(lv, charV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        charV = (CharValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        test("c", charV, cTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        lv = sf.visibleVariableByName("s");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        ShortValue shortV = (ShortValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        short sTmp = 12345;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        test("s", shortV, sTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        sTmp = -32766;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        shortV = vm().mirrorOf(sTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        sf.setValue(lv, shortV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        shortV = (ShortValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        test("s", shortV, sTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        lv = sf.visibleVariableByName("i");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        IntegerValue integerV = (IntegerValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        int iTmp = 8675309;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        test("i", integerV, iTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        iTmp = -42;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        integerV = vm().mirrorOf(iTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        sf.setValue(lv, integerV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        integerV = (IntegerValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        test("i", integerV, iTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        lv = sf.visibleVariableByName("w");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        LongValue longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        long wTmp = 973230999L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        test("w", longV, wTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        wTmp = 0xde00ad00be00ef00L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        longV = vm().mirrorOf(wTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        sf.setValue(lv, longV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        test("w", longV, wTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        lv = sf.visibleVariableByName("x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        long xTmp = 973230999L * 1000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        test("x", longV, xTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        xTmp = 0xca00fe00ba00be00L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        longV = vm().mirrorOf(xTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        sf.setValue(lv, longV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        test("x", longV, xTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        lv = sf.visibleVariableByName("y");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        long yTmp = 22;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        test("y", longV, yTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        yTmp = 0xdeadbeefcafebabeL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        longV = vm().mirrorOf(yTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        sf.setValue(lv, longV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        test("x", longV, yTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        lv = sf.visibleVariableByName("f");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        FloatValue floatV = (FloatValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        float fTmp = 6.66f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        test("f", floatV, fTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        fTmp = (float)java.lang.Math.PI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        floatV = vm().mirrorOf(fTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        sf.setValue(lv, floatV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        floatV = (FloatValue)sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        test("f", floatV, fTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        lv = sf.visibleVariableByName("d");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        DoubleValue doubleV = (DoubleValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        double dTmp = 7.77;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        test("d", doubleV, dTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        dTmp = java.lang.Math.E;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        doubleV = vm().mirrorOf(dTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        sf.setValue(lv, doubleV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        doubleV = (DoubleValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        test("d", doubleV, dTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    protected void runTests()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        startToMain("FetchLocalsDebugee");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
         * Get to the bottom of testMethod():
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        try {
44529
c1e6dd7a7326 8177507: line number sensitive tests for jdi should be unified
iignatyev
parents: 24973
diff changeset
   383
            BreakpointEvent bpe = resumeTo("FetchLocalsDebugee", LINE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
             * Fetch values from fields; what did we get?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            StackFrame sf = bpe.thread().frame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            testLocalVariables (sf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        } catch(Exception ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            ex.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            // Allow application to complete and shut down
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            resumeToVMDisconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        if (!testFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            System.out.println("FetchLocals: passed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            throw new Exception("FetchLocals: failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
}