sa-jdi

h();
      
      connectToImportModule();
      
      return outBuf.toString();
    }
    catch (IOException e)
    {
      detach();
      throw new DebuggerException("Error while executing command on dbx console", e);
    }
  }
  
  public String getConsolePrompt()
    throws DebuggerException
  {
    return "(dbx) ";
  }
  
  public CDebugger getCDebugger()
    throws DebuggerException
  {
    return null;
  }
  
  public synchronized Address lookup(String objectName, String symbol)
  {
    long addr = lookupInProcess(objectName, symbol);
    if (addr == 0L) {
      return null;
    }
    return new DbxAddress(this, addr);
  }
  
  public synchronized OopHandle lookupOop(String objectName, String symbol)
  {
    long addr = lookupInProcess(objectName, symbol);
    if (addr == 0L) {
      return null;
    }
    return new DbxOopHandle(this, addr);
  }
  
  public MachineDescription getMachineDescription()
  {
    return machDesc;
  }
  
  public void setMachineDescription(MachineDescription machDesc)
  {
    this.machDesc = machDesc;
    setBigEndian(machDesc.isBigEndian());
    utils = new DebuggerUtilities(machDesc.getAddressSize(), machDesc.isBigEndian());
  }
  
  public int getRemoteProcessAddressSize()
  {
    if (dbxProcess == null) {
      throw new RuntimeException("Not attached to remote process");
    }
    try
    {
      printlnToOutput("address_size");
      return in.parseInt();
    }
    catch (IOException e) {}
    return -1;
  }
  
  public ThreadProxy getThreadForIdentifierAddress(Address addr)
  {
    return threadFactory.createThreadWrapper(addr);
  }
  
  public ThreadProxy getThreadForThreadId(long id)
  {
    return threadFactory.createThreadWrapper(id);
  }
  
  public long readJLong(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    if (unalignedAccessesOkay) {
      utils.checkAlignment(address, jintSize);
    } else {
      utils.checkAlignment(address, jlongSize);
    }
    byte[] data = readBytes(address, jlongSize);
    return utils.dataToJLong(data, jlongSize);
  }
  
  public String addressValueToString(long address)
  {
    return utils.addressValueToString(address);
  }
  
  public long readCInteger(long address, long numBytes, boolean isUnsigned)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkConfigured();
    if (!unalignedAccessesOkay) {
      utils.checkAlignment(address, numBytes);
    } else if (numBytes == 8L) {
      utils.checkAlignment(address, 4L);
    } else {
      utils.checkAlignment(address, numBytes);
    }
    byte[] data = readBytes(address, numBytes);
    return utils.dataToCInteger(data, isUnsigned);
  }
  
  public DbxAddress readAddress(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    long value = readAddressValue(address);
    return value == 0L ? null : new DbxAddress(this, value);
  }
  
  public DbxAddress readCompOopAddress(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    long value = readCompOopAddressValue(address);
    return value == 0L ? null : new DbxAddress(this, value);
  }
  
  public DbxOopHandle readOopHandle(long address)
    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException
  {
    long value = readAddressValue(address);
    return value == 0L ? null : new DbxOopHandle(this, value);
  }
  
  public DbxOopHandle readCompOopHandle(long address)
    throws UnmappedAddressException, UnalignedAddressException, NotInHeapException
  {
    long value = readCompOopAddressValue(address);
    return value == 0L ? null : new DbxOopHandle(this, value);
  }
  
  public synchronized long[] getThreadIntegerRegisterSet(int tid)
  {
    try
    {
      printlnToOutput("thr_gregs " + tid);
      int num = in.parseInt();
      long[] res = new long[num];
      for (int i = 0; i < num; i++) {
        res[i] = in.parseAddress();
      }
      return res;
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return null;
  }
  
  public long getAddressValue(Address addr)
  {
    if (addr == null) {
      return 0L;
    }
    return ((DbxAddress)addr).getValue();
  }
  
  public Address newAddress(long value)
  {
    if (value == 0L) {
      return null;
    }
    return new DbxAddress(this, value);
  }
  
  private void launchProcess()
    throws IOException
  {
    dbxProcess = Runtime.getRuntime().exec(dbxPathName);
    
    dbxOutStreamMonitor = new StreamMonitor(dbxProcess.getInputStream(), "dbx stdout", true);
    dbxErrStreamMonitor = new StreamMonitor(dbxProcess.getErrorStream(), "dbx stderr", true);
  }
  
  private void importDbxModule()
    throws DebuggerException
  {
    dbxOutStreamMonitor.addTrigger("Defining svc_agent_run", 102);
    for (int i = 0; i < dbxSvcAgentDSOPathNames.length; i++)
    {
      dbxOstr.println("import " + dbxSvcAgentDSOPathNames[i]);
      dbxOstr.println("kprint -u2 \\(Ready\\)");
      boolean seen = dbxErrStreamMonitor.waitFor("(Ready)", 60000L);
      if (!seen)
      {
        detach();
        throw new DebuggerException("Timed out while importing dbx module from file\n" + dbxSvcAgentDSOPathNames[i]);
      }
      List retVals = dbxErrStreamMonitor.getTriggersSeen();
      if (retVals.contains(new Integer(101)))
      {
        detach();
        throw new DebuggerException("Unable to find the Serviceability Agent's dbx import module at pathname \"" + dbxSvcAgentDSOPathNames[i] + "\"");
      }
      retVals = dbxOutStreamMonitor.getTriggersSeen();
      if (retVals.contains(new Integer(102)))
      {
        System.out.println("importDbxModule: imported " + dbxSvcAgentDSOPathNames[i]);
        return;
      }
    }
    detach();
    String errMsg = "Unable to find a version of the Serviceability Agent's dbx import module\nmatching the architecture of dbx at any of the following locations:";
    for (int i = 0; i < dbxSvcAgentDSOPathNames.length; i++) {
      errMsg = errMsg + "\n" + dbxSvcAgentDSOPathNames[i];
    }
    throw new DebuggerException(errMsg);
  }
  
  private void shutdown()
  {
    if (dbxProcess != null) {
      try
      {
        dbxProcess.exitValue();
      }
      catch (IllegalThreadStateException e)
      {
        dbxProcess.destroy();
      }
    }
    try
    {
      if (importModuleSocket != null) {
        importModuleSocket.close();
      }
    }
    catch (IOException e) {}
    clear();
    clearCache();
  }
  
  synchronized long lookupInProcess(String objectName, String symbol)
  {
    try
    {
      printlnToOutput("lookup " + objectName + " " + symbol);
      return in.parseAddress();
    }
    catch (Exception e) {}
    return 0L;
  }
  
  public synchronized ReadResult readBytesFromProcess(long address, long numBytes)
    throws DebuggerException
  {
    if (numBytes < 0L) {
      throw new DebuggerException("Can not read negative number (" + numBytes + ") of bytes from process");
    }
    try
    {
      String cmd = "peek " + utils.addressValueToString(address) + " " + numBytes;
      printlnToOutput(cmd);
      while (in.readByte() != 66) {}
      byte res = in.readByte();
      if (res == 0)
      {
        System.err.println("Failing command: " + cmd);
        throw new DebuggerException("Read of remote process address space failed");
      }
      byte[] buf = new byte[(int)numBytes];
      boolean bailOut = false;
      long failureAddress = 0L;
      int numReads = 0;
      while (numBytes > 0L)
      {
        long len = in.readUnsignedInt();
        boolean isMapped = in.readByte() != 0;
        if (!isMapped)
        {
          if (!bailOut)
          {
            bailOut = true;
            failureAddress = address;
          }
        }
        else {
          in.readBytes(buf, 0, (int)len);
        }
        numBytes -= len;
        address += len;
        numReads++;
      }
      if (Assert.ASSERTS_ENABLED) {
        Assert.that(numBytes == 0L, "Bug in debug server's implementation of peek: numBytesLeft == " + numBytes + ", should be 0 (did " + numReads + " reads)");
      }
      if (bailOut) {
        return new ReadResult(failureAddress);
      }
      return new ReadResult(buf);
    }
    catch (IOException e)
    {
      throw new DebuggerException(e);
    }
  }
  
  public void writeBytesToProcess(long address, long numBytes, byte[] data)
    throws UnmappedAddressException, DebuggerException
  {
    throw new DebuggerException("Unimplemented");
  }
  
  ReadResult readBytesFromProcessInternal(long address, long numBytes)
    throws DebuggerException
  {
    return readBytesFromProcess(address, numBytes);
  }
  
  private void printlnToOutput(String s)
    throws IOException
  {
    out.println(s);
    if (out.checkError()) {
      throw new IOException("Error occurred while writing to debug server");
    }
  }
  
  private void clear()
  {
    dbxProcess = null;
    dbxOstr = null;
    out = null;
    in = null;
    importModuleSocket = null;
  }
  
  private void connectToImportModule()
    throws IOException
  {
    importModuleSocket = null;
    long endTime = System.currentTimeMillis() + 60000L;
    while ((importModuleSocket == null) && (System.currentTimeMillis() < endTime)) {
      try
      {
        importModuleSocket = new Socket(InetAddress.getLocalHost(), 21928);
        importModuleSocket.setTcpNoDelay(true);
      }
      catch (IOException e)
      {
        try
        {
          Thread.sleep(1000L);
        }
        catch (InterruptedException ex) {}
      }
    }
    if (importModuleSocket == null)
    {
      detach();
      throw new DebuggerException("Timed out while attempting to connect to remote dbx process");
    }
    out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(importModuleSocket.getOutputStream(), "US-ASCII")), true);
    in = new InputLexer(new BufferedInputStream(importModuleSocket.getInputStream()));
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.dbx.DbxDebuggerLocal
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.dbx;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.OopHandle;

class DbxOopHandle
  extends DbxAddress
  implements OopHandle
{
  DbxOopHandle(DbxDebugger debugger, long addr)
  {
    super(debugger, addr);
  }
  
  public Address addOffsetTo(long offset)
    throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("addOffsetTo not applicable to OopHandles (interior object pointers not allowed)");
  }
  
  public Address andWithMask(long mask)
    throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("andWithMask not applicable to OopHandles (i.e., anything but C addresses)");
  }
  
  public Address orWithMask(long mask)
    throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("orWithMask not applicable to OopHandles (i.e., anything but C addresses)");
  }
  
  public Address xorWithMask(long mask)
    throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("xorWithMask not applicable to OopHandles (i.e., anything but C addresses)");
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.dbx.DbxOopHandle
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.dbx;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.ThreadProxy;

public abstract interface DbxThreadFactory
{
  public abstract ThreadProxy createThreadWrapper(Address paramAddress);
  
  public abstract ThreadProxy createThreadWrapper(long paramLong);
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.dbx.DbxThreadFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.dbx.sparc;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.DebuggerException;
import sun.jvm.hotspot.debugger.ThreadContext;
import sun.jvm.hotspot.debugger.ThreadProxy;
import sun.jvm.hotspot.debugger.dbx.DbxDebugger;
import sun.jvm.hotspot.utilities.Assert;

public class DbxSPARCThread
  implements ThreadProxy
{
  private DbxDebugger debugger;
  private int id;
  
  public DbxSPARCThread(DbxDebugger debugger, Address addr)
  {
    this.debugger = debugger;
    
    id = ((int)addr.getCIntegerAt(0L, 4L, true));
  }
  
  public DbxSPARCThread(DbxDebugger debugger, long id)
  {
    this.debugger = debugger;
    this.id = ((int)id);
  }
  
  public boolean equals(Object obj)
  {
    if ((obj == null) || (!(obj instanceof DbxSPARCThread))) {
      return false;
    }
    return id == id;
  }
  
  public int hashCode()
  {
    return id;
  }
  
  public ThreadContext getContext()
    throws IllegalThreadStateException
  {
    DbxSPARCThreadContext context = new DbxSPARCThreadContext(debugger);
    long[] regs = debugger.getThreadIntegerRegisterSet(id);
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(regs.length == 38, "size of register set must match");
    }
    for (int i = 0; i < regs.length; i++) {
      context.setRegister(i, regs[i]);
    }
    return context;
  }
  
  public boolean canSetContext()
    throws DebuggerException
  {
    return false;
  }
  
  public void setContext(ThreadContext context)
    throws IllegalThreadStateException, DebuggerException
  {
    throw new DebuggerException("Unimplemented");
  }
  
  public String toString()
  {
    return "t@" + id;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.dbx.sparc.DbxSPARCThread
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.dbx.sparc;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.dbx.DbxDebugger;
import sun.jvm.hotspot.debugger.sparc.SPARCThreadContext;

public class DbxSPARCThreadContext
  extends SPARCThreadContext
{
  private DbxDebugger debugger;
  
  public DbxSPARCThreadContext(DbxDebugger debugger)
  {
    this.debugger = debugger;
  }
  
  public void setRegisterAsAddress(int index, Address value)
  {
    setRegister(index, debugger.getAddressValue(value));
  }
  
  public Address getRegisterAsAddress(int index)
  {
    return debugger.newAddress(getRegister(index));
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.dbx.sparc.DbxSPARCThreadContext
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.dbx.sparc;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.ThreadProxy;
import sun.jvm.hotspot.debugger.dbx.DbxDebugger;
import sun.jvm.hotspot.debugger.dbx.DbxThreadFactory;

public class DbxSPARCThreadFactory
  implements DbxThreadFactory
{
  private DbxDebugger debugger;
  
  public DbxSPARCThreadFactory(DbxDebugger debugger)
  {
    this.debugger = debugger;
  }
  
  public ThreadProxy createThreadWrapper(Address threadIdentifierAddr)
  {
    return new DbxSPARCThread(debugger, threadIdentifierAddr);
  }
  
  public ThreadProxy createThreadWrapper(long id)
  {
    return new DbxSPARCThread(debugger, id);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.dbx.sparc.DbxSPARCThreadFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.dbx.x86;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.DebuggerException;
import sun.jvm.hotspot.debugger.ThreadContext;
import sun.jvm.hotspot.debugger.ThreadProxy;
import sun.jvm.hotspot.debugger.dbx.DbxDebugger;
import sun.jvm.hotspot.utilities.Assert;

public class DbxX86Thread
  implements ThreadProxy
{
  private DbxDebugger debugger;
  private int id;
  
  public DbxX86Thread(DbxDebugger debugger, Address addr)
  {
    this.debugger = debugger;
    
    id = ((int)addr.getCIntegerAt(0L, 4L, true));
  }
  
  public DbxX86Thread(DbxDebugger debugger, long id)
  {
    this.debugger = debugger;
    this.id = ((int)id);
  }
  
  public boolean equals(Object obj)
  {
    if ((obj == null) || (!(obj instanceof DbxX86Thread))) {
      return false;
    }
    return id == id;
  }
  
  public int hashCode()
  {
    return id;
  }
  
  public ThreadContext getContext()
    throws IllegalThreadStateException
  {
    DbxX86ThreadContext context = new DbxX86ThreadContext(debugger);
    long[] regs = debugger.getThreadIntegerRegisterSet(id);
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(regs.length == 19, "unknown size of register set -- adjust this code");
    }
    for (int i = 0; i < regs.length; i++) {
      context.setRegister(i, regs[i]);
    }
    return context;
  }
  
  public boolean canSetContext()
    throws DebuggerException
  {
    return false;
  }
  
  public void setContext(ThreadContext context)
    throws IllegalThreadStateException, DebuggerException
  {
    throw new DebuggerException("Unimplemented");
  }
  
  public String toString()
  {
    return "t@" + id;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.dbx.x86.DbxX86Thread
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.dbx.x86;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.dbx.DbxDebugger;
import sun.jvm.hotspot.debugger.x86.X86ThreadContext;

public class DbxX86ThreadContext
  extends X86ThreadContext
{
  private DbxDebugger debugger;
  
  public DbxX86ThreadContext(DbxDebugger debugger)
  {
    this.debugger = debugger;
  }
  
  public void setRegisterAsAddress(int index, Address value)
  {
    setRegister(index, debugger.getAddressValue(value));
  }
  
  public Address getRegisterAsAddress(int index)
  {
    return debugger.newAddress(getRegister(index));
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.dbx.x86.DbxX86ThreadContext
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.dbx.x86;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.ThreadProxy;
import sun.jvm.hotspot.debugger.dbx.DbxDebugger;
import sun.jvm.hotspot.debugger.dbx.DbxThreadFactory;

public class DbxX86ThreadFactory
  implements DbxThreadFactory
{
  private DbxDebugger debugger;
  
  public DbxX86ThreadFactory(DbxDebugger debugger)
  {
    this.debugger = debugger;
  }
  
  public ThreadProxy createThreadWrapper(Address threadIdentifierAddr)
  {
    return new DbxX86Thread(debugger, threadIdentifierAddr);
  }
  
  public ThreadProxy createThreadWrapper(long id)
  {
    return new DbxX86Thread(debugger, id);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.dbx.x86.DbxX86ThreadFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger;

import java.util.List;
import sun.jvm.hotspot.debugger.cdbg.CDebugger;

public abstract interface Debugger
  extends SymbolLookup, ThreadAccess
{
  public abstract boolean hasProcessList()
    throws DebuggerException;
  
  public abstract List getProcessList()
    throws DebuggerException;
  
  public abstract void attach(int paramInt)
    throws DebuggerException;
  
  public abstract void attach(String paramString1, String paramString2)
    throws DebuggerException;
  
  public abstract boolean detach()
    throws DebuggerException;
  
  public abstract Address parseAddress(String paramString)
    throws NumberFormatException, DebuggerException;
  
  public abstract long getAddressValue(Address paramAddress)
    throws DebuggerException;
  
  public abstract String getOS()
    throws DebuggerException;
  
  public abstract String getCPU()
    throws DebuggerException;
  
  public abstract MachineDescription getMachineDescription()
    throws DebuggerException;
  
  public abstract boolean hasConsole()
    throws DebuggerException;
  
  public abstract String consoleExecuteCommand(String paramString)
    throws DebuggerException;
  
  public abstract String getConsolePrompt()
    throws DebuggerException;
  
  public abstract CDebugger getCDebugger()
    throws DebuggerException;
  
  public abstract long getJBooleanSize();
  
  public abstract long getJByteSize();
  
  public abstract long getJCharSize();
  
  public abstract long getJDoubleSize();
  
  public abstract long getJFloatSize();
  
  public abstract long getJIntSize();
  
  public abstract long getJLongSize();
  
  public abstract long getJShortSize();
  
  public abstract long getHeapOopSize();
  
  public abstract long getNarrowOopBase();
  
  public abstract int getNarrowOopShift();
  
  public abstract ReadResult readBytesFromProcess(long paramLong1, long paramLong2)
    throws DebuggerException;
  
  public abstract void writeBytesToProcess(long paramLong1, long paramLong2, byte[] paramArrayOfByte)
    throws UnmappedAddressException, DebuggerException;
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.Debugger
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger;

class DebuggerBase$Fetcher
  implements PageFetcher
{
  private final DebuggerBase this$0;
  
  DebuggerBase$Fetcher(DebuggerBase paramDebuggerBase) {}
  
  public Page fetchPage(long pageBaseAddress, long numBytes)
  {
    ReadResult res = this$0.readBytesFromProcess(pageBaseAddress, numBytes);
    if (res.getData() == null) {
      return new Page(pageBaseAddress, numBytes);
    }
    return new Page(pageBaseAddress, res.getData());
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.DebuggerBase.Fetcher
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger;

import java.io.PrintStream;

public abstract class DebuggerBase
  implements Debugger
{
  protected MachineDescription machDesc;
  protected DebuggerUtilities utils;
  protected long jbooleanSize;
  protected long jbyteSize;
  protected long jcharSize;
  protected long jdoubleSize;
  protected long jfloatSize;
  protected long jintSize;
  protected long jlongSize;
  protected long jshortSize;
  protected boolean javaPrimitiveTypesConfigured;
  protected long oopSize;
  protected long heapOopSize;
  protected long narrowOopBase;
  protected int narrowOopShift;
  private PageCache cache;
  private boolean useFastAccessors;
  private boolean bigEndian;
  
  class Fetcher
    implements PageFetcher
  {
    Fetcher() {}
    
    public Page fetchPage(long pageBaseAddress, long numBytes)
    {
      ReadResult res = readBytesFromProcess(pageBaseAddress, numBytes);
      if (res.getData() == null) {
        return new Page(pageBaseAddress, numBytes);
      }
      return new Page(pageBaseAddress, res.getData());
    }
  }
  
  public void configureJavaPrimitiveTypeSizes(long jbooleanSize, long jbyteSize, long jcharSize, long jdoubleSize, long jfloatSize, long jintSize, long jlongSize, long jshortSize)
  {
    this.jbooleanSize = jbooleanSize;
    this.jbyteSize = jbyteSize;
    this.jcharSize = jcharSize;
    this.jdoubleSize = jdoubleSize;
    this.jfloatSize = jfloatSize;
    this.jintSize = jintSize;
    this.jlongSize = jlongSize;
    this.jshortSize = jshortSize;
    if (jbooleanSize < 1L) {
      throw new RuntimeException("jboolean size is too small");
    }
    if (jbyteSize < 1L) {
      throw new RuntimeException("jbyte size is too small");
    }
    if (jcharSize < 2L) {
      throw new RuntimeException("jchar size is too small");
    }
    if (jdoubleSize < 8L) {
      throw new RuntimeException("jdouble size is too small");
    }
    if (jfloatSize < 4L) {
      throw new RuntimeException("jfloat size is too small");
    }
    if (jintSize < 4L) {
      throw new RuntimeException("jint size is too small");
    }
    if (jlongSize < 8L) {
      throw new RuntimeException("jlong size is too small");
    }
    if (jshortSize < 2L) {
      throw new RuntimeException("jshort size is too small");
    }
    if (jintSize != jfloatSize) {
      throw new RuntimeException("jint size and jfloat size must be equal");
    }
    if (jlongSize != jdoubleSize) {
      throw new RuntimeException("jlong size and jdouble size must be equal");
    }
    useFastAccessors = ((cache != null) && (jbooleanSize == 1L) && (jbyteSize == 1L) && (jcharSize == 2L) && (jdoubleSize == 8L) && (jfloatSize == 4L) && (jintSize == 4L) && (jlongSize == 8L) && (jshortSize == 2L));
    
    javaPrimitiveTypesConfigured = true;
  }
  
  public void putHeapConst(long heapOopSize, long narrowOopBase, int narrowOopShift)
  {
    this.heapOopSize = heapOopSize;
    this.narrowOopBase = narrowOopBase;
    this.narrowOopShift = narrowOopShift;
  }
  
  protected final void initCache(long pageSize, long maxNumPages)
  {
    cache = new PageCache(pageSize, maxNumPages, new Fetcher());
    if (machDesc != null) {
      bigEndian = machDesc.isBigEndian();
    }
  }
  
  protected final void setBigEndian(boolean bigEndian)
  {
    this.bigEndian = bigEndian;
  }
  
  protected final void clearCache()
  {
    if (cache != null) {
      cache.clear();
    }
  }
  
  protected final void disableCache()
  {
    if (cache != null) {
      cache.disable();
    }
  }
  
  protected final void enableCache()
  {
    if (cache != null) {
      cache.enable();
    }
  }
  
  protected final byte[] readBytes(long address, long numBytes)
    throws UnmappedAddressException, DebuggerException
  {
    if (cache != null) {
      return cache.getData(address, numBytes);
    }
    ReadResult res = readBytesFromProcess(address, numBytes);
    if (res.getData() != null) {
      return res.getData();
    }
    throw new UnmappedAddressException(res.getFailureAddress());
  }
  
  protected final void writeBytes(long address, long numBytes, byte[] data)
    throws UnmappedAddressException, DebuggerException
  {
    if (cache != null) {
      cache.clear(address, numBytes);
    }
    writeBytesToProcess(address, numBytes, data);
  }
  
  public boolean readJBoolean(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jbooleanSize);
    if (useFastAccessors) {
      return cache.getByte(address) != 0;
    }
    byte[] data = readBytes(address, jbooleanSize);
    return utils.dataToJBoolean(data, jbooleanSize);
  }
  
  public byte readJByte(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jbyteSize);
    if (useFastAccessors) {
      return cache.getByte(address);
    }
    byte[] data = readBytes(address, jbyteSize);
    return utils.dataToJByte(data, jbyteSize);
  }
  
  public char readJChar(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jcharSize);
    if (useFastAccessors) {
      return cache.getChar(address, bigEndian);
    }
    byte[] data = readBytes(address, jcharSize);
    return utils.dataToJChar(data, jcharSize);
  }
  
  public double readJDouble(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jdoubleSize);
    if (useFastAccessors) {
      return cache.getDouble(address, bigEndian);
    }
    byte[] data = readBytes(address, jdoubleSize);
    return utils.dataToJDouble(data, jdoubleSize);
  }
  
  public float readJFloat(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jfloatSize);
    if (useFastAccessors) {
      return cache.getFloat(address, bigEndian);
    }
    byte[] data = readBytes(address, jfloatSize);
    return utils.dataToJFloat(data, jfloatSize);
  }
  
  public int readJInt(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jintSize);
    if (useFastAccessors) {
      return cache.getInt(address, bigEndian);
    }
    byte[] data = readBytes(address, jintSize);
    return utils.dataToJInt(data, jintSize);
  }
  
  public long readJLong(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jlongSize);
    if (useFastAccessors) {
      return cache.getLong(address, bigEndian);
    }
    byte[] data = readBytes(address, jlongSize);
    return utils.dataToJLong(data, jlongSize);
  }
  
  public short readJShort(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jshortSize);
    if (useFastAccessors) {
      return cache.getShort(address, bigEndian);
    }
    byte[] data = readBytes(address, jshortSize);
    return utils.dataToJShort(data, jshortSize);
  }
  
  public long readCInteger(long address, long numBytes, boolean isUnsigned)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkConfigured();
    utils.checkAlignment(address, numBytes);
    if (useFastAccessors)
    {
      if (isUnsigned)
      {
        switch ((int)numBytes)
        {
        case 1: 
          return cache.getByte(address) & 0xFF;
        case 2: 
          return cache.getShort(address, bigEndian) & 0xFFFF;
        case 4: 
          return cache.getInt(address, bigEndian) & 0xFFFFFFFF;
        case 8: 
          return cache.getLong(address, bigEndian);
        }
        byte[] data = readBytes(address, numBytes);
        return utils.dataToCInteger(data, isUnsigned);
      }
      switch ((int)numBytes)
      {
      case 1: 
        return cache.getByte(address);
      case 2: 
        return cache.getShort(address, bigEndian);
      case 4: 
        return cache.getInt(address, bigEndian);
      case 8: 
        return cache.getLong(address, bigEndian);
      }
      byte[] data = readBytes(address, numBytes);
      return utils.dataToCInteger(data, isUnsigned);
    }
    byte[] data = readBytes(address, numBytes);
    return utils.dataToCInteger(data, isUnsigned);
  }
  
  public void writeJBoolean(long address, boolean value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jbooleanSize);
    byte[] data = utils.jbooleanToData(value);
    writeBytes(address, jbooleanSize, data);
  }
  
  public void writeJByte(long address, byte value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jbyteSize);
    byte[] data = utils.jbyteToData(value);
    writeBytes(address, jbyteSize, data);
  }
  
  public void writeJChar(long address, char value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jcharSize);
    byte[] data = utils.jcharToData(value);
    writeBytes(address, jcharSize, data);
  }
  
  public void writeJDouble(long address, double value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jdoubleSize);
    byte[] data = utils.jdoubleToData(value);
    writeBytes(address, jdoubleSize, data);
  }
  
  public void writeJFloat(long address, float value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jfloatSize);
    byte[] data = utils.jfloatToData(value);
    writeBytes(address, jfloatSize, data);
  }
  
  public void writeJInt(long address, int value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jintSize);
    byte[] data = utils.jintToData(value);
    writeBytes(address, jintSize, data);
  }
  
  public void writeJLong(long address, long value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jlongSize);
    byte[] data = utils.jlongToData(value);
    writeBytes(address, jlongSize, data);
  }
  
  public void writeJShort(long address, short value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkJavaConfigured();
    utils.checkAlignment(address, jshortSize);
    byte[] data = utils.jshortToData(value);
    writeBytes(address, jshortSize, data);
  }
  
  public void writeCInteger(long address, long numBytes, long value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    checkConfigured();
    utils.checkAlignment(address, numBytes);
    byte[] data = utils.cIntegerToData(numBytes, value);
    writeBytes(address, numBytes, data);
  }
  
  protected long readAddressValue(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    return readCInteger(address, machDesc.getAddressSize(), true);
  }
  
  protected long readCompOopAddressValue(long address)
    throws UnmappedAddressException, UnalignedAddressException
  {
    long value = readCInteger(address, getHeapOopSize(), true);
    if (value != 0L) {
      value = narrowOopBase + (value << narrowOopShift);
    }
    return value;
  }
  
  protected void writeAddressValue(long address, long value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    writeCInteger(address, machDesc.getAddressSize(), value);
  }
  
  protected final void checkConfigured()
  {
    if (machDesc == null) {
      throw new RuntimeException("MachineDescription must have been set by this point");
    }
    if (utils == null) {
      throw new RuntimeException("DebuggerUtilities must have been set by this point");
    }
  }
  
  protected final void checkJavaConfigured()
  {
    checkConfigured();
    if (!javaPrimitiveTypesConfigured) {
      throw new RuntimeException("Java primitive type sizes have not yet been configured");
    }
  }
  
  protected int parseCacheNumPagesProperty(int defaultNum)
  {
    String cacheNumPagesString = System.getProperty("cacheNumPages");
    if (cacheNumPagesString != null) {
      try
      {
        return Integer.parseInt(cacheNumPagesString);
      }
      catch (Exception e)
      {
        System.err.println("Error parsing cacheNumPages property:");
        e.printStackTrace();
      }
    }
    return defaultNum;
  }
  
  protected void invalidatePageCache(long startAddress, long numBytes)
  {
    cache.clear(startAddress, numBytes);
  }
  
  public long getJBooleanSize()
  {
    return jbooleanSize;
  }
  
  public long getJByteSize()
  {
    return jbyteSize;
  }
  
  public long getJCharSize()
  {
    return jcharSize;
  }
  
  public long getJDoubleSize()
  {
    return jdoubleSize;
  }
  
  public long getJFloatSize()
  {
    return jfloatSize;
  }
  
  public long getJIntSize()
  {
    return jintSize;
  }
  
  public long getJLongSize()
  {
    return jlongSize;
  }
  
  public long getJShortSize()
  {
    return jshortSize;
  }
  
  public long getHeapOopSize()
  {
    return heapOopSize;
  }
  
  public long getNarrowOopBase()
  {
    return narrowOopBase;
  }
  
  public int getNarrowOopShift()
  {
    return narrowOopShift;
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.DebuggerBase
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger;

public class DebuggerException
  extends RuntimeException
{
  public DebuggerException() {}
  
  public DebuggerException(String message)
  {
    super(message);
  }
  
  public DebuggerException(String message, Throwable cause)
  {
    super(message, cause);
  }
  
  public DebuggerException(Throwable cause)
  {
    super(cause);
  }
}

/* Location:
 * Qualified Name:     sun.jvm.hotspot.debugger.DebuggerException
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger;

public class DebuggerUtilities
{
  protected long addressSize;
  protected boolean isBigEndian;
  
  public DebuggerUtilities(long addressSize, boolean isBigEndian)
  {
    this.addressSize = addressSize;
    this.isBigEndian = isBigEndian;
  }
  
  public String addressValueToString(long address)
  {
    StringBuffer buf = new StringBuffer();
    buf.append("0x");
    String val;
    String val;
    if (addressSize == 8L) {
      val = Long.toHexString(address);
    } else {
      val = Integer.toHexString((int)address);
    }
    for (int i = 0; i < 2L * addressSize - val.length(); i++) {
      buf.append('0');
    }
    buf.append(val);
    return buf.toString();
  }
  
  public void checkAlignment(long address, long alignment)
  {
    if (address % alignment != 0L) {
      throw new UnalignedAddressException("Trying to read at address: " + addressValueToString(address) + " with alignment: " + alignment, address);
    }
  }
  
  public long scanAddress(String addrStr)
    throws NumberFormatException
  {
    String s = addrStr.trim();
    if (!s.startsWith("0x")) {
      throw new NumberFormatException(addrStr);
    }
    long l = 0L;
    for (int i = 2; i < s.length(); i++)
    {
      int val = charToNibble(s.charAt(i));
      l <<= 4;
      l |= val;
    }
    return l;
  }
  
  public int charToNibble(char ascii)
    throws NumberFormatException
  {
    if ((ascii >= '0') && (ascii <= '9')) {
      return ascii - '0';
    }
    if ((ascii >= 'A') && (ascii <= 'F')) {
      return '\n' + ascii - 65;
    }
    if ((ascii >= 'a') && (ascii <= 'f')) {
      return '\n' + ascii - 97;
    }
    throw new NumberFormatException(new Character(ascii).toString());
  }
  
  public boolean dataToJBoolean(byte[] data, long jbooleanSize)
  {
    checkDataContents(data, jbooleanSize);
    
    return data[0] != 0;
  }
  
  public byte dataToJByte(byte[] data, long jbyteSize)
  {
    checkDataContents(data, jbyteSize);
    
    return data[0];
  }
  
  public char dataToJChar(byte[] data, long jcharSize)
  {
    checkDataContents(data, jcharSize);
    if (!isBigEndian) {
      byteSwap(data);
    }
    return (char)((data[0] & 0xFF) << 8 | data[1] & 0xFF);
  }
  
  public double dataToJDouble(byte[] data, long jdoubleSize)
  {
    long longBits = dataToJLong(data, jdoubleSize);
    
    return Double.longBitsToDouble(longBits);
  }
  
  public float dataToJFloat(byte[] data, long jfloatSize)
  {
    int intBits = dataToJInt(data, jfloatSize);
    
    return Float.intBitsToFloat(intBits);
  }
  
  public int dataToJInt(byte[] data, long jintSize)
  {
    checkDataContents(data, jintSize);
    if (!isBigEndian) {
      byteSwap(data);
    }
    return (data[0] & 0xFF) << 24 | (data[1] & 0xFF) << 16 | (data[2] & 0xFF) << 8 | data[3] & 0xFF;
  }
  
  public long dataToJLong(byte[] data, long jlongSize)
  {
    checkDataContents(data, jlongSize);
    if (!isBigEndian) {
      byteSwap(data);
    }
    return rawDataToJLong(data);
  }
  
  public short dataToJShort(byte[] data, long jshortSize)
  {
    checkDataContents(data, jshortSize);
    if (!isBigEndian) {
      byteSwap(data);
    }
    return (short)((data[0] & 0xFF) << 8 | data[1] & 0xFF);
  }
  
  public long dataToCInteger(byte[] data, boolean isUnsigned)
  {
    checkDataContents(data, data.length);
    if (!isBigEndian) {
      byteSwap(data);
    }
    if ((data.length < 8) && (!isUnsigned) && ((data[0] & 0x80) != 0))
    {
      byte[] newData = new byte[8];
      for (int i = 0; i < 8; i++) {
        if (7 - i < data.length) {
          newData[i] = data[(i + data.length - 8)];
        } else {
          newData[i] = -1;
        }
      }
      data = newData;
    }
    return rawDataToJLong(data);
  }
  
  public long dataToAddressValue(byte[] data)
  {
    checkDataContents(data, addressSize);
    if (!isBigEndian) {
      byteSwap(data);
    }
    return rawDataToJLong(data);
  }
  
  public byte[] jbooleanToData(boolean value)
  {
    byte[] res = new byte[1];
    res[0] = ((byte)(value ? 1 : 0));
    return res;
  }
  
  public byte[] jbyteToData(byte value)
  {
    byte[] res = new byte[1];
    res[0] = value;
    return res;
  }
  
  public byte[] jcharToData(char value)
  {
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd