@Override
	public int getBytes(ByteBuffer buffer, int addressOffset) {
		try (LockHold hold = space.trace.lockRead()) {
			Address address = getX1();
			if (byteCache == null) {
				byteCache = ByteBuffer.allocate(getLength());
			}
			int end = addressOffset + buffer.remaining();
			// Fill the cache, if needed
			if (end > byteCache.position()) {
				byteCache.limit(Math.min(byteCache.capacity(), end));
				// TODO: Retrieve the memory space at code space construction time
				DBTraceMemorySpace mem = space.trace.getMemoryManager().get(space, false);
				mem.getViewBytes(getStartSnap(), address.add(byteCache.position()), byteCache);
			}
			// Copy from the cache
			int toCopyFromCache =
				Math.min(byteCache.position() - addressOffset, buffer.remaining());
			if (toCopyFromCache > 0) {
				buffer.put(byteCache.array(), addressOffset, toCopyFromCache);
			}
			else {
				toCopyFromCache = 0;
			}
			if (byteCache.position() >= end) {
				return toCopyFromCache;
			}
			// If needed, copy the rest from DB
			assert byteCache.position() == byteCache.capacity();
			int startRemains = Math.max(addressOffset, byteCache.position());
			DBTraceMemorySpace mem = space.trace.getMemoryManager().get(space, false);
			return toCopyFromCache +
				mem.getViewBytes(getStartSnap(), address.add(startRemains), buffer);
		}
	}
Construct a code unit

@param space the space
@param tree the storage R*-Tree
@param store the object store
@param record the record
Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/database/listing/AbstractDBTraceCodeUnit.java