@Test
	public void testAddGuestDataThenRemoveAndDelete() throws Exception {
		DBTracePlatformManager platMan = b.trace.getPlatformManager();
		Language x86 = getSLEIGH_X86_LANGUAGE();
		DBTraceGuestPlatform guest;
		DBTraceGuestPlatformMappedRange mappedRange;

		TraceData hd4000;
		TraceData gd4008;
		TraceData gd400c;
		try (Transaction tx = b.startTransaction()) {
			guest = platMan.addGuestPlatform(x86.getDefaultCompilerSpec());
			mappedRange = guest.addMappedRange(b.addr(0x0000), b.addr(guest, 0x0000), 1L << 32);
			hd4000 = b.addData(0, b.addr(0x4000), PointerDataType.dataType,
				b.buf(0, 0, 0, 0, 0, 0, 0x40, 0x80));
			gd4008 = b.addData(0, b.addr(0x4008), guest, PointerDataType.dataType,
				b.buf(0x81, 0x40, 0, 0));
			gd400c = b.addData(0, b.addr(0x400c), gd4008.getDataType(), b.buf(0x82, 0x40, 0, 0));
		}
		assertEquals(b.host, hd4000.getPlatform());
		assertEquals(8, hd4000.getLength());
		assertEquals(guest, gd4008.getPlatform());
		assertEquals(4, gd4008.getLength());
		assertEquals(guest, gd400c.getPlatform());
		assertEquals(4, gd400c.getLength());

		assertEquals(gd4008, manager.codeUnits().getAt(0, b.addr(0x4008)));
		assertEquals(gd400c, manager.codeUnits().getAt(0, b.addr(0x400c)));

		try (Transaction tx = b.startTransaction()) {
			mappedRange.delete(new ConsoleTaskMonitor());
		}
		assertEquals(hd4000, manager.codeUnits().getAt(0, b.addr(0x4000)));
		assertUndefinedWithAddr(b.addr(0x4008), manager.codeUnits().getAt(0, b.addr(0x4008)));
		assertUndefinedWithAddr(b.addr(0x400c), manager.codeUnits().getAt(0, b.addr(0x400c)));

		b.trace.undo();

		// NB. The range deletion also deletes the guest units, so they'll have new identities
		gd4008 = manager.definedData().getAt(0, b.addr(0x4008));
		gd400c = manager.definedData().getAt(0, b.addr(0x400c));
		assertNotNull(gd4008);
		assertNotNull(gd400c);
		assertEquals(guest, gd4008.getPlatform());
		assertEquals(guest, gd400c.getPlatform());
		try (Transaction tx = b.startTransaction()) {
			guest.delete(new ConsoleTaskMonitor());
		}
		assertEquals(hd4000, manager.codeUnits().getAt(0, b.addr(0x4000)));
		assertUndefinedWithAddr(b.addr(0x4008), manager.codeUnits().getAt(0, b.addr(0x4008)));
		assertUndefinedWithAddr(b.addr(0x400c), manager.codeUnits().getAt(0, b.addr(0x400c)));
		assertNotNull(manager.definedData().getAt(0, b.addr(0x4000)));
	}
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