hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java
author xdono
Tue, 28 Jul 2009 12:12:40 -0700
changeset 3261 c7d5aae8d3f7
parent 2254 f13dda645a4b
child 5547 f4b087cbb361
permissions -rw-r--r--
6862919: Update copyright year Summary: Update copyright for files that have been modified in 2009, up to 07/09 Reviewed-by: tbell, ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
3261
c7d5aae8d3f7 6862919: Update copyright year
xdono
parents: 2254
diff changeset
     2
 * Copyright 2001-2009 Sun Microsystems, Inc.  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
 *
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;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
/** <P> DebuggerBase is a recommended base class for debugger
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
    implementations. It can use a PageCache to cache data from the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
    target process. Note that this class would not be suitable if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
    system were used to reflect upon itself; it would never be safe to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
    store the value in an OopHandle in anything but an OopHandle.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
    However, it provides a fair amount of code sharing to the current
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
    dbx and win32 implementations. </P>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
    <P> NOTE that much of the code sharing is achieved by having this
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
    class implement many of the methods in the Win32Debugger and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    DbxDebugger interfaces. </P> */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
public abstract class DebuggerBase implements Debugger {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    40
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  // May be set lazily, but must be set before calling any of the read
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  // routines below
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  protected MachineDescription machDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  protected DebuggerUtilities utils;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Java primitive type sizes, set during bootstrapping. Do not call
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // any of the Java read routines until these are set up.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  protected long jbooleanSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  protected long jbyteSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  protected long jcharSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  protected long jdoubleSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  protected long jfloatSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  protected long jintSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  protected long jlongSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  protected long jshortSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  protected boolean javaPrimitiveTypesConfigured;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    56
  // heap data.
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    57
  protected long oopSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
    58
  protected long heapOopSize;
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
    59
  protected long narrowOopBase;  // heap base for compressed oops.
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
    60
  protected int  narrowOopShift; // shift to decode compressed oops.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // Should be initialized if desired by calling initCache()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  private PageCache cache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // State for faster accessors that don't allocate memory on each read
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  private boolean useFastAccessors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  private boolean bigEndian;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // Page-fetching functionality for LRU cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  class Fetcher implements PageFetcher {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    public Page fetchPage(long pageBaseAddress, long numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
      // This assumes that if any byte is unmapped, that the entire
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      // page is. The common case, however, is that the page is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
      // mapped, so we always fetch the entire thing all at once to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
      // avoid two round-trip communications per page fetch, even
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
      // though fetching of unmapped pages will be slow.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
      ReadResult res = readBytesFromProcess(pageBaseAddress, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      if (res.getData() == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
        return new Page(pageBaseAddress, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      return new Page(pageBaseAddress, res.getData());
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
  protected DebuggerBase() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  /** From the JVMDebugger interface. This is the only public method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
      of this class. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
                                              long jbyteSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
                                              long jcharSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
                                              long jdoubleSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
                                              long jfloatSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
                                              long jintSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
                                              long jlongSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
                                              long jshortSize) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    this.jbooleanSize = jbooleanSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    this.jbyteSize = jbyteSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    this.jcharSize = jcharSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    this.jdoubleSize = jdoubleSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    this.jfloatSize = jfloatSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    this.jintSize = jintSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    this.jlongSize = jlongSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    this.jshortSize = jshortSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    if (jbooleanSize < 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
      throw new RuntimeException("jboolean size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    if (jbyteSize < 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
      throw new RuntimeException("jbyte size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    if (jcharSize < 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
      throw new RuntimeException("jchar size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    if (jdoubleSize < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      throw new RuntimeException("jdouble size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    if (jfloatSize < 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      throw new RuntimeException("jfloat size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    if (jintSize < 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      throw new RuntimeException("jint size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    if (jlongSize < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      throw new RuntimeException("jlong size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    if (jshortSize < 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      throw new RuntimeException("jshort size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    if (jintSize != jfloatSize) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      // If dataToJFloat were rewritten, this wouldn't be necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
      throw new RuntimeException("jint size and jfloat size must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    if (jlongSize != jdoubleSize) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      // If dataToJDouble were rewritten, this wouldn't be necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
      throw new RuntimeException("jlong size and jdouble size must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    useFastAccessors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      ((cache != null) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
       (jbooleanSize == 1) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
       (jbyteSize    == 1) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
       (jcharSize    == 2) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
       (jdoubleSize  == 8) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
       (jfloatSize   == 4) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
       (jintSize     == 4) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
       (jlongSize    == 8) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
       (jshortSize   == 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    javaPrimitiveTypesConfigured = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   162
  public void putHeapConst(long heapOopSize, long narrowOopBase, int narrowOopShift) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   163
    this.heapOopSize = heapOopSize;
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   164
    this.narrowOopBase = narrowOopBase;
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   165
    this.narrowOopShift = narrowOopShift;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   166
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   167
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  /** May be called by subclasses if desired to initialize the page
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
      cache but may not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  protected final void initCache(long pageSize, long maxNumPages) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    cache = new PageCache(pageSize, maxNumPages, new Fetcher());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    if (machDesc != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
      bigEndian = machDesc.isBigEndian();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  /** May be called by subclasses if needed (if the machine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
      description is not available at the time of cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
      initialization, as on Solaris) but may not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  protected final void setBigEndian(boolean bigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    this.bigEndian = bigEndian;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  /** May be called by subclasses to clear out the cache but may not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
      be overridden. For convenience, this can be called even if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
      cache has not been initialized. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  protected final void clearCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
      cache.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  /** May be called by subclasses to disable the cache (for example,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
      when the target process has been resumed) but may not be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      overridden. For convenience, this can be called even if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
      cache has not been initialized. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  protected final void disableCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      cache.disable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  /** May be called by subclasses to re-enable the cache (for example,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
      when the target process has been suspended) but may not be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
      overridden. For convenience, this can be called even if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
      cache has not been initialized. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  protected final void enableCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
      cache.enable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  /** May be called by subclasses directly but may not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  protected final byte[] readBytes(long address, long numBytes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    throws UnmappedAddressException, DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      return cache.getData(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
      ReadResult res = readBytesFromProcess(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
      if (res.getData() != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
        return res.getData();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
      throw new UnmappedAddressException(res.getFailureAddress());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  /** May be called by subclasses directly but may not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  protected final void writeBytes(long address, long numBytes, byte[] data)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    throws UnmappedAddressException, DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
      cache.clear(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    writeBytesToProcess(address, numBytes, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  public boolean readJBoolean(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    utils.checkAlignment(address, jbooleanSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      return (cache.getByte(address) != 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
      byte[] data = readBytes(address, jbooleanSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
      return utils.dataToJBoolean(data, jbooleanSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  public byte readJByte(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    utils.checkAlignment(address, jbyteSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
      return cache.getByte(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      byte[] data = readBytes(address, jbyteSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
      return utils.dataToJByte(data, jbyteSize);
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
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  public char readJChar(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    utils.checkAlignment(address, jcharSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
      return cache.getChar(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
      byte[] data = readBytes(address, jcharSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
      return (char) utils.dataToJChar(data, jcharSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  public double readJDouble(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    utils.checkAlignment(address, jdoubleSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
      return cache.getDouble(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
      byte[] data = readBytes(address, jdoubleSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
      return utils.dataToJDouble(data, jdoubleSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  public float readJFloat(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    utils.checkAlignment(address, jfloatSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
      return cache.getFloat(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
      byte[] data = readBytes(address, jfloatSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
      return utils.dataToJFloat(data, jfloatSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  public int readJInt(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    utils.checkAlignment(address, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
      return cache.getInt(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
      byte[] data = readBytes(address, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
      return utils.dataToJInt(data, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  public long readJLong(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    utils.checkAlignment(address, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
      return cache.getLong(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
      byte[] data = readBytes(address, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
      return utils.dataToJLong(data, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  public short readJShort(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    utils.checkAlignment(address, jshortSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
      return cache.getShort(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
      byte[] data = readBytes(address, jshortSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
      return utils.dataToJShort(data, jshortSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  public long readCInteger(long address, long numBytes, boolean isUnsigned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    checkConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    utils.checkAlignment(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
      if (isUnsigned) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
        switch((int) numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
        case 1: return cache.getByte(address) & 0xFF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
        case 2: return cache.getShort(address, bigEndian) & 0xFFFF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
        case 4: return cache.getInt(address, bigEndian) & 0xFFFFFFFFL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
        case 8: return cache.getLong(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
        default: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
          byte[] data = readBytes(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
          return utils.dataToCInteger(data, isUnsigned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
        switch((int) numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        case 1: return cache.getByte(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
        case 2: return cache.getShort(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
        case 4: return cache.getInt(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
        case 8: return cache.getLong(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
        default: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
          byte[] data = readBytes(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
          return utils.dataToCInteger(data, isUnsigned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
      byte[] data = readBytes(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
      return utils.dataToCInteger(data, isUnsigned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  public void writeJBoolean(long address, boolean value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
    utils.checkAlignment(address, jbooleanSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
    byte[] data = utils.jbooleanToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    writeBytes(address, jbooleanSize, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  public void writeJByte(long address, byte value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
    utils.checkAlignment(address, jbyteSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
    byte[] data = utils.jbyteToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
    writeBytes(address, jbyteSize, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  public void writeJChar(long address, char value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
    utils.checkAlignment(address, jcharSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    byte[] data = utils.jcharToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
    writeBytes(address, jcharSize, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  public void writeJDouble(long address, double value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
    utils.checkAlignment(address, jdoubleSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    byte[] data = utils.jdoubleToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    writeBytes(address, jdoubleSize, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  public void writeJFloat(long address, float value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    utils.checkAlignment(address, jfloatSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    byte[] data = utils.jfloatToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    writeBytes(address, jfloatSize, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  public void writeJInt(long address, int value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    utils.checkAlignment(address, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    byte[] data = utils.jintToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    writeBytes(address, jintSize, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  public void writeJLong(long address, long value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    utils.checkAlignment(address, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
    byte[] data = utils.jlongToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    writeBytes(address, jlongSize, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  public void writeJShort(long address, short value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    utils.checkAlignment(address, jshortSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    byte[] data = utils.jshortToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    writeBytes(address, jshortSize, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
  public void writeCInteger(long address, long numBytes, long value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    checkConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    utils.checkAlignment(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    byte[] data = utils.cIntegerToData(numBytes, value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    writeBytes(address, numBytes, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  protected long readAddressValue(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    return readCInteger(address, machDesc.getAddressSize(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   457
  protected long readCompOopAddressValue(long address)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   458
    throws UnmappedAddressException, UnalignedAddressException {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   459
    long value = readCInteger(address, getHeapOopSize(), true);
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   460
    if (value != 0) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   461
      // See oop.inline.hpp decode_heap_oop
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   462
      value = (long)(narrowOopBase + (long)(value << narrowOopShift));
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   463
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   464
    return value;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   465
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   466
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  protected void writeAddressValue(long address, long value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
    writeCInteger(address, machDesc.getAddressSize(), value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  /** Can be called by subclasses but can not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  protected final void checkConfigured() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
    if (machDesc == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
      throw new RuntimeException("MachineDescription must have been set by this point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
    if (utils == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
      throw new RuntimeException("DebuggerUtilities must have been set by this point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  /** Can be called by subclasses but can not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  protected final void checkJavaConfigured() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    checkConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    if (!javaPrimitiveTypesConfigured) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
      throw new RuntimeException("Java primitive type sizes have not yet been configured");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  /** Possibly override page cache size with user-specified property */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  protected int parseCacheNumPagesProperty(int defaultNum) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
    String cacheNumPagesString = System.getProperty("cacheNumPages");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
    if (cacheNumPagesString != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
      try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
        return Integer.parseInt(cacheNumPagesString);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
      } catch (Exception e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
        System.err.println("Error parsing cacheNumPages property:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
        e.printStackTrace();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
    return defaultNum;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  /** Interim solution for allowing subclasses to write bytes to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
      process until we make that functionality available in the basic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      Address interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  protected void invalidatePageCache(long startAddress, long numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
    cache.clear(startAddress, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  public long getJBooleanSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
    return jbooleanSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  public long getJByteSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    return jbyteSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  public long getJCharSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    return jcharSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  public long getJDoubleSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
    return jdoubleSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  public long getJFloatSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
    return jfloatSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  public long getJIntSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
    return jintSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  public long getJLongSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
    return jlongSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  public long getJShortSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
    return jshortSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   543
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   544
  public long getHeapOopSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   545
    return heapOopSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   546
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   547
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   548
  public long getNarrowOopBase() {
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   549
    return narrowOopBase;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   550
  }
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   551
  public int getNarrowOopShift() {
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   552
    return narrowOopShift;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   553
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
}