@Test public void testFindPatternAcrossRanges() { AbstractMemory sut = new MockMemory(ByteOrder.BIG_ENDIAN); sut.addMemorySource(new MockMemorySource(new byte[] { 0x0 }, 0, 0, 100)); sut .addMemorySource(new MockMemorySource(new byte[] { 0xA }, 0, 100, 100)); sut .addMemorySource(new MockMemorySource(new byte[] { 0xB }, 0, 200, 100)); sut .addMemorySource(new MockMemorySource(new byte[] { 0xD }, 0, 400, 100)); byte[] patternBuffer1 = new byte[100]; byte[] patternBuffer2 = new byte[100]; patternBuffer1[97] = 0xD; patternBuffer1[98] = 0xE; patternBuffer1[99] = 0xA; patternBuffer2[0] = 0xD; patternBuffer2[1] = 0xB; patternBuffer2[2] = 0xE; patternBuffer2[3] = 0xE; patternBuffer2[4] = 0xF; sut.addMemorySource(new BufferMemorySource(0, 500, patternBuffer1)); sut.addMemorySource(new BufferMemorySource(0, 600, patternBuffer2)); sut .addMemorySource(new MockMemorySource(new byte[] { 0xD }, 0, 700, 100)); sut .addMemorySource(new MockMemorySource(new byte[] { 0xD }, 0, 900, 100)); sut .addMemorySource(new MockMemorySource(new byte[] { 0xD }, 0, 1000, 100)); long address = sut.findPattern(new byte[] { 0xD, 0xE, 0xA, 0xD, 0xB, 0xE, 0xE, 0xF }, 1, 0); assertEquals(597, address); assertEquals(-1, sut.findPattern(new byte[] { 0xD, 0xE, 0xA, 0xD, 0xB, 0xE, 0xE, 0xF }, 1, 598)); assertEquals(-1, sut.findPattern(new byte[] { 0xD, 0xE, 0xA, 0xD, 0xB, 0xE, 0xE, 0xF }, 8, 0)); }
public void addMemorySource(IMemorySource source) { logger.logp(FINEST,"AbstractMemory","addMemorySource","Added memory range {0}-{1}",new Object[]{Long.toHexString(source.getBaseAddress()), Long.toHexString(source.getTopAddress()) }); if (GLOBAL_CACHE_ENABLED) { IMemorySource wrappedSource = new CachingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { if (RECORDING_CACHE_STATS) { IMemorySource wrappedSource = new CountingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { memorySources.addMemorySource(source); } } rangeTable = null; }
AbstractMemory extends SearchableMemory implements IMemory { public void addMemorySource(IMemorySource source) { logger.logp(FINEST,"AbstractMemory","addMemorySource","Added memory range {0}-{1}",new Object[]{Long.toHexString(source.getBaseAddress()), Long.toHexString(source.getTopAddress()) }); if (GLOBAL_CACHE_ENABLED) { IMemorySource wrappedSource = new CachingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { if (RECORDING_CACHE_STATS) { IMemorySource wrappedSource = new CountingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { memorySources.addMemorySource(source); } } rangeTable = null; } }
AbstractMemory extends SearchableMemory implements IMemory { public void addMemorySource(IMemorySource source) { logger.logp(FINEST,"AbstractMemory","addMemorySource","Added memory range {0}-{1}",new Object[]{Long.toHexString(source.getBaseAddress()), Long.toHexString(source.getTopAddress()) }); if (GLOBAL_CACHE_ENABLED) { IMemorySource wrappedSource = new CachingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { if (RECORDING_CACHE_STATS) { IMemorySource wrappedSource = new CountingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { memorySources.addMemorySource(source); } } rangeTable = null; } protected  AbstractMemory(ByteOrder byteOrder); }
AbstractMemory extends SearchableMemory implements IMemory { public void addMemorySource(IMemorySource source) { logger.logp(FINEST,"AbstractMemory","addMemorySource","Added memory range {0}-{1}",new Object[]{Long.toHexString(source.getBaseAddress()), Long.toHexString(source.getTopAddress()) }); if (GLOBAL_CACHE_ENABLED) { IMemorySource wrappedSource = new CachingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { if (RECORDING_CACHE_STATS) { IMemorySource wrappedSource = new CountingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { memorySources.addMemorySource(source); } } rangeTable = null; } protected  AbstractMemory(ByteOrder byteOrder); byte getByteAt(long address); int getBytesAt(long address, byte[] buffer); int getBytesAt(final long address, byte[] buffer, final int offset,final int length); int getIntAt(long address); long getLongAt(long address); short getShortAt(long address); void addMemorySource(IMemorySource source); void removeMemorySource(IMemorySource source); void addMemorySources(Collection<? extends IMemorySource> memorySources); List<IMemoryRange> getMemoryRanges(); ByteOrder getByteOrder(); boolean isShared(long address); boolean isExecutable(long address); boolean isReadOnly(long address); Properties getProperties(long address); }
AbstractMemory extends SearchableMemory implements IMemory { public void addMemorySource(IMemorySource source) { logger.logp(FINEST,"AbstractMemory","addMemorySource","Added memory range {0}-{1}",new Object[]{Long.toHexString(source.getBaseAddress()), Long.toHexString(source.getTopAddress()) }); if (GLOBAL_CACHE_ENABLED) { IMemorySource wrappedSource = new CachingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { if (RECORDING_CACHE_STATS) { IMemorySource wrappedSource = new CountingMemorySource(source); decoratorMappingTable.put(source, wrappedSource); memorySources.addMemorySource(wrappedSource); } else { memorySources.addMemorySource(source); } } rangeTable = null; } protected  AbstractMemory(ByteOrder byteOrder); byte getByteAt(long address); int getBytesAt(long address, byte[] buffer); int getBytesAt(final long address, byte[] buffer, final int offset,final int length); int getIntAt(long address); long getLongAt(long address); short getShortAt(long address); void addMemorySource(IMemorySource source); void removeMemorySource(IMemorySource source); void addMemorySources(Collection<? extends IMemorySource> memorySources); List<IMemoryRange> getMemoryRanges(); ByteOrder getByteOrder(); boolean isShared(long address); boolean isExecutable(long address); boolean isReadOnly(long address); Properties getProperties(long address);  }