src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java
author jjg
Mon, 20 May 2019 10:57:57 -0700
changeset 54950 46ae54c3026d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8223663: Update links for tool guides Reviewed-by: alanb, erikj, darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
     2
 * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
package sun.jvm.hotspot.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.
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
    61
  // class metadata space
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
    62
  protected long klassPtrSize;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
    63
  protected long narrowKlassBase;  // heap base for compressed klass ptrs.
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
    64
  protected int  narrowKlassShift; // shift to decode compressed klass ptrs.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // Should be initialized if desired by calling initCache()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  private PageCache cache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // State for faster accessors that don't allocate memory on each read
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  private boolean useFastAccessors;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  private boolean bigEndian;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // Page-fetching functionality for LRU cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  class Fetcher implements PageFetcher {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    public Page fetchPage(long pageBaseAddress, long numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
      // This assumes that if any byte is unmapped, that the entire
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
      // page is. The common case, however, is that the page is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      // mapped, so we always fetch the entire thing all at once to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      // avoid two round-trip communications per page fetch, even
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
      // though fetching of unmapped pages will be slow.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
      ReadResult res = readBytesFromProcess(pageBaseAddress, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
      if (res.getData() == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
        return new Page(pageBaseAddress, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
      return new Page(pageBaseAddress, res.getData());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  protected DebuggerBase() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  /** From the JVMDebugger interface. This is the only public method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      of this class. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  public void configureJavaPrimitiveTypeSizes(long jbooleanSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
                                              long jbyteSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
                                              long jcharSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
                                              long jdoubleSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
                                              long jfloatSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                                              long jintSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
                                              long jlongSize,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
                                              long jshortSize) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    this.jbooleanSize = jbooleanSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    this.jbyteSize = jbyteSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    this.jcharSize = jcharSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    this.jdoubleSize = jdoubleSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    this.jfloatSize = jfloatSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    this.jintSize = jintSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    this.jlongSize = jlongSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    this.jshortSize = jshortSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    if (jbooleanSize < 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
      throw new RuntimeException("jboolean 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 (jbyteSize < 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
      throw new RuntimeException("jbyte 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 (jcharSize < 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      throw new RuntimeException("jchar 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 (jdoubleSize < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      throw new RuntimeException("jdouble 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 (jfloatSize < 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
      throw new RuntimeException("jfloat 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 (jintSize < 4) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      throw new RuntimeException("jint 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 (jlongSize < 8) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      throw new RuntimeException("jlong 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 (jshortSize < 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
      throw new RuntimeException("jshort size is too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
    if (jintSize != jfloatSize) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      // If dataToJFloat were rewritten, this wouldn't be necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      throw new RuntimeException("jint size and jfloat size must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    if (jlongSize != jdoubleSize) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
      // If dataToJDouble were rewritten, this wouldn't be necessary
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      throw new RuntimeException("jlong size and jdouble size must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    useFastAccessors =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
      ((cache != null) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
       (jbooleanSize == 1) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
       (jbyteSize    == 1) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
       (jcharSize    == 2) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
       (jdoubleSize  == 8) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
       (jfloatSize   == 4) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
       (jintSize     == 4) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
       (jlongSize    == 8) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
       (jshortSize   == 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    javaPrimitiveTypesConfigured = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   166
  public void putHeapConst(long heapOopSize, long klassPtrSize, long narrowOopBase, int narrowOopShift,
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   167
                           long narrowKlassBase, int narrowKlassShift) {
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   168
    this.heapOopSize = heapOopSize;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   169
    this.klassPtrSize = klassPtrSize;
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   170
    this.narrowOopBase = narrowOopBase;
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   171
    this.narrowOopShift = narrowOopShift;
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   172
    this.narrowKlassBase = narrowKlassBase;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   173
    this.narrowKlassShift = narrowKlassShift;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   174
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   175
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  /** May be called by subclasses if desired to initialize the page
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
      cache but may not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  protected final void initCache(long pageSize, long maxNumPages) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    cache = new PageCache(pageSize, maxNumPages, new Fetcher());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    if (machDesc != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
      bigEndian = machDesc.isBigEndian();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  /** May be called by subclasses if needed (if the machine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
      description is not available at the time of cache
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
      initialization, as on Solaris) but may not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  protected final void setBigEndian(boolean bigEndian) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    this.bigEndian = bigEndian;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  /** May be called by subclasses to clear out the cache but may not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
      be overridden. For convenience, this can be called even if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
      cache has not been initialized. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  protected final void clearCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
      cache.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  /** May be called by subclasses to disable the cache (for example,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
      when the target process has been resumed) but may not be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      overridden. For convenience, this can be called even if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
      cache has not been initialized. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  protected final void disableCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
      cache.disable();
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
  /** May be called by subclasses to re-enable the cache (for example,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
      when the target process has been suspended) but may not be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
      overridden. For convenience, this can be called even if the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
      cache has not been initialized. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  protected final void enableCache() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      cache.enable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  /** May be called by subclasses directly but may not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  protected final byte[] readBytes(long address, long numBytes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    throws UnmappedAddressException, DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
      return cache.getData(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
      ReadResult res = readBytesFromProcess(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
      if (res.getData() != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
        return res.getData();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
      throw new UnmappedAddressException(res.getFailureAddress());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  /** May be called by subclasses directly but may not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  protected final void writeBytes(long address, long numBytes, byte[] data)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
    throws UnmappedAddressException, DebuggerException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    if (cache != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      cache.clear(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
    writeBytesToProcess(address, numBytes, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  public boolean readJBoolean(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    utils.checkAlignment(address, jbooleanSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
      return (cache.getByte(address) != 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
      byte[] data = readBytes(address, jbooleanSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
      return utils.dataToJBoolean(data, jbooleanSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  public byte readJByte(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    utils.checkAlignment(address, jbyteSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
      return cache.getByte(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
      byte[] data = readBytes(address, jbyteSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
      return utils.dataToJByte(data, jbyteSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  public char readJChar(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    utils.checkAlignment(address, jcharSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
      return cache.getChar(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
      byte[] data = readBytes(address, jcharSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
      return (char) utils.dataToJChar(data, jcharSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  public double readJDouble(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    utils.checkAlignment(address, jdoubleSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
      return cache.getDouble(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
      byte[] data = readBytes(address, jdoubleSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
      return utils.dataToJDouble(data, jdoubleSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  public float readJFloat(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
    utils.checkAlignment(address, jfloatSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
      return cache.getFloat(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      byte[] data = readBytes(address, jfloatSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
      return utils.dataToJFloat(data, jfloatSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  public int readJInt(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
    utils.checkAlignment(address, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
      return cache.getInt(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
      byte[] data = readBytes(address, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
      return utils.dataToJInt(data, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  public long readJLong(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    utils.checkAlignment(address, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
      return cache.getLong(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
      byte[] data = readBytes(address, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      return utils.dataToJLong(data, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  public short readJShort(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
    utils.checkAlignment(address, jshortSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
      return cache.getShort(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
      byte[] data = readBytes(address, jshortSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
      return utils.dataToJShort(data, jshortSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  // NOTE: assumes value does not span pages (may be bad assumption on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  // Solaris/x86; see unalignedAccessesOkay in DbxDebugger hierarchy)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  public long readCInteger(long address, long numBytes, boolean isUnsigned)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    checkConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    utils.checkAlignment(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
    if (useFastAccessors) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
      if (isUnsigned) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
        switch((int) numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
        case 1: return cache.getByte(address) & 0xFF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
        case 2: return cache.getShort(address, bigEndian) & 0xFFFF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
        case 4: return cache.getInt(address, bigEndian) & 0xFFFFFFFFL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        case 8: return cache.getLong(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
        default: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
          byte[] data = readBytes(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
          return utils.dataToCInteger(data, isUnsigned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
        switch((int) numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
        case 1: return cache.getByte(address);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
        case 2: return cache.getShort(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
        case 4: return cache.getInt(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
        case 8: return cache.getLong(address, bigEndian);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
        default: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
          byte[] data = readBytes(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
          return utils.dataToCInteger(data, isUnsigned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
      byte[] data = readBytes(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
      return utils.dataToCInteger(data, isUnsigned);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    }
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 writeJBoolean(long address, boolean 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, jbooleanSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
    byte[] data = utils.jbooleanToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
    writeBytes(address, jbooleanSize, 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 writeJByte(long address, byte 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, jbyteSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
    byte[] data = utils.jbyteToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
    writeBytes(address, jbyteSize, 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 writeJChar(long address, char 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, jcharSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
    byte[] data = utils.jcharToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    writeBytes(address, jcharSize, 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 writeJDouble(long address, double 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, jdoubleSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    byte[] data = utils.jdoubleToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    writeBytes(address, jdoubleSize, 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 writeJFloat(long address, float 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, jfloatSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    byte[] data = utils.jfloatToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    writeBytes(address, jfloatSize, 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 writeJInt(long address, int 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, jintSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
    byte[] data = utils.jintToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    writeBytes(address, jintSize, 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 writeJLong(long address, long 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, jlongSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    byte[] data = utils.jlongToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    writeBytes(address, jlongSize, 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 writeJShort(long address, short value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    checkJavaConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
    utils.checkAlignment(address, jshortSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    byte[] data = utils.jshortToData(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
    writeBytes(address, jshortSize, 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
  public void writeCInteger(long address, long numBytes, long value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
    checkConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    utils.checkAlignment(address, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
    byte[] data = utils.cIntegerToData(numBytes, value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
    writeBytes(address, numBytes, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  protected long readAddressValue(long address)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    return readCInteger(address, machDesc.getAddressSize(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   465
  protected long readCompOopAddressValue(long address)
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   466
    throws UnmappedAddressException, UnalignedAddressException {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   467
    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
   468
    if (value != 0) {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   469
      // 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
   470
      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
   471
    }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   472
    return value;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   473
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   474
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   475
  protected long readCompKlassAddressValue(long address)
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   476
    throws UnmappedAddressException, UnalignedAddressException {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   477
    long value = readCInteger(address, getKlassPtrSize(), true);
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   478
    if (value != 0) {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   479
      value = (long)(narrowKlassBase + (long)(value << narrowKlassShift));
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   480
    }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   481
    return value;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   482
  }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   483
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  protected void writeAddressValue(long address, long value)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    throws UnmappedAddressException, UnalignedAddressException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
    writeCInteger(address, machDesc.getAddressSize(), value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  /** Can be called by subclasses but can not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  protected final void checkConfigured() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
    if (machDesc == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
      throw new RuntimeException("MachineDescription must have been set by this point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
    if (utils == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
      throw new RuntimeException("DebuggerUtilities must have been set by this point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  /** Can be called by subclasses but can not be overridden */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  protected final void checkJavaConfigured() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
    checkConfigured();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    if (!javaPrimitiveTypesConfigured) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
      throw new RuntimeException("Java primitive type sizes have not yet been configured");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  /** Possibly override page cache size with user-specified property */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  protected int parseCacheNumPagesProperty(int defaultNum) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    String cacheNumPagesString = System.getProperty("cacheNumPages");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    if (cacheNumPagesString != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
      try {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
        return Integer.parseInt(cacheNumPagesString);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
      } catch (Exception e) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
        System.err.println("Error parsing cacheNumPages property:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
        e.printStackTrace();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    return defaultNum;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  /** Interim solution for allowing subclasses to write bytes to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
      process until we make that functionality available in the basic
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
      Address interface */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  protected void invalidatePageCache(long startAddress, long numBytes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
    cache.clear(startAddress, numBytes);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  public long getJBooleanSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
    return jbooleanSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  public long getJByteSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    return jbyteSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  public long getJCharSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    return jcharSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  public long getJDoubleSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    return jdoubleSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  public long getJFloatSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
    return jfloatSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  public long getJIntSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
    return jintSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  public long getJLongSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    return jlongSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  public long getJShortSize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
    return jshortSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  }
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   560
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   561
  public long getHeapOopSize() {
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   562
    return heapOopSize;
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   563
  }
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   564
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   565
  public long getNarrowOopBase() {
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   566
    return narrowOopBase;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   567
  }
2254
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   568
  public int getNarrowOopShift() {
f13dda645a4b 6791178: Specialize for zero as the compressed oop vm heap base
kvn
parents: 670
diff changeset
   569
    return narrowOopShift;
360
21d113ecbf6a 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 1
diff changeset
   570
  }
13969
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   571
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   572
  public long getKlassPtrSize() {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   573
    return klassPtrSize;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   574
  }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   575
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   576
  public long getNarrowKlassBase() {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   577
    return narrowKlassBase;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   578
  }
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   579
  public int getNarrowKlassShift() {
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   580
    return narrowKlassShift;
d2a189b83b87 7054512: Compress class pointers after perm gen removal
roland
parents: 5547
diff changeset
   581
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
}