@Test
	public void testAddGuestInstructionThenRemoveAndDelete() throws AddressOverflowException,
			CodeUnitInsertionException, IOException, CancelledException {
		DBTracePlatformManager platMan = b.trace.getPlatformManager();
		Language x86 = getSLEIGH_X86_LANGUAGE();
		DBTraceGuestPlatform guest;
		DBTraceGuestPlatformMappedRange mappedRange;

		TraceInstruction g4000;
		TraceInstruction i4001;
		TraceData d4003;
		try (Transaction tx = b.startTransaction()) {
			guest = platMan.addGuestPlatform(x86.getDefaultCompilerSpec());
			mappedRange = guest.addMappedRange(b.addr(0x0000), b.addr(guest, 0x0000), 1L << 32);
			g4000 = b.addInstruction(0, b.addr(0x4000), guest, b.buf(0x90));
			i4001 = b.addInstruction(0, b.addr(0x4001), b.host, b.buf(0xf4, 0));
			d4003 = b.addData(0, b.addr(0x4003), LongDataType.dataType, b.buf(1, 2, 3, 4));
		}

		assertEquals(g4000, manager.codeUnits().getAt(0, b.addr(0x4000)));
		try (Transaction tx = b.startTransaction()) {
			mappedRange.delete(new ConsoleTaskMonitor());
		}
		assertUndefinedWithAddr(b.addr(0x4000), manager.codeUnits().getAt(0, b.addr(0x4000)));
		assertEquals(i4001, manager.codeUnits().getAt(0, b.addr(0x4001)));
		assertEquals(d4003, manager.codeUnits().getAt(0, b.addr(0x4003)));

		b.trace.undo();

		// NB. The range deletion also deletes the guest unit, so it'll have a new identity
		g4000 = manager.instructions().getAt(0, b.addr(0x4000));
		assertNotNull(g4000);
		assertEquals(guest, g4000.getPlatform());
		try (Transaction tx = b.startTransaction()) {
			guest.delete(new ConsoleTaskMonitor());
		}
		assertUndefinedWithAddr(b.addr(0x4000), manager.codeUnits().getAt(0, b.addr(0x4000)));
		assertEquals(i4001, manager.codeUnits().getAt(0, b.addr(0x4001)));
		assertEquals(d4003, manager.codeUnits().getAt(0, b.addr(0x4003)));
		assertNotNull(manager.instructions().getAt(0, b.addr(0x4001)));
		assertNotNull(manager.definedData().getAt(0, b.addr(0x4003)));
	}
This test is interesting because the pointer type def causes an update to the data type
settings <em>while the unit is still being created</em>. This will invalidate the trace's
caches. All of them, including the defined data units, which can become the cause of many
timing issues.
Ghidra/Debug/Framework-TraceModeling/src/test/java/ghidra/trace/database/listing/DBTraceCodeManagerTest.java