WatchedMemoryBus.java

1
package com.rox.mem;
2
3
/**
4
 * A {@link MemoryBus} that reports every read and write made through it - how watchpoints see the CPU's accesses.
5
 * Anything reaching the wrapped bus another way (debugger peeks, OAM DMA's page copy) isn't reported.
6
 */
7
public final class WatchedMemoryBus implements MemoryBus {
8
    @FunctionalInterface
9
    public interface AccessListener {
10
        void accessed(int address, boolean write, int value);
11
    }
12
13
    private final MemoryBus memoryBus;
14
    private final AccessListener listener;
15
16
    public WatchedMemoryBus(final MemoryBus memoryBus, final AccessListener listener){
17
        this.memoryBus = memoryBus;
18
        this.listener = listener;
19
    }
20
21
    @Override
22
    public int read(final int address){
23
        final int value = memoryBus.read(address);
24 1 1. read : removed call to com/rox/mem/WatchedMemoryBus$AccessListener::accessed → KILLED
        listener.accessed(address, false, value);
25 1 1. read : replaced int return with 0 for com/rox/mem/WatchedMemoryBus::read → KILLED
        return value;
26
    }
27
28
    @Override
29
    public void write(final int address, final int value){
30 1 1. write : removed call to com/rox/mem/MemoryBus::write → KILLED
        memoryBus.write(address, value);
31 1 1. write : removed call to com/rox/mem/WatchedMemoryBus$AccessListener::accessed → KILLED
        listener.accessed(address, true, value);
32
    }
33
}

Mutations

24

1.1
Location : read
Killed by : com.rox.mem.WatchedMemoryBusTest.[engine:junit-jupiter]/[class:com.rox.mem.WatchedMemoryBusTest]/[method:aReadReturnsTheWrappedBusesValueAndReportsIt()]
removed call to com/rox/mem/WatchedMemoryBus$AccessListener::accessed → KILLED

25

1.1
Location : read
Killed by : com.rox.mem.WatchedMemoryBusTest.[engine:junit-jupiter]/[class:com.rox.mem.WatchedMemoryBusTest]/[method:aReadReturnsTheWrappedBusesValueAndReportsIt()]
replaced int return with 0 for com/rox/mem/WatchedMemoryBus::read → KILLED

30

1.1
Location : write
Killed by : com.rox.mem.WatchedMemoryBusTest.[engine:junit-jupiter]/[class:com.rox.mem.WatchedMemoryBusTest]/[method:aWriteReachesTheWrappedBusThenIsReported()]
removed call to com/rox/mem/MemoryBus::write → KILLED

31

1.1
Location : write
Killed by : com.rox.mem.WatchedMemoryBusTest.[engine:junit-jupiter]/[class:com.rox.mem.WatchedMemoryBusTest]/[method:aWriteReachesTheWrappedBusThenIsReported()]
removed call to com/rox/mem/WatchedMemoryBus$AccessListener::accessed → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1