Search in sources :

Example 1 with MemoryRange

use of com.ibm.dtfj.corereaders.MemoryRange in project openj9 by eclipse.

the class ImageAddressSpace method getImageSections.

public Iterator getImageSections() {
    Iterator rangeWalker = _shadow.getMemoryRanges();
    Vector sections = new Vector();
    while (rangeWalker.hasNext()) {
        MemoryRange range = (MemoryRange) rangeWalker.next();
        if (range.getAsid() == _asid) {
            long virtualAddress = range.getVirtualAddress();
            RawImageSection section = new RawImageSection(getPointer(virtualAddress), range.getSize());
            sections.add(section);
        }
    }
    return sections.iterator();
}
Also used : MemoryRange(com.ibm.dtfj.corereaders.MemoryRange) Iterator(java.util.Iterator) Vector(java.util.Vector)

Example 2 with MemoryRange

use of com.ibm.dtfj.corereaders.MemoryRange in project openj9 by eclipse.

the class DumpReaderAddressSpace method getBytesAt.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.addressspace.IAbstractAddressSpace#getBytesAt(int, long, byte[])
	 */
public int getBytesAt(int asid, long address, byte[] buffer) throws MemoryAccessException {
    int size, bytesRead = 0;
    while (bytesRead < buffer.length) {
        long adjustedAddress = address + ((long) bytesRead & 0xFFFFFFFF);
        MemoryRange match = _residentRange(asid, adjustedAddress);
        long offset = adjustedAddress - match.getVirtualAddress();
        long bytesAvailable = match.getSize() - offset;
        // For 64-bit dumps, need to safely limit byte array size
        if (bytesAvailable > (long) (Integer.MAX_VALUE)) {
            size = buffer.length - bytesRead;
        } else {
            size = Math.min((int) bytesAvailable, buffer.length - bytesRead);
        }
        try {
            if (match.isInCoreFile() == true) {
                _reader.seek(match.getFileOffset() + offset);
                byte[] temp = _reader.readBytes(size);
                System.arraycopy(temp, 0, buffer, bytesRead, temp.length);
            } else {
                /*
					 * This memory range is not mapped into the core file, but is resident in
					 * an external library file, so read it from there.
					 */
                DumpReader reader = match.getLibraryReader();
                if (reader != null) {
                    reader.seek(offset);
                    byte[] temp = reader.readBytes(size);
                    System.arraycopy(temp, 0, buffer, bytesRead, temp.length);
                } else {
                    // No valid reader for this memory
                    throw new MemoryAccessException(asid, adjustedAddress, "Cannot read memory external to core file");
                }
            }
        } catch (IOException e) {
            throw new MemoryAccessException(asid, adjustedAddress, "IOException reading core file: " + e.getMessage());
        }
        bytesRead += size;
    }
    return bytesRead;
}
Also used : MemoryRange(com.ibm.dtfj.corereaders.MemoryRange) DumpReader(com.ibm.dtfj.corereaders.DumpReader) IOException(java.io.IOException) MemoryAccessException(com.ibm.dtfj.corereaders.MemoryAccessException)

Example 3 with MemoryRange

use of com.ibm.dtfj.corereaders.MemoryRange in project openj9 by eclipse.

the class LayeredAddressSpace method mapRegion.

public void mapRegion(long virtualAddress, ClosingFileReader residentFile, long fileOffset, long size) {
    MemoryRange range = new MemoryRange(virtualAddress, fileOffset, size);
    _moduleRanges.put(range, residentFile);
}
Also used : MemoryRange(com.ibm.dtfj.corereaders.MemoryRange)

Example 4 with MemoryRange

use of com.ibm.dtfj.corereaders.MemoryRange in project openj9 by eclipse.

the class SimpleAddressSpace method getBytesAt.

public int getBytesAt(int asid, long address, byte[] buffer) throws MemoryAccessException {
    MemoryRange resident = _residentRange(asid, address);
    long readLocation = resident.getFileOffset() + (address - resident.getVirtualAddress());
    try {
        _backing.seek(readLocation);
        _backing.readFully(buffer);
    } catch (IOException e) {
        throw new MemoryAccessException(asid, address);
    }
    return buffer.length;
}
Also used : MemoryRange(com.ibm.dtfj.corereaders.MemoryRange) IOException(java.io.IOException) MemoryAccessException(com.ibm.dtfj.corereaders.MemoryAccessException)

Example 5 with MemoryRange

use of com.ibm.dtfj.corereaders.MemoryRange in project openj9 by eclipse.

the class LayeredAddressSpace method getBytesAt.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.addressspace.IAbstractAddressSpace#getBytesAt(int, long, byte[])
	 */
public int getBytesAt(int asid, long address, byte[] buffer) throws MemoryAccessException {
    if (null == _moduleRangesArray) {
        _moduleRangesArray = (MemoryRange[]) _moduleRanges.keySet().toArray(new MemoryRange[0]);
    }
    int retI = findWhichMemoryRange(asid, address, _moduleRangesArray, _lastModuleRange, false);
    if (retI > -1) {
        MemoryRange range = (MemoryRange) _moduleRangesArray[retI];
        if (range.contains(address)) {
            ClosingFileReader readable = (ClosingFileReader) _moduleRanges.get(range);
            try {
                long fileOffset = range.getFileOffset() + (address - range.getVirtualAddress());
                readable.seek(fileOffset);
                readable.readFully(buffer);
                return buffer.length;
            } catch (IOException ex) {
                System.out.println(">> Memory access exception in getBytesAt");
                throw new MemoryAccessException(asid, address);
            }
        }
    }
    // this must not be in one of the newer regions
    return _base.getBytesAt(asid, address, buffer);
}
Also used : MemoryRange(com.ibm.dtfj.corereaders.MemoryRange) ClosingFileReader(com.ibm.dtfj.corereaders.ClosingFileReader) IOException(java.io.IOException) MemoryAccessException(com.ibm.dtfj.corereaders.MemoryAccessException)

Aggregations

MemoryRange (com.ibm.dtfj.corereaders.MemoryRange)6 MemoryAccessException (com.ibm.dtfj.corereaders.MemoryAccessException)3 IOException (java.io.IOException)3 Iterator (java.util.Iterator)2 ClosingFileReader (com.ibm.dtfj.corereaders.ClosingFileReader)1 DumpReader (com.ibm.dtfj.corereaders.DumpReader)1 Vector (java.util.Vector)1