hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerServer.java
author coleenp
Sun, 13 Apr 2008 17:43:42 -0400
changeset 360 21d113ecbf6a
parent 1 489c9b5090e2
child 670 ddf3e9583f2f
permissions -rw-r--r--
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2003 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
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.debugger.remote;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
import java.rmi.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
import java.rmi.server.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
import sun.jvm.hotspot.debugger.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
/** The implementation of the RemoteDebugger interface. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
    delegates to a local debugger */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
public class RemoteDebuggerServer extends UnicastRemoteObject
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  implements RemoteDebugger {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  private transient Debugger debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  /** This is the required no-arg constructor */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  public RemoteDebuggerServer() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    super();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  /** This is the constructor used on the machine where the debuggee
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
      process lies */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  public RemoteDebuggerServer(Debugger debugger) throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    super();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    this.debugger = debugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  public String getOS() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    return debugger.getOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  public String getCPU() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    return debugger.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  public MachineDescription getMachineDescription() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    return debugger.getMachineDescription();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  public long lookupInProcess(String objectName, String symbol) throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    Address addr = debugger.lookup(objectName, symbol);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    return addr == null? 0L : debugger.getAddressValue(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  public ReadResult readBytesFromProcess(long address, long numBytes) throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    return debugger.readBytesFromProcess(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  public boolean hasConsole() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    return debugger.hasConsole();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  public String getConsolePrompt() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    return debugger.getConsolePrompt();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  public String consoleExecuteCommand(String cmd) throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    return debugger.consoleExecuteCommand(cmd);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  public long getJBooleanSize() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    return debugger.getJBooleanSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  public long getJByteSize() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    return debugger.getJByteSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  public long getJCharSize() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    return debugger.getJCharSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  public long getJDoubleSize() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    return debugger.getJDoubleSize();
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 long getJFloatSize() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    return debugger.getJFloatSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  public long getJIntSize() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    return debugger.getJIntSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  public long getJLongSize() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    return debugger.getJLongSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  public long getJShortSize() throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    return debugger.getJShortSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   117
  public long getHeapBase() throws RemoteException {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   118
    return debugger.getHeapBase();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   119
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   120
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   121
  public long getHeapOopSize() throws RemoteException {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   122
    return debugger.getHeapOopSize();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   123
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   124
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   125
  public long getLogMinObjAlignmentInBytes() throws RemoteException {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   126
    return debugger.getLogMinObjAlignmentInBytes();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   127
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  public boolean   areThreadsEqual(long addrOrId1, boolean isAddress1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
                                   long addrOrId2, boolean isAddress2) throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    ThreadProxy t1 = getThreadProxy(addrOrId1, isAddress1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    ThreadProxy t2 = getThreadProxy(addrOrId2, isAddress2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    return t1.equals(t2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  public int       getThreadHashCode(long addrOrId, boolean isAddress) throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    ThreadProxy t = getThreadProxy(addrOrId, isAddress);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    return t.hashCode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  public long[]    getThreadIntegerRegisterSet(long addrOrId, boolean isAddress) throws RemoteException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    ThreadProxy t = getThreadProxy(addrOrId, isAddress);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    ThreadContext tc = t.getContext();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    long[] regs = new long[tc.getNumRegisters()];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    for (int r = 0; r < regs.length; r++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
       regs[r] = tc.getRegister(r);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    return regs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  private ThreadProxy getThreadProxy(long addrOrId, boolean isAddress) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
     if (isAddress) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
        Address addr = debugger.parseAddress("0x" + Long.toHexString(addrOrId));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
        return debugger.getThreadForIdentifierAddress(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
     } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
        return debugger.getThreadForThreadId(addrOrId);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
     }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
}