hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/StackFrameImpl.java
author never
Mon, 05 Sep 2011 17:09:05 -0700
changeset 10517 f92c9ff3a15f
parent 5547 f4b087cbb361
permissions -rw-r--r--
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244) Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
     2
 * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
package sun.jvm.hotspot.jdi;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import com.sun.jdi.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import sun.jvm.hotspot.oops.ObjectHeap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
import sun.jvm.hotspot.debugger.OopHandle;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
import sun.jvm.hotspot.oops.Array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
import sun.jvm.hotspot.oops.ObjArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
import sun.jvm.hotspot.oops.TypeArray;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
import sun.jvm.hotspot.oops.Instance;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
import sun.jvm.hotspot.runtime.BasicType;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
import sun.jvm.hotspot.runtime.JavaVFrame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
import sun.jvm.hotspot.runtime.StackValue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
import sun.jvm.hotspot.runtime.StackValueCollection;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
import sun.jvm.hotspot.utilities.Assert;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
import java.util.List;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
import java.util.Map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
import java.util.ArrayList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
import java.util.HashMap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
import java.util.Iterator;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
import java.util.Collections;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
public class StackFrameImpl extends MirrorImpl
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
                            implements StackFrame
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    /* Once false, frame should not be used.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
     * access synchronized on (vm.state())
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
     */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    private boolean isValid = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    private final ThreadReferenceImpl thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    private final JavaVFrame saFrame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    private final Location location;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    private Map visibleVariables =  null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    private ObjectReference thisObject = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    StackFrameImpl(VirtualMachine vm, ThreadReferenceImpl thread,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
                   JavaVFrame jvf) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
        super(vm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
        this.thread = thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
        this.saFrame = jvf;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
        sun.jvm.hotspot.oops.Method SAMethod = jvf.getMethod();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
        ReferenceType rt = ((VirtualMachineImpl)vm).referenceType(SAMethod.getMethodHolder());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
        this.location = new LocationImpl(vm, rt, SAMethod, (long)jvf.getBCI());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    private void validateStackFrame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
        if (!isValid) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
            throw new InvalidStackFrameException("Thread has been resumed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    JavaVFrame getJavaVFrame() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        return saFrame;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    /**
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
     * Return the frame location.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
     * Need not be synchronized since it cannot be provably stale.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
     */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    public Location location() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
        validateStackFrame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
        return location;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    /**
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
     * Return the thread holding the frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
     * Need not be synchronized since it cannot be provably stale.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
     */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    public ThreadReference thread() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
        validateStackFrame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
        return thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    public boolean equals(Object obj) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
        if ((obj != null) && (obj instanceof StackFrameImpl)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
            StackFrameImpl other = (StackFrameImpl)obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
            return (saFrame.equals(other.saFrame));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
            return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    public int hashCode() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
        return saFrame.hashCode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    public ObjectReference thisObject() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
        validateStackFrame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
        MethodImpl currentMethod = (MethodImpl)location.method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
        if (currentMethod.isStatic() || currentMethod.isNative()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
            return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
        if (thisObject == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
            StackValueCollection values = saFrame.getLocals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
            if (Assert.ASSERTS_ENABLED) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
                Assert.that(values.size() > 0, "this is missing");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
            // 'this' at index 0.
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   126
            if (values.get(0).getType() == BasicType.getTConflict()) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   127
              return null;
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   128
            }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
            OopHandle handle = values.oopHandleAt(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
            ObjectHeap heap = vm.saObjectHeap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
            thisObject = vm.objectMirror(heap.newOop(handle));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
        return thisObject;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    /**
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
     * Build the visible variable map.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
     * Need not be synchronized since it cannot be provably stale.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
     */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    private void createVisibleVariables() throws AbsentInformationException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
        if (visibleVariables == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
            List allVariables = location.method().variables();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
            Map map = new HashMap(allVariables.size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
            Iterator iter = allVariables.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
            while (iter.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
                LocalVariableImpl variable = (LocalVariableImpl)iter.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
                String name = variable.name();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
                if (variable.isVisible(this)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
                    LocalVariable existing = (LocalVariable)map.get(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
                    if ((existing == null) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
                        variable.hides(existing)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
                        map.put(name, variable);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
            visibleVariables = map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    /**
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
     * Return the list of visible variable in the frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
     * Need not be synchronized since it cannot be provably stale.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
     */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    public List visibleVariables() throws AbsentInformationException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
        validateStackFrame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
        createVisibleVariables();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
        List mapAsList = new ArrayList(visibleVariables.values());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        Collections.sort(mapAsList);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
        return mapAsList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    /**
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
     * Return a particular variable in the frame.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
     * Need not be synchronized since it cannot be provably stale.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
     */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    public LocalVariable visibleVariableByName(String name) throws AbsentInformationException  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
        validateStackFrame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
        createVisibleVariables();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
        return (LocalVariable)visibleVariables.get(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    public Value getValue(LocalVariable variable) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
        List list = new ArrayList(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
        list.add(variable);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
        Map map = getValues(list);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
        return (Value)map.get(variable);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    public Map getValues(List variables) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
        validateStackFrame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
        StackValueCollection values = saFrame.getLocals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
        int count = variables.size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
        Map map = new HashMap(count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
        for (int ii=0; ii<count; ++ii) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
            LocalVariableImpl variable = (LocalVariableImpl)variables.get(ii);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
            if (!variable.isVisible(this)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
                throw new IllegalArgumentException(variable.name() +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
                                 " is not valid at this frame location");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
            ValueImpl valueImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
            int ss = variable.slot();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
            char c = variable.signature().charAt(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
            BasicType variableType = BasicType.charToBasicType(c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
            valueImpl = getSlotValue(values, variableType, ss);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
            map.put(variable, valueImpl);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
        return map;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    public List getArgumentValues() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
        validateStackFrame();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
        StackValueCollection values = saFrame.getLocals();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
        MethodImpl mmm = (MethodImpl)location.method();
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   216
        if (mmm.isNative())
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   217
            return null;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
        List argSigs = mmm.argumentSignatures();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
        int count = argSigs.size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
        List res = new ArrayList(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
        int slot = mmm.isStatic()? 0 : 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
        for (int ii = 0; ii < count; ++slot, ++ii) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
            char sigChar = ((String)argSigs.get(ii)).charAt(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
            BasicType variableType = BasicType.charToBasicType(sigChar);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
            res.add(getSlotValue(values, variableType, slot));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
            if (sigChar == 'J' || sigChar == 'D') {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
                slot++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
        return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    private ValueImpl getSlotValue(StackValueCollection values,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
                       BasicType variableType, int ss) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
        ValueImpl valueImpl = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
        OopHandle handle = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
        ObjectHeap heap = vm.saObjectHeap();
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   239
        if (values.get(ss).getType() == BasicType.getTConflict()) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   240
          // Dead locals, so just represent them as a zero of the appropriate type
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   241
          if (variableType == BasicType.T_BOOLEAN) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   242
            valueImpl = (BooleanValueImpl) vm.mirrorOf(false);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   243
          } else if (variableType == BasicType.T_CHAR) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   244
            valueImpl = (CharValueImpl) vm.mirrorOf((char)0);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   245
          } else if (variableType == BasicType.T_FLOAT) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   246
            valueImpl = (FloatValueImpl) vm.mirrorOf((float)0);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   247
          } else if (variableType == BasicType.T_DOUBLE) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   248
            valueImpl = (DoubleValueImpl) vm.mirrorOf((double)0);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   249
          } else if (variableType == BasicType.T_BYTE) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   250
            valueImpl = (ByteValueImpl) vm.mirrorOf((byte)0);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   251
          } else if (variableType == BasicType.T_SHORT) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   252
            valueImpl = (ShortValueImpl) vm.mirrorOf((short)0);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   253
          } else if (variableType == BasicType.T_INT) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   254
            valueImpl = (IntegerValueImpl) vm.mirrorOf((int)0);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   255
          } else if (variableType == BasicType.T_LONG) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   256
            valueImpl = (LongValueImpl) vm.mirrorOf((long)0);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   257
          } else if (variableType == BasicType.T_OBJECT) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   258
            // we may have an [Ljava/lang/Object; - i.e., Object[] with the
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   259
            // elements themselves may be arrays because every array is an Object.
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   260
            handle = null;
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   261
            valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   262
          } else if (variableType == BasicType.T_ARRAY) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   263
            handle = null;
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   264
            valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   265
          } else if (variableType == BasicType.T_VOID) {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   266
            valueImpl = new VoidValueImpl(vm);
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   267
          } else {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   268
            throw new RuntimeException("Should not read here");
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   269
          }
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   270
        } else {
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   271
          if (variableType == BasicType.T_BOOLEAN) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
            valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   273
          } else if (variableType == BasicType.T_CHAR) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
            valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   275
          } else if (variableType == BasicType.T_FLOAT) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
            valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   277
          } else if (variableType == BasicType.T_DOUBLE) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
            valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   279
          } else if (variableType == BasicType.T_BYTE) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
            valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   281
          } else if (variableType == BasicType.T_SHORT) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
            valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   283
          } else if (variableType == BasicType.T_INT) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
            valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   285
          } else if (variableType == BasicType.T_LONG) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
            valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   287
          } else if (variableType == BasicType.T_OBJECT) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
            // we may have an [Ljava/lang/Object; - i.e., Object[] with the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
            // elements themselves may be arrays because every array is an Object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
            handle = values.oopHandleAt(ss);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
            valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   292
          } else if (variableType == BasicType.T_ARRAY) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
            handle = values.oopHandleAt(ss);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
            valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   295
          } else if (variableType == BasicType.T_VOID) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
            valueImpl = new VoidValueImpl(vm);
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   297
          } else {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
            throw new RuntimeException("Should not read here");
10517
f92c9ff3a15f 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 5547
diff changeset
   299
          }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
        return valueImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    public void setValue(LocalVariable variableIntf, Value valueIntf)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
        throws InvalidTypeException, ClassNotLoadedException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
        vm.throwNotReadOnlyException("StackFrame.setValue()");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    public String toString() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
        return location.toString() + " in thread " + thread.toString();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
}