private StackTraceElement[] recordTestThreadState() {

		Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
		Set<Entry<Thread, StackTraceElement[]>> entrySet = allStackTraces.entrySet();
		for (Entry<Thread, StackTraceElement[]> entry : entrySet) {

			Thread thread = entry.getKey();
			if (TestThread.isTestThread(thread)) {

				// grab the state of the test thread, but chop out some uninteresting calls
				StackTraceElement[] fullTrace = entry.getValue();
				StackTraceElement[] filtered = TestThread.filterTrace(fullTrace);
				return filtered;
			}
		}

		return new StackTraceElement[0];
	}
A class to take an exception and capture test system state for later reporting.
Ghidra/Framework/Generic/src/main/java/generic/test/TestExceptionTracker.java