hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/remote/RemoteDebuggerClient.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-2004 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.util.*;
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
import sun.jvm.hotspot.debugger.cdbg.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
import sun.jvm.hotspot.debugger.remote.sparc.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
import sun.jvm.hotspot.debugger.remote.x86.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
import sun.jvm.hotspot.debugger.remote.amd64.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
/** An implementation of Debugger which wraps a
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    RemoteDebugger, providing remote debugging via RMI.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    This implementation provides caching of the remote process's
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    address space on the local machine where the user interface is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    running. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
public class RemoteDebuggerClient extends DebuggerBase implements JVMDebugger {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  private RemoteDebugger remoteDebugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  private RemoteThreadFactory threadFactory;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  private boolean unalignedAccessesOkay = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  private static final int cacheSize = 16 * 1024 * 1024; // 16 MB
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  public RemoteDebuggerClient(RemoteDebugger remoteDebugger) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    super();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
      this.remoteDebugger = remoteDebugger;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
      machDesc = remoteDebugger.getMachineDescription();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
      utils = new DebuggerUtilities(machDesc.getAddressSize(), machDesc.isBigEndian());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
      int cacheNumPages;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
      int cachePageSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
      String cpu = remoteDebugger.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
      // page size. (FIXME: should pick this up from the remoteDebugger.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
      if (cpu.equals("sparc")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
        threadFactory = new RemoteSPARCThreadFactory(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
        cachePageSize = 8192;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
        cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
      } else if (cpu.equals("x86")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
        threadFactory = new RemoteX86ThreadFactory(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
        cachePageSize = 4096;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
        cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
        unalignedAccessesOkay = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
      } else if (cpu.equals("amd64")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
        threadFactory = new RemoteAMD64ThreadFactory(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
        cachePageSize = 4096;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
        cacheNumPages = parseCacheNumPagesProperty(cacheSize / cachePageSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
        unalignedAccessesOkay = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
        throw new DebuggerException("Thread access for CPU architecture " + cpu + " not yet supported");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
      // Cache portion of the remote process's address space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      initCache(cachePageSize, cacheNumPages);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
      jbooleanSize = remoteDebugger.getJBooleanSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      jbyteSize    = remoteDebugger.getJByteSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
      jcharSize    = remoteDebugger.getJCharSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
      jdoubleSize  = remoteDebugger.getJDoubleSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
      jfloatSize   = remoteDebugger.getJFloatSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
      jintSize     = remoteDebugger.getJIntSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
      jlongSize    = remoteDebugger.getJLongSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
      jshortSize   = remoteDebugger.getJShortSize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
      javaPrimitiveTypesConfigured = true;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    88
      heapBase     = remoteDebugger.getHeapBase();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    89
      heapOopSize  = remoteDebugger.getHeapOopSize();
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    90
      logMinObjAlignmentInBytes  = remoteDebugger.getLogMinObjAlignmentInBytes();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
      throw new DebuggerException(e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    }
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[] getThreadIntegerRegisterSet(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
      return remoteDebugger.getThreadIntegerRegisterSet(getAddressValue(addr), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
      throw new DebuggerException(e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  public long[] getThreadIntegerRegisterSet(long id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      return remoteDebugger.getThreadIntegerRegisterSet(id, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
      throw new DebuggerException(e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  /** Unimplemented in this class (remote remoteDebugger should already be attached) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  public boolean hasProcessList() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    throw new DebuggerException("Should not be called on RemoteDebuggerClient");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  /** Unimplemented in this class (remote remoteDebugger should already be attached) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  public List getProcessList() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    throw new DebuggerException("Should not be called on RemoteDebuggerClient");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  /** Unimplemented in this class (remote remoteDebugger should already be attached) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  public void attach(int processID) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    throw new DebuggerException("Should not be called on RemoteDebuggerClient");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  /** Unimplemented in this class (remote remoteDebugger should already be attached) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  public void attach(String executableName, String coreFileName) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    throw new DebuggerException("Should not be called on RemoteDebuggerClient");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  /** Unimplemented in this class (remote remoteDebugger can not be detached) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  public boolean detach() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    throw new DebuggerException("Should not be called on RemoteDebuggerClient");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  public Address parseAddress(String addressString) throws NumberFormatException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    long addr = utils.scanAddress(addressString);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    if (addr == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    return new RemoteAddress(this, addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  public String getOS() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
      return remoteDebugger.getOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      throw new DebuggerException(e);
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
  public String getCPU() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
      return remoteDebugger.getCPU();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
      throw new DebuggerException(e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  public boolean hasConsole() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
       return remoteDebugger.hasConsole();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    } catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
       throw new DebuggerException(e);
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
  public String consoleExecuteCommand(String cmd) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
      return remoteDebugger.consoleExecuteCommand(cmd);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
      throw new DebuggerException(e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    }
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 String getConsolePrompt() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
      return remoteDebugger.getConsolePrompt();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
    } catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
      throw new DebuggerException(e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  public CDebugger getCDebugger() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // Implementation of SymbolLookup interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  public Address lookup(String objectName, String symbol) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      long addr = remoteDebugger.lookupInProcess(objectName, symbol);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
      if (addr == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
        return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
      return new RemoteAddress(this, addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
      throw new DebuggerException(e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  public OopHandle lookupOop(String objectName, String symbol) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      long addr = remoteDebugger.lookupInProcess(objectName, symbol);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
      if (addr == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
        return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      return new RemoteOopHandle(this, addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
      throw new DebuggerException(e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  /** Need to override this to relax alignment checks on x86. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  public long readCInteger(long address, long numBytes, boolean isUnsigned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    if (!unalignedAccessesOkay) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      utils.checkAlignment(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
      // Only slightly relaxed semantics -- this is a hack, but is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
      // necessary on x86 where it seems the compiler is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
      // putting some global 64-bit data on 32-bit boundaries
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      if (numBytes == 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
        utils.checkAlignment(address, 4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
        utils.checkAlignment(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    byte[] data = readBytes(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    return utils.dataToCInteger(data, isUnsigned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  // Overridden from DebuggerBase because we need to relax alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // constraints on x86
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  public long readJLong(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    // FIXME: allow this to be configurable. Undesirable to add a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    // dependency on the runtime package here, though, since this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    // package should be strictly underneath it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    if (unalignedAccessesOkay) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
      utils.checkAlignment(address, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
      utils.checkAlignment(address, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
    byte[] data = readBytes(address, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    return utils.dataToJLong(data, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  //--------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // Implementation of JVMDebugger interface
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  /** Unimplemented in this class (remote remoteDebugger should already be configured) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
                                              long jbyteSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
                                              long jcharSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
                                              long jdoubleSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
                                              long jfloatSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
                                              long jintSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
                                              long jlongSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
                                              long jshortSize) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    throw new DebuggerException("Should not be called on RemoteDebuggerClient");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  public void setMachineDescription(MachineDescription machDesc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    throw new DebuggerException("Should not be called on RemoteDebuggerClient");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  public int getRemoteProcessAddressSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
    throw new DebuggerException("Should not be called on RemoteDebuggerClient");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  public String addressValueToString(long addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    return utils.addressValueToString(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  public long getAddressValue(Address addr) throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
    if (addr == null) return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    return ((RemoteAddress) addr).getValue();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  public Address newAddress(long value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
    if (value == 0) return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
    return new RemoteAddress(this, value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  RemoteAddress readAddress(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    long value = readAddressValue(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    return (value == 0 ? null : new RemoteAddress(this, value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   304
  RemoteAddress readCompOopAddress(long address)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   305
    throws UnmappedAddressException, UnalignedAddressException {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   306
    long value = readCompOopAddressValue(address);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   307
    return (value == 0 ? null : new RemoteAddress(this, value));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   308
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   309
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  RemoteOopHandle readOopHandle(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    long value = readAddressValue(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    return (value == 0 ? null : new RemoteOopHandle(this, value));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   316
  RemoteOopHandle readCompOopHandle(long address)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   317
    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   318
    long value = readCompOopAddressValue(address);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   319
    return (value == 0 ? null : new RemoteOopHandle(this, value));
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   320
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   321
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  boolean areThreadsEqual(Address addr1, Address addr2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
       return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
                                             getAddressValue(addr2), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
    } catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  boolean areThreadsEqual(long id1, long id2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
       return remoteDebugger.areThreadsEqual(id1, false, id2, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
    } catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  boolean areThreadsEqual(Address addr1, long id2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
       return remoteDebugger.areThreadsEqual(getAddressValue(addr1), true, id2, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    } catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  boolean areThreadsEqual(long id1, Address addr2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
       return remoteDebugger.areThreadsEqual(id1, false, getAddressValue(addr2), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    } catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  int getThreadHashCode(Address a) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
       return remoteDebugger.getThreadHashCode(getAddressValue(a), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
    } catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    return a.hashCode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  int getThreadHashCode(long id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
       return remoteDebugger.getThreadHashCode(id, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    } catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    return (int) id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  public ThreadProxy getThreadForIdentifierAddress(Address addr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
     return threadFactory.createThreadWrapper(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  public ThreadProxy getThreadForThreadId(long id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
     return threadFactory.createThreadWrapper(id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  public MachineDescription getMachineDescription() throws DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
     return machDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  /** This reads bytes from the remote process. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  public ReadResult readBytesFromProcess(long address, long numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
      return remoteDebugger.readBytesFromProcess(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
    catch (RemoteException e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
      throw new DebuggerException(e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  public void writeBytesToProcess(long a, long b, byte[] c) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
     throw new DebuggerException("Unimplemented!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
}