sa-jdi

{
      file.seek(offset);
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  long getFilePointer()
    throws ELFException
  {
    try
    {
      return file.getFilePointer();
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  byte readByte()
    throws ELFException
  {
    try
    {
      return file.readByte();
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  int readBytes(byte[] b)
    throws ELFException
  {
    try
    {
      return file.read(b);
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  short readShort()
    throws ELFException
  {
    try
    {
      short val;
      switch (ident[5])
      {
      case 1: 
        val = byteSwap(file.readShort());
        break;
      case 2: 
        val = file.readShort();
        break;
      default: 
        throw new ELFException("Invalid encoding.");
      }
      return val;
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  int readInt()
    throws ELFException
  {
    try
    {
      int val;
      switch (ident[5])
      {
      case 1: 
        val = byteSwap(file.readInt());
        break;
      case 2: 
        val = file.readInt();
        break;
      default: 
        throw new ELFException("Invalid encoding.");
      }
      return val;
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  long readLong()
    throws ELFException
  {
    try
    {
      long val;
      switch (ident[5])
      {
      case 1: 
        val = byteSwap(file.readLong());
        break;
      case 2: 
        val = file.readLong();
        break;
      default: 
        throw new ELFException("Invalid encoding.");
      }
      return val;
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  short byteSwap(short arg)
  {
    return (short)(arg << 8 | arg >>> 8 & 0xFF);
  }
  
  int byteSwap(int arg)
  {
    return byteSwap((short)arg) << 16 | byteSwap((short)(arg >>> 16)) & 0xFFFF;
  }
  
  long byteSwap(long arg)
  {
    return byteSwap((int)arg) << 32 | byteSwap((int)(arg >>> 32)) & 0xFFFFFFFFFFFFFFFF;
  }
  
  short readUnsignedByte()
    throws ELFException
  {
    try
    {
      return unsignedByte(file.readByte());
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  int readUnsignedShort()
    throws ELFException
  {
    try
    {
      int val;
      switch (ident[5])
      {
      case 1: 
        val = unsignedByteSwap(file.readShort());
        break;
      case 2: 
        val = unsignedByte(file.readShort());
        break;
      default: 
        throw new ELFException("Invalid encoding.");
      }
      return val;
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  long readUnsignedInt()
    throws ELFException
  {
    try
    {
      long val;
      switch (ident[5])
      {
      case 1: 
        val = unsignedByteSwap(file.readInt());
        break;
      case 2: 
        val = unsignedByte(file.readInt());
        break;
      default: 
        throw new ELFException("Invalid encoding.");
      }
      return val;
    }
    catch (IOException e)
    {
      throw new ELFException(e);
    }
  }
  
  short unsignedByte(byte arg)
  {
    return (short)(arg & 0xFF);
  }
  
  int unsignedByte(short arg)
  {
    int val;
    int val;
    if (arg >= 0) {
      val = arg;
    } else {
      val = unsignedByte((byte)(arg >>> 8)) << 8 | (byte)arg;
    }
    return val;
  }
  
  long unsignedByte(int arg)
  {
    long val;
    long val;
    if (arg >= 0) {
      val = arg;
    } else {
      val = unsignedByte((short)(arg >>> 16)) << 16 | (short)arg;
    }
    return val;
  }
  
  int unsignedByteSwap(short arg)
  {
    return unsignedByte((byte)arg) << 8 | unsignedByte((byte)(arg >>> 8));
  }
  
  long unsignedByteSwap(int arg)
  {
    return unsignedByteSwap((short)arg) << 16 | unsignedByteSwap((short)(arg >>> 16));
  }
}

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

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.io.RandomAccessFile;
import java.util.Arrays;
import sun.jvm.hotspot.debugger.DataSource;
import sun.jvm.hotspot.debugger.RandomAccessFileDataSource;
import sun.jvm.hotspot.utilities.memo.MemoizedObject;

public class ELFFileParser
{
  private static ELFFileParser elfParser;
  private static final String US_ASCII = "US-ASCII";
  
  public static ELFFileParser getParser()
  {
    if (elfParser == null) {
      elfParser = new ELFFileParser();
    }
    return elfParser;
  }
  
  public ELFFile parse(String filename)
    throws ELFException
  {
    try
    {
      RandomAccessFile file = new RandomAccessFile(filename, "r");
      return parse(new RandomAccessFileDataSource(file));
    }
    catch (FileNotFoundException e)
    {
      throw new ELFException(e);
    }
  }
  
  public ELFFile parse(DataSource source)
    throws ELFException
  {
    return new ELFFileImpl(source);
  }
  
  class ELFFileImpl
    implements ELFFile
  {
    private DataSource file;
    private ELFHeader header;
    private byte[] ident = new byte[16];
    
    ELFFileImpl(DataSource file)
      throws ELFException
    {
      this.file = file;
      int bytesRead = readBytes(ident);
      if (bytesRead != ident.length) {
        throw new ELFException("Error reading elf header (read " + bytesRead + "bytes, expected to " + "read " + ident.length + "bytes).");
      }
      if (!Arrays.equals(getMagicNumber(), ELF_MAGIC_NUMBER)) {
        throw new ELFException("Bad magic number for file.");
      }
      header = new ELFHeaderImpl();
    }
    
    public ELFHeader getHeader()
    {
      return header;
    }
    
    public byte[] getMagicNumber()
    {
      byte[] magicNumber = new byte[4];
      magicNumber[0] = ident[0];
      magicNumber[1] = ident[1];
      magicNumber[2] = ident[2];
      magicNumber[3] = ident[3];
      return magicNumber;
    }
    
    public byte getObjectSize()
    {
      return ident[4];
    }
    
    public byte getEncoding()
    {
      return ident[5];
    }
    
    public byte getVersion()
    {
      return ident[6];
    }
    
    class ELFHeaderImpl
      implements ELFHeader
    {
      private byte[] ident = new byte[16];
      private short file_type;
      private short arch;
      private int version;
      private int entry_point;
      private int ph_offset;
      private int sh_offset;
      private int flags;
      private short eh_size;
      private short ph_entry_size;
      private short num_ph;
      private short sh_entry_size;
      private short num_sh;
      private short sh_string_ndx;
      private MemoizedObject[] sectionHeaders;
      private MemoizedObject[] programHeaders;
      private ELFSectionHeader symbolTableSection;
      private ELFSectionHeader dynamicSymbolTableSection;
      private ELFHashTable hashTable;
      
      ELFHeaderImpl()
        throws ELFException
      {
        file_type = readShort();
        arch = readShort();
        version = readInt();
        entry_point = readInt();
        ph_offset = readInt();
        sh_offset = readInt();
        flags = readInt();
        eh_size = readShort();
        ph_entry_size = readShort();
        num_ph = readShort();
        sh_entry_size = readShort();
        num_sh = readShort();
        sh_string_ndx = readShort();
        
        sectionHeaders = new MemoizedObject[num_sh];
        for (int i = 0; i < num_sh; i++)
        {
          final long sectionHeaderOffset = sh_offset + i * sh_entry_size;
          
          sectionHeaders[i = new MemoizedObject()
          {
            public Object computeValue()
            {
              return new ELFFileParser.ELFFileImpl.ELFSectionHeaderImpl(ELFFileParser.ELFFileImpl.this, sectionHeaderOffset);
            }
          };
        }
      }
      
      public short getFileType()
      {
        return file_type;
      }
      
      public short getArch()
      {
        return arch;
      }
      
      public short getSectionHeaderSize()
      {
        return sh_entry_size;
      }
      
      public short getNumberOfSectionHeaders()
      {
        return num_sh;
      }
      
      public ELFSectionHeader getSectionHeader(int index)
      {
        return (ELFSectionHeader)sectionHeaders[index].getValue();
      }
      
      public ELFStringTable getSectionHeaderStringTable()
      {
        return getSectionHeader(sh_string_ndx).getStringTable();
      }
      
      public ELFStringTable getStringTable()
      {
        return findStringTableWithName(".strtab");
      }
      
      public ELFStringTable getDynamicStringTable()
      {
        return findStringTableWithName(".dynstr");
      }
      
      private ELFStringTable findStringTableWithName(String tableName)
      {
        ELFSectionHeader sh = null;
        for (int i = 1; i < getNumberOfSectionHeaders(); i++)
        {
          sh = getSectionHeader(i);
          if (tableName.equals(sh.getName())) {
            return sh.getStringTable();
          }
        }
        return null;
      }
      
      public ELFHashTable getHashTable()
      {
        return null;
      }
      
      public ELFSectionHeader getSymbolTableSection()
      {
        if (symbolTableSection != null) {
          return symbolTableSection;
        }
        symbolTableSection = getSymbolTableSection(2);
        
        return symbolTableSection;
      }
      
      public ELFSectionHeader getDynamicSymbolTableSection()
      {
        if (dynamicSymbolTableSection != null) {
          return dynamicSymbolTableSection;
        }
        dynamicSymbolTableSection = getSymbolTableSection(11);
        
        return dynamicSymbolTableSection;
      }
      
      private ELFSectionHeader getSymbolTableSection(int type)
      {
        ELFSectionHeader sh = null;
        for (int i = 1; i < getNumberOfSectionHeaders(); i++)
        {
          sh = getSectionHeader(i);
          if (sh.getType() == type)
          {
            dynamicSymbolTableSection = sh;
            return sh;
          }
        }
        return null;
      }
      
      public ELFSymbol getELFSymbol(String symbolName)
      {
        if (symbolName == null) {
          return null;
        }
        ELFSymbol symbol = null;
        int numSymbols = 0;
        ELFSectionHeader sh = getDynamicSymbolTableSection();
        if (sh != null)
        {
          numSymbols = sh.getNumberOfSymbols();
          for (int i = 0; i < Math.ceil(numSymbols / 2); i++)
          {
            if (symbolName.equals((symbol = sh.getELFSymbol(i)).getName())) {
              return symbol;
            }
            if (symbolName.equals((symbol = sh.getELFSymbol(numSymbols - 1 - i)).getName())) {
              return symbol;
            }
          }
        }
        sh = getSymbolTableSection();
        if (sh != null)
        {
          numSymbols = sh.getNumberOfSymbols();
          for (int i = 0; i < Math.ceil(numSymbols / 2); i++)
          {
            if (symbolName.equals((symbol = sh.getELFSymbol(i)).getName())) {
              return symbol;
            }
            if (symbolName.equals((symbol = sh.getELFSymbol(numSymbols - 1 - i)).getName())) {
              return symbol;
            }
          }
        }
        return null;
      }
      
      public ELFSymbol getELFSymbol(long address)
      {
        ELFSymbol symbol = null;
        int numSymbols = 0;
        long value = 0L;
        
        ELFSectionHeader sh = getDynamicSymbolTableSection();
        if (sh != null)
        {
          numSymbols = sh.getNumberOfSymbols();
          for (int i = 0; i < numSymbols; i++)
          {
            symbol = sh.getELFSymbol(i);
            value = symbol.getValue();
            if ((address >= value) && (address < value + symbol.getSize())) {
              return symbol;
            }
          }
        }
        sh = getSymbolTableSection();
        if (sh != null)
        {
          numSymbols = sh.getNumberOfSymbols();
          for (int i = 0; i < numSymbols; i++)
          {
            symbol = sh.getELFSymbol(i);
            value = symbol.getValue();
            if ((address >= value) && (address < value + symbol.getSize())) {
              return symbol;
            }
          }
        }
        return null;
      }
    }
    
    class ELFSectionHeaderImpl
      implements ELFSectionHeader
    {
      private int name_ndx;
      private int type;
      private int flags;
      private int address;
      private int section_offset;
      private int size;
      private int link;
      private int info;
      private int address_alignment;
      private int entry_size;
      private MemoizedObject[] symbols;
      private MemoizedObject stringTable;
      private MemoizedObject hashTable;
      
      ELFSectionHeaderImpl(long offset)
        throws ELFException
      {
        seek(offset);
        name_ndx = readInt();
        type = readInt();
        flags = readInt();
        address = readInt();
        section_offset = readInt();
        size = readInt();
        link = readInt();
        info = readInt();
        address_alignment = readInt();
        entry_size = readInt();
        int num_entries;
        switch (type)
        {
        case 0: 
          break;
        case 1: 
          break;
        case 2: 
        case 11: 
          num_entries = size / entry_size;
          symbols = new MemoizedObject[num_entries];
          for (int i = 0; i < num_entries; i++)
          {
            final int symbolOffset = section_offset + i * entry_size;
            
            symbols[i = new MemoizedObject()
            {
              public Object computeValue()
              {
                return new ELFFileParser.ELFFileImpl.ELFSymbolImpl(ELFFileParser.ELFFileImpl.this, symbolOffset, type);
              }
            };
          }
          break;
        case 3: 
          final int strTableOffset = section_offset;
          final int strTableSize = size;
          stringTable = new MemoizedObject()
          {
            public Object computeValue()
            {
              return new ELFFileParser.ELFFileImpl.ELFStringTableImpl(ELFFileParser.ELFFileImpl.this, strTableOffset, strTableSize);
            }
          };
          break;
        case 4: 
          break;
        case 5: 
          final int hashTableOffset = section_offset;
          final int hashTableSize = size;
          hashTable = new MemoizedObject()
          {
            public Object computeValue()
            {
              return new ELFFileParser.ELFFileImpl.ELFHashTableImpl(ELFFileParser.ELFFileImpl.this, hashTableOffset, hashTableSize);
            }
          };
          break;
        case 6: 
          break;
        case 7: 
          break;
        case 8: 
          break;
        case 9: 
          break;
        case 10: 
          break;
        }
      }
      
      public int getType()
      {
        return type;
      }
      
      public int getNumberOfSymbols()
      {
        if (symbols != null) {
          return symbols.length;
        }
        return 0;
      }
      
      public ELFSymbol getELFSymbol(int index)
      {
        return (ELFSymbol)symbols[index].getValue();
      }
      
      public ELFStringTable getStringTable()
      {
        if (stringTable != null) {
          return (ELFStringTable)stringTable.getValue();
        }
        return null;
      }
      
      public ELFHashTable getHashTable()
      {
        if (hashTable != null) {
          return (ELFHashTable)hashTable.getValue();
        }
        return null;
      }
      
      public String getName()
      {
        if (name_ndx == 0) {
          return null;
        }
        ELFStringTable tbl = getHeader().getSectionHeaderStringTable();
        return tbl.get(name_ndx);
      }
      
      public int getLink()
      {
        return link;
      }
      
      public int getOffset()
      {
        return section_offset;
      }
    }
    
    class ELFSymbolImpl
      implements ELFSymbol
    {
      private int name_ndx;
      private int value;
      private int size;
      private byte info;
      private byte other;
      private short section_header_ndx;
      private int section_type;
      private long offset;
      
      ELFSymbolImpl(long offset, int section_type)
        throws ELFException
      {
        seek(offset);
        this.offset = offset;
        name_ndx = readInt();
        value = readInt();
        size = readInt();
        info = readByte();
        other = readByte();
        section_header_ndx = readShort();
        
        this.section_type = section_type;
        switch (getType())
        {
        case 0: 
          break;
        case 1: 
          break;
        case 2: 
          break;
        case 3: 
          break;
        case 4: 
          break;
        case 13: 
          break;
        case 15: 
          break;
        }
      }
      
      public int getBinding()
      {
        return info >> 4;
      }
      
      public int getType()
      {
        return info & 0xF;
      }
      
      public long getOffset()
      {
        return offset;
      }
      
      public String getName()
      {
        if (name_ndx == 0) {
          return null;
        }
        String symbol_name = null;
        if (section_type == 2) {
          symbol_name = getHeader().getStringTable().get(name_ndx);
        } else if (section_type == 11) {
          symbol_name = getHeader().getDynamicStringTable().get(name_ndx);
        }
        return symbol_name;
      }
      
      public long getValue()
      {
        return value;
      }
      
      public int getSize()
      {
        return size;
      }
    }
    
    class ELFStringTableImpl
      implements ELFStringTable
    {
      private byte[] data;
      private int numStrings;
      
      ELFStringTableImpl(long offset, int length)
        throws ELFException
      {
        seek(offset);
        data = new byte[length];
        int bytesRead = readBytes(data);
        if (bytesRead != length) {
          throw new ELFException("Error reading string table (read " + bytesRead + "bytes, expected to " + "read " + data.length + "bytes).");
        }
        numStrings = 0;
        for (int ptr = 0; ptr < data.length; ptr++) {
          if (data[ptr] == 0) {
            numStrings += 1;
          }
        }
      }
      
      public String get(int index)
      {
        int startPtr = index;
        int endPtr = index;
        while (data[endPtr] != 0) {
          endPtr++;
        }
        return new String(data, startPtr, endPtr - startPtr);
      }
      
      public int getNumStrings()
      {
        return numStrings;
      }
    }
    
    class ELFHashTableImpl
      implements ELFHashTable
    {
      private int num_buckets;
      private int num_chains;
      private int[] buckets;
      private int[] chains;
      
      ELFHashTableImpl(long offset, int length)
        throws ELFException
      {
        seek(offset);
        num_buckets = readInt();
        num_chains = readInt();
        
        buckets = new int[num_buckets];
        chains = new int[num_chains];
        for (int i = 0; i < num_buckets; i++) {
          buckets[i] = readInt();
        }
        for (int i = 0; i < num_chains; i++) {
          chains[i] = readInt();
        }
        int actual = num_buckets * 4 + num_chains * 4 + 8;
        if (length != actual) {
          throw new ELFException("Error reading string table (read " + actual + "bytes, expected to " + "read " + length + "bytes).");
        }
      }
      
      public ELFSymbol getSymbol(String symbolName)
      {
        return null;
      }
    }
    
    public void close()
      throws ELFException
    {
      try
      {
        file.close();
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    void seek(long offset)
      throws ELFException
    {
      try
      {
        file.seek(offset);
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    long getFilePointer()
      throws ELFException
    {
      try
      {
        return file.getFilePointer();
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    byte readByte()
      throws ELFException
    {
      try
      {
        return file.readByte();
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    int readBytes(byte[] b)
      throws ELFException
    {
      try
      {
        return file.read(b);
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    short readShort()
      throws ELFException
    {
      try
      {
        short val;
        switch (ident[5])
        {
        case 1: 
          val = byteSwap(file.readShort());
          break;
        case 2: 
          val = file.readShort();
          break;
        default: 
          throw new ELFException("Invalid encoding.");
        }
        return val;
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    int readInt()
      throws ELFException
    {
      try
      {
        int val;
        switch (ident[5])
        {
        case 1: 
          val = byteSwap(file.readInt());
          break;
        case 2: 
          val = file.readInt();
          break;
        default: 
          throw new ELFException("Invalid encoding.");
        }
        return val;
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    long readLong()
      throws ELFException
    {
      try
      {
        long val;
        switch (ident[5])
        {
        case 1: 
          val = byteSwap(file.readLong());
          break;
        case 2: 
          val = file.readLong();
          break;
        default: 
          throw new ELFException("Invalid encoding.");
        }
        return val;
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    short byteSwap(short arg)
    {
      return (short)(arg << 8 | arg >>> 8 & 0xFF);
    }
    
    int byteSwap(int arg)
    {
      return byteSwap((short)arg) << 16 | byteSwap((short)(arg >>> 16)) & 0xFFFF;
    }
    
    long byteSwap(long arg)
    {
      return byteSwap((int)arg) << 32 | byteSwap((int)(arg >>> 32)) & 0xFFFFFFFFFFFFFFFF;
    }
    
    short readUnsignedByte()
      throws ELFException
    {
      try
      {
        return unsignedByte(file.readByte());
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    int readUnsignedShort()
      throws ELFException
    {
      try
      {
        int val;
        switch (ident[5])
        {
        case 1: 
          val = unsignedByteSwap(file.readShort());
          break;
        case 2: 
          val = unsignedByte(file.readShort());
          break;
        default: 
          throw new ELFException("Invalid encoding.");
        }
        return val;
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    long readUnsignedInt()
      throws ELFException
    {
      try
      {
        long val;
        switch (ident[5])
        {
        case 1: 
          val = unsignedByteSwap(file.readInt());
          break;
        case 2: 
          val = unsignedByte(file.readInt());
          break;
        default: 
          throw new ELFException("Invalid encoding.");
        }
        return val;
      }
      catch (IOException e)
      {
        throw new ELFException(e);
      }
    }
    
    short unsignedByte(byte arg)
    {
      return (short)(arg & 0xFF);
    }
    
    int unsignedByte(short arg)
    {
      int val;
      int val;
      if (arg >= 0) {
        val = arg;
      } else {
        val = unsignedByte((byte)(arg >>> 8)) << 8 | (byte)arg;
      }
      return val;
    }
    
    long unsignedByte(int arg)
    {
      long val;
      long val;
      if (arg >= 0) {
        val = arg;
      } else {
        val = unsignedByte((short)(arg >>> 16)) << 16 | (short)arg;
      }
      return val;
    }
    
    int unsignedByteSwap(short arg)
    {
      return unsignedByte((byte)arg) << 8 | unsignedByte((byte)(arg >>> 8));
    }
    
    long unsignedByteSwap(int arg)
    {
      return unsignedByteSwap((short)arg) << 16 | unsignedByteSwap((short)(arg >>> 16));
    }
  }
  
  public static void main(String[] args)
  {
    if (args.length != 1)
    {
      System.out.println("Usage: java ELFFileParser <elf file>");
      System.exit(0);
    }
    ELFFile elfFile = getParser().parse(args[0]);
    
    ELFHeader elfHeader = elfFile.getHeader();
    System.out.println("ELF File: " + args[0]);
    
    System.out.println("ELF object size: " + (elfFile.getObjectSize() == 1 ? "32-bit" : elfFile.getObjectSize() == 0 ? "Invalid Object Size" : "64-bit"));
    
    System.out.println("ELF data encoding: " + (elfFile.getEncoding() == 1 ? "LSB" : elfFile.getEncoding() == 0 ? "Invalid Data Encoding" : "MSB"));
    
    int h = elfHeader.getNumberOfSectionHeaders();
    System.out.println("--> Start: reading " + h + " section headers.");
    for (int i = 0; i < elfHeader.getNumberOfSectionHeaders(); i++)
    {
      ELFSectionHeader sh = elfHeader.getSectionHeader(i);
      String str = sh.getName();
      System.out.println("----> Start: Section (" + i + ") " + str);
      
      int num = 0;
      if ((num = sh.getNumberOfSymbols()) != 0)
      {
        System.out.println("------> Start: reading " + num + " symbols.");
        ELFSymbol sym;
        for (int j = 0; j < num; j++) {
          sym = sh.getELFSymbol(j);
        }
        System.out.println("<------ End: reading " + num + " symbols.");
      }
      if (sh.getType() == 3)
      {
        System.out.println("------> Start: reading string table.");
        ELFStringTable st = sh.getStringTable();
        System.out.println("<------ End: reading string table.");
      }
      if (sh.getType() == 5)
      {
        System.out.println("------> Start: reading hash table.");
        sh.getHashTable();
        System.out.println("<------ End: reading hash table.");
      }
      System.out.println("<---- End: Section (" + i + ") " + str);
    }
    System.out.println("<-- End: reading " + h + " section headers.");
    
    elfFile.close();
  }
}

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

public abstract interface ELFHashTable
{
  public abstract ELFSymbol getSymbol(String paramString);
}

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

public abstract interface ELFHeader
{
  public static final int FT_NONE = 0;
  public static final int FT_REL = 1;
  public static final int FT_EXEC = 2;
  public static final int FT_DYN = 3;
  public static final int FT_CORE = 4;
  public static final int FT_LOCPROC = 65280;
  public static final int FT_HICPROC = 65535;
  public static final int ARCH_NONE = 0;
  public static final int ARCH_ATT = 1;
  public static final int ARCH_SPARC = 2;
  public static final int ARCH_i386 = 3;
  public static final int ARCH_68k = 4;
  public static final int ARCH_88k = 5;
  public static final int ARCH_i860 = 7;
  public static final int ARCH_MIPS = 8;
  
  public abstract short getFileType();
  
  public abstract short getArch();
  
  public abstract short getSectionHeaderSize();
  
  public abstract short getNumberOfSectionHeaders();
  
  public abstract ELFSectionHeader getSectionHeader(int paramInt);
  
  public abstract ELFStringTable getSectionHeaderStringTable();
  
  public abstract ELFStringTable getStringTable();
  
  public abstract ELFStringTable getDynamicStringTable();
  
  public abstract ELFHashTable getHashTable();
  
  public abstract ELFSectionHeader getSymbolTableSection();
  
  public abstract ELFSectionHeader getDynamicSymbolTableSection();
  
  public abstract ELFSymbol getELFSymbol(String paramString);
  
  public abstract ELFSymbol getELFSymbol(long paramLong);
}

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

public abstract interface ELFProgramHeader
{
  public static final int TYPE_NULL = 0;
  public static final int TYPE_LOAD = 1;
  public static final int TYPE_DYNAMIC = 2;
  public static final int TYPE_INTERP = 3;
  public static final int TYPE_NOTE = 4;
  public static final int TYPE_SHLIB = 5;
  public static final int TYPE_PHDR = 6;
  public static final int TYPE_LOPROC = 1879048192;
  public static final int TYPE_HIPROC = Integer.MAX_VALUE;
  
  public abstract int getType();
}

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

public abstract interface ELFSectionHeader
{
  public static final int NDX_UNDEFINED = 0;
  public static final int NDX_LORESERVE = 65280;
  public static final int NDX_LOPROC = 65280;
  public static final int NDX_HIPROC = 65311;
  public static final int NDX_ABS = 65521;
  public static final int NDX_COMMON = 65522;
  public static final int NDX_HIRESERVE = 65535;
  public static final int TYPE_NULL = 0;
  public static final int TYPE_PROGBITS = 1;
  public static final int TYPE_SYMTBL = 2;
  public static final int TYPE_STRTBL = 3;
  public static final int TYPE_RELO_EXPLICIT = 4;
  public static final int TYPE_HASH = 5;
  public static final int TYPE_DYNAMIC = 6;
  public static final int TYPE_NOTE = 7;
  public static final int TYPE_NOBITS = 8;
  public static final int TYPE_RELO = 9;
  public static final int TYPE_SHLIB = 10;
  public static final int TYPE_DYNSYM = 11;
  public static final int TYPE_LOPROC = 1879048192;
  public static final int TYPE_HIPROC = Integer.MAX_VALUE;
  public static final int TYPE_LOUSER = Integer.MIN_VALUE;
  public static final int TYPE_HIUSER = -1;
  public static final int FLAG_WRITE = 1;
  public static final int FLAG_ALLOC = 2;
  public static final int FLAG_EXEC_INSTR = 4;
  public static final int FLAG_MASK = -268435456;
  public static final String STRING_TABLE_NAME = ".strtab";
  public static final String DYNAMIC_STRING_TABLE_NAME = ".dynstr";
  
  public abstract int getType();
  
  public abstract int getNumberOfSymbols();
  
  public abstract ELFSymbol getELFSymbol(int paramInt);
  
  public abstract ELFStringTable getStringTable();
  
  public abstract ELFHashTable getHashTable();
  
  public abstract int getLink();
  
  public abstract String getName();
  
  public abstract int getOffset();
}

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

public abstract interface ELFStringTable
{
  public abstract String get(int paramInt);
  
  public abstract int getNumStrings();
}

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

public abstract interface ELFSymbol
{
  public static final int BINDING_LOCAL = 0;
  public static final int BINDING_GLOBAL = 1;
  public static final int BINDING_WEAK = 2;
  public static final int BINDING_LOPROC = 13;
  public static final int BINDING_HIPROC = 15;
  public static final byte TYPE_NOOBJECT = 0;
  public static final byte TYPE_OBJECT = 1;
  public static final byte TYPE_FUNCTION = 2;
  public static final byte TYPE_SECTION = 3;
  public static final byte TYPE_FILE = 4;
  public static final byte TYPE_LOPROC = 13;
  public static final byte TYPE_HIPROC = 15;
  
  public abstract long getOffset();
  
  public abstract String getName();
  
  public abstract int getBinding();
  
  public abstract int getType();
  
  public abstract long getValue();
  
  public abstract int getSize();
}

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

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.proc.ProcDebugger;
import sun.jvm.hotspot.utilities.Assert;

public class ProcAMD64Thread
  implements ThreadProxy
{
  private ProcDebugger debugger;
  private int id;
  
  public ProcAMD64Thread(ProcDebugger debugger, Address addr)
  {
    this.debugger = debugger;
    
    id = ((int)addr.getCIntegerAt(0L, 4L, true));
  }
  
  public ProcAMD64Thread(ProcDebugger debugger, long id)
  {
    this.debugger = debugger;
    this.id = ((int)id);
  }
  
  public ThreadContext getContext()
    throws IllegalThreadStateException
  {
    ProcAMD64ThreadContext context = new ProcAMD64ThreadContext(debugger);
    long[] regs = debugger.getThreadIntegerRegisterSet(id);
    if (Assert.ASSERTS_ENABLED) {
      Assert.that(regs.length == 28, "size mismatch");
    }
    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;
  }
  
  public boolean equals(Object obj)
  {
    if ((obj == null) || (!(obj instanceof ProcAMD64Thread))) {
      return false;
    }
    return id == id;
  }
  
  public int hashCode()
  {
    return id;
  }
}

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

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.amd64.AMD64ThreadContext;
import sun.jvm.hotspot.debugger.proc.ProcDebugger;

public class ProcAMD64ThreadContext
  extends AMD64ThreadContext
{
  private ProcDebugger debugger;
  
  public ProcAMD64ThreadContext(ProcDebugger 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.proc.amd64.ProcAMD64ThreadContext
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package sun.jvm.hotspot.debugger.proc.amd64;

import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.ThreadProxy;
import sun.jvm.hotspot.debugger.proc.ProcDebugger;
import sun.jvm.hotspot.debugger.proc.ProcThreadFactory;

public class ProcAMD64ThreadFactory
  implements ProcThreadFactory
{
  private ProcDebugger debugger;
  
  public ProcAMD64ThreadFactory(ProcDebugger debugger)
  {
    this.debugger = debugger;
  }
  
  public ThreadProxy createThreadWrapper(Address threadIdentifierAddr)
  {
    return new ProcAMD64Thread(debugger, threadIdentifierAddr);
  }
  
  public ThreadProxy createThreadWrapper(long id)
  {
    return new ProcAMD64Thread(debugger, id);
  }
}

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

import java.io.PrintStream;
import sun.jvm.hotspot.debugger.Address;
import sun.jvm.hotspot.debugger.DebuggerException;
import sun.jvm.hotspot.debugger.NotInHeapException;
import sun.jvm.hotspot.debugger.OopHandle;
import sun.jvm.hotspot.debugger.UnalignedAddressException;
import sun.jvm.hotspot.debugger.UnmappedAddressException;

class ProcAddress
  implements Address
{
  protected ProcDebugger debugger;
  protected long addr;
  
  ProcAddress(ProcDebugger debugger, long addr)
  {
    this.debugger = debugger;
    this.addr = addr;
  }
  
  public boolean equals(Object arg)
  {
    if (arg == null) {
      return false;
    }
    if (!(arg instanceof ProcAddress)) {
      return false;
    }
    return addr == addr;
  }
  
  public int hashCode()
  {
    return (int)addr;
  }
  
  public String toString()
  {
    return debugger.addressValueToString(addr);
  }
  
  public long getCIntegerAt(long offset, long numBytes, boolean isUnsigned)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readCInteger(addr + offset, numBytes, isUnsigned);
  }
  
  public Address getAddressAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readAddress(addr + offset);
  }
  
  public Address getCompOopAddressAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readCompOopAddress(addr + offset);
  }
  
  public boolean getJBooleanAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readJBoolean(addr + offset);
  }
  
  public byte getJByteAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readJByte(addr + offset);
  }
  
  public char getJCharAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readJChar(addr + offset);
  }
  
  public double getJDoubleAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readJDouble(addr + offset);
  }
  
  public float getJFloatAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readJFloat(addr + offset);
  }
  
  public int getJIntAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readJInt(addr + offset);
  }
  
  public long getJLongAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readJLong(addr + offset);
  }
  
  public short getJShortAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException
  {
    return debugger.readJShort(addr + offset);
  }
  
  public OopHandle getOopHandleAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException, NotInHeapException
  {
    return debugger.readOopHandle(addr + offset);
  }
  
  public OopHandle getCompOopHandleAt(long offset)
    throws UnalignedAddressException, UnmappedAddressException, NotInHeapException
  {
    return debugger.readCompOopHandle(addr + offset);
  }
  
  public void setCIntegerAt(long offset, long numBytes, long value)
  {
    throw new DebuggerException("Unimplemented");
  }
  
  public void setAddressAt(long offset, Address value)
  {
    throw new DebuggerException("Unimplemented");
  }
  
  public void setJBooleanAt(long offset, boolean value)
    throws UnmappedAddressException, UnalignedAddressException
  {
    throw new DebuggerException("Unimplemented");
  }
  
  public void setJByteAt(long offset, 
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