Module openj9.dtfj

Class AddressSpace

java.lang.Object
com.ibm.dtfj.corereaders.zos.dumpreader.AddressSpace
All Implemented Interfaces:
Serializable

public class AddressSpace extends Object implements Serializable
This class represents an address space in an svcdump. It provides the ability to read the contents of an address amongst other things. Note that in Zebedee as a whole, addresses are always represented by a long (Java primitive) to avoid the overhead of continually creating address objects.
See Also:
  • Field Details

    • dump

      protected Dump dump
      The dump we belong to
    • asid

      protected int asid
      Our address space id
    • addressMap

      protected IntegerMap addressMap
      Mapping of address to file offsets
    • lastBlockAddress

      protected long lastBlockAddress
      The last block address requested (quick block cache)
    • lastButOneBlockAddress

      protected long lastButOneBlockAddress
      The last but one block address requested (quick block cache)
    • ranges

      protected AddressRange[] ranges
      Array of AddressRanges
    • WILD_POINTER

      public static final long WILD_POINTER
      Constant used to indicate an uninitialized pointer (for performance reasons we use primitive longs for pointers rather than objects)
      See Also:
  • Constructor Details

    • AddressSpace

      public AddressSpace(Dump dump, int asid)
      Creates a new AddressSpace belonging to the given Dump and having the given id.
      Parameters:
      dump - the Dump this space belongs to
      asid - the address space id
  • Method Details

    • getDump

      public Dump getDump()
      Returns:
      the Dump we belong to
    • getRootAddressSpace

      public AddressSpace getRootAddressSpace()
      Returns:
      the root address space
    • getUserMap

      public Map getUserMap()
      Returns a general purpose Map object that AddressSpace users can use as they see fit. This map is provided as a convenience since users of AddressSpace often want to store related info somewhere. Care should be taken that nobody else has used the same key - one way to achieve this would be to use a class object as a key.
    • getAsid

      public int getAsid()
      Returns the MVS ASID (Address Space Identifier) for this address space.
    • getAddressRanges

      public AddressRange[] getAddressRanges()
      Returns an array of all the AddressRanges in this address space. An address range is simply a pair of [low, high] addresses for which memory is available in the dump.
    • getUnusedAddressRanges

      public AddressRange[] getUnusedAddressRanges()
      Returns an array of all the unused address ranges in the address space. This is the inverse of getAddressRanges().
    • getImageInputStream

      public AddressSpaceImageInputStream getImageInputStream()
      Returns an AddressSpaceImageInputStream for this address space. The ImageInputStream interface provides a wealth of read methods.
    • roundToPage

      protected long roundToPage(long address)
      Rounds the address to the base page address and also strips the top bit if in 32-bit mode.
    • stripTopBit

      public long stripTopBit(long address)
      Strip the top bit if this is a 32-bit platform
    • getBlockFromCacheOrDisk

      protected byte[] getBlockFromCacheOrDisk(long address) throws IOException
      Get the block either from the cache or from disk. This protected method is provided so that MutableAddressSpace has the chance to look in its own cache first.
      Throws:
      IOException
    • read

      public int read(long address) throws IOException
      Read an unsigned byte at the specified address.
      Throws:
      IOException - if the given address is not present in this address space
    • readInt

      public int readInt(long address) throws IOException
      Read an int at the specified address.
      Throws:
      IOException - if the given address is not present in this address space
    • readUnsignedByte

      public int readUnsignedByte(long address) throws IOException
      Read an unsigned byte at the specified address.
      Throws:
      IOException - if the given address is not present in this address space
    • readByte

      public byte readByte(long address) throws IOException
      Read a (signed) byte at the specified address.
      Throws:
      IOException - if the given address is not present in this address space
    • readUnsignedShort

      public int readUnsignedShort(long address) throws IOException
      Read an unsigned short at the specified address.
      Throws:
      IOException - if the given address is not present in this address space
    • readShort

      public short readShort(long address) throws IOException
      Read a (signed) short at the specified address.
      Throws:
      IOException - if the given address is not present in this address space
    • readUnsignedInt

      public long readUnsignedInt(long address) throws IOException
      Read an unsigned int at the specified address.
      Throws:
      IOException - if the given address is not present in this address space
    • readLong

      public long readLong(long address) throws IOException
      Read a long at the specified address.
      Throws:
      IOException - if the given address is not present in this address space
    • readWord

      public long readWord(long address) throws IOException
      Read a word at the specified address. A word is either 32 or 64 bits depending on the machine context.
      Throws:
      IOException
    • getWordLength

      public int getWordLength()
      Returns the word length in bytes (either 4 or 8 bytes depending on the machine context).
    • read

      public void read(long address, byte[] b, int off, int len) throws IOException
      Reads len bytes of data from the given address into an array of bytes.
      Parameters:
      address - the address to read from
      b - - the buffer into which the data is read
      off - - the start offset in array b at which the data is written
      len - - the number of bytes to read
      Throws:
      IOException
    • readEbcdicString

      public String readEbcdicString(long address, int length) throws IOException
      Read an EBCDIC String. This method expects to find a sequence of EBCDIC bytes at the given address.
      Parameters:
      address - the start address of the EBCDIC bytes
      length - the number of bytes to be read
      Throws:
      IOException - if the given address is not present in this address space
    • readEbcdicString

      public String readEbcdicString(long address) throws IOException
      Read an EBCDIC String. Assumes that address points to the halfword length immediately followed by the EBCDIC bytes.
      Parameters:
      address - the start address of the EBCDIC bytes
      Throws:
      IOException - if the given address is not present in this address space
    • readEbcdicCString

      public String readEbcdicCString(long address) throws IOException
      Read an EBCDIC String. Assumes that address points to a null-terminated EBCDIC string.
      Parameters:
      address - the start address of the EBCDIC bytes
      Throws:
      IOException - if the given address is not present in this address space
    • readAsciiString

      public String readAsciiString(long address, int length) throws IOException
      Read an ASCII String. This method expects to find a sequence of ASCII bytes at the given address.
      Parameters:
      address - the start address of the ASCII bytes
      length - the number of bytes to be read
      Throws:
      IOException - if the given address is not present in this address space
    • readAsciiCString

      public String readAsciiCString(long address) throws IOException
      Read the ASCII string at the given address. Assumes that address points to a null-terminated ASCII C string.
      Parameters:
      address - the start address of the ASCII bytes
      Throws:
      IOException - if the given address is not present in this address space
    • readAsciiString

      public String readAsciiString(long address) throws IOException
      Read an ASCII String. Assumes that address points to the halfword length immediately followed by the ASCII bytes.
      Parameters:
      address - the start address of the ASCII bytes
      Throws:
      IOException - if the given address is not present in this address space
    • readUtf8String

      public String readUtf8String(long address) throws IOException
      Read a UTF8 String. Assumes that address points to the halfword length immediately followed by the utf8 bytes. XXX Despite the name no UTF8 conversion is done yet! (i.e. assumes ASCII)
      Parameters:
      address - the start address of the structure
      Throws:
      IOException - if the given address is not present in this address space
    • isValid

      public boolean isValid(long address)
      Returns true if the given address is present in this address space.
    • is64bit

      public boolean is64bit()
      Returns true if this is a 64-bit machine
    • setIs64bit

      public void setIs64bit(boolean is64bit)
      Sets whether this is a 64-bit machine. Unfortunately there is no way of knowing at the beginning if we are running in 64-bit mode, this is only discovered in le/Caa. So perhaps this knowledge should only be in the le layer?
    • toString

      public String toString()
      Returns the address space id as a hex string.
      Overrides:
      toString in class Object
      Returns:
      String a printable representation for the receiver.