< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/debugger/DebuggerBase.java

Print this page

  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 package sun.jvm.hotspot.debugger;
 26 



 27 /** <P> DebuggerBase is a recommended base class for debugger
 28     implementations. It can use a PageCache to cache data from the
 29     target process. Note that this class would not be suitable if the
 30     system were used to reflect upon itself; it would never be safe to
 31     store the value in an OopHandle in anything but an OopHandle.
 32     However, it provides a fair amount of code sharing to the current
 33     dbx and win32 implementations. </P>
 34 
 35     <P> NOTE that much of the code sharing is achieved by having this
 36     class implement many of the methods in the Win32Debugger and
 37     DbxDebugger interfaces. </P> */
 38 
 39 public abstract class DebuggerBase implements Debugger {
 40 
 41   // May be set lazily, but must be set before calling any of the read
 42   // routines below
 43   protected MachineDescription machDesc;
 44   protected DebuggerUtilities utils;
 45   // Java primitive type sizes, set during bootstrapping. Do not call
 46   // any of the Java read routines until these are set up.

457     writeBytes(address, numBytes, data);
458   }
459 
460   protected long readAddressValue(long address)
461     throws UnmappedAddressException, UnalignedAddressException {
462     return readCInteger(address, machDesc.getAddressSize(), true);
463   }
464 
465   protected long readCompOopAddressValue(long address)
466     throws UnmappedAddressException, UnalignedAddressException {
467     long value = readCInteger(address, getHeapOopSize(), true);
468     if (value != 0) {
469       // See oop.inline.hpp decode_heap_oop
470       value = (long)(narrowOopBase + (long)(value << narrowOopShift));
471     }
472     return value;
473   }
474 
475   protected long readCompKlassAddressValue(long address)
476     throws UnmappedAddressException, UnalignedAddressException {
477     long value = readCInteger(address, getKlassPtrSize(), true);








478     if (value != 0) {
479       value = (long)(narrowKlassBase + (long)(value << narrowKlassShift));
480     }
481     return value;
482   }
483 
484   protected void writeAddressValue(long address, long value)
485     throws UnmappedAddressException, UnalignedAddressException {
486     writeCInteger(address, machDesc.getAddressSize(), value);
487   }
488 
489   /** Can be called by subclasses but can not be overridden */
490   protected final void checkConfigured() {
491     if (machDesc == null) {
492       throw new RuntimeException("MachineDescription must have been set by this point");
493     }
494     if (utils == null) {
495       throw new RuntimeException("DebuggerUtilities must have been set by this point");
496     }
497   }

  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 package sun.jvm.hotspot.debugger;
 26 
 27 import sun.jvm.hotspot.oops.Mark;
 28 import sun.jvm.hotspot.runtime.VM;
 29 
 30 /** <P> DebuggerBase is a recommended base class for debugger
 31     implementations. It can use a PageCache to cache data from the
 32     target process. Note that this class would not be suitable if the
 33     system were used to reflect upon itself; it would never be safe to
 34     store the value in an OopHandle in anything but an OopHandle.
 35     However, it provides a fair amount of code sharing to the current
 36     dbx and win32 implementations. </P>
 37 
 38     <P> NOTE that much of the code sharing is achieved by having this
 39     class implement many of the methods in the Win32Debugger and
 40     DbxDebugger interfaces. </P> */
 41 
 42 public abstract class DebuggerBase implements Debugger {
 43 
 44   // May be set lazily, but must be set before calling any of the read
 45   // routines below
 46   protected MachineDescription machDesc;
 47   protected DebuggerUtilities utils;
 48   // Java primitive type sizes, set during bootstrapping. Do not call
 49   // any of the Java read routines until these are set up.

460     writeBytes(address, numBytes, data);
461   }
462 
463   protected long readAddressValue(long address)
464     throws UnmappedAddressException, UnalignedAddressException {
465     return readCInteger(address, machDesc.getAddressSize(), true);
466   }
467 
468   protected long readCompOopAddressValue(long address)
469     throws UnmappedAddressException, UnalignedAddressException {
470     long value = readCInteger(address, getHeapOopSize(), true);
471     if (value != 0) {
472       // See oop.inline.hpp decode_heap_oop
473       value = (long)(narrowOopBase + (long)(value << narrowOopShift));
474     }
475     return value;
476   }
477 
478   protected long readCompKlassAddressValue(long address)
479     throws UnmappedAddressException, UnalignedAddressException {
480     long value;
481     if (VM.getVM().isCompactObjectHeadersEnabled()) {
482       // On 64 bit systems, the compressed Klass* is currently read from the mark
483       // word. We need to load the whole mark, and shift the upper parts.
484       value = readCInteger(address, machDesc.getAddressSize(), true);
485       value = value >>> Mark.getKlassShift();
486     } else {
487       value = readCInteger(address, getKlassPtrSize(), true);
488     }
489     if (value != 0) {
490       value = (long)(narrowKlassBase + (long)(value << narrowKlassShift));
491     }
492     return value;
493   }
494 
495   protected void writeAddressValue(long address, long value)
496     throws UnmappedAddressException, UnalignedAddressException {
497     writeCInteger(address, machDesc.getAddressSize(), value);
498   }
499 
500   /** Can be called by subclasses but can not be overridden */
501   protected final void checkConfigured() {
502     if (machDesc == null) {
503       throw new RuntimeException("MachineDescription must have been set by this point");
504     }
505     if (utils == null) {
506       throw new RuntimeException("DebuggerUtilities must have been set by this point");
507     }
508   }
< prev index next >