- 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected IntegerMap
addressMap
Mapping of address to file offsetsprotected int
asid
Our address space idprotected Dump
dump
The dump we belong toprotected long
lastBlockAddress
The last block address requested (quick block cache)protected long
lastButOneBlockAddress
The last but one block address requested (quick block cache)protected AddressRange[]
ranges
Array of AddressRangesstatic long
WILD_POINTER
Constant used to indicate an uninitialized pointer (for performance reasons we use primitive longs for pointers rather than objects)
-
Constructor Summary
Constructors Constructor Description AddressSpace(Dump dump, int asid)
Creates a new AddressSpace belonging to the given Dump and having the given id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AddressRange[]
getAddressRanges()
Returns an array of all theAddressRange
s in this address space.int
getAsid()
Returns the MVS ASID (Address Space Identifier) for this address space.protected byte[]
getBlockFromCacheOrDisk(long address)
Get the block either from the cache or from disk.Dump
getDump()
AddressSpaceImageInputStream
getImageInputStream()
Returns anAddressSpaceImageInputStream
for this address space.AddressSpace
getRootAddressSpace()
AddressRange[]
getUnusedAddressRanges()
Returns an array of all the unused address ranges in the address space.Map
getUserMap()
Returns a general purpose Map object that AddressSpace users can use as they see fit.int
getWordLength()
Returns the word length in bytes (either 4 or 8 bytes depending on the machine context).boolean
is64bit()
Returns true if this is a 64-bit machineboolean
isValid(long address)
Returns true if the given address is present in this address space.int
read(long address)
Read an unsigned byte at the specified address.void
read(long address, byte[] b, int off, int len)
Reads len bytes of data from the given address into an array of bytes.String
readAsciiCString(long address)
Read the ASCII string at the given address.String
readAsciiString(long address)
Read an ASCII String.String
readAsciiString(long address, int length)
Read an ASCII String.byte
readByte(long address)
Read a (signed) byte at the specified address.String
readEbcdicCString(long address)
Read an EBCDIC String.String
readEbcdicString(long address)
Read an EBCDIC String.String
readEbcdicString(long address, int length)
Read an EBCDIC String.int
readInt(long address)
Read an int at the specified address.long
readLong(long address)
Read a long at the specified address.short
readShort(long address)
Read a (signed) short at the specified address.int
readUnsignedByte(long address)
Read an unsigned byte at the specified address.long
readUnsignedInt(long address)
Read an unsigned int at the specified address.int
readUnsignedShort(long address)
Read an unsigned short at the specified address.String
readUtf8String(long address)
Read a UTF8 String.long
readWord(long address)
Read a word at the specified address.protected long
roundToPage(long address)
Rounds the address to the base page address and also strips the top bit if in 32-bit mode.void
setIs64bit(boolean is64bit)
Sets whether this is a 64-bit machine.long
stripTopBit(long address)
Strip the top bit if this is a 32-bit platformString
toString()
Returns the address space id as a hex string.
-
-
-
Field Detail
-
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:
- Constant Field Values
-
-
Method Detail
-
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 theAddressRange
s 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 ofgetAddressRanges()
.
-
getImageInputStream
public AddressSpaceImageInputStream getImageInputStream()
Returns anAddressSpaceImageInputStream
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 fromb
- - the buffer into which the data is readoff
- - the start offset in array b at which the data is writtenlen
- - 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 byteslength
- 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 byteslength
- 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?
-
-