public static AddressSet getCodeUnitSet(AddressSetView addrSet, Program program) {
		Listing listing = program.getListing();
		AddressSet addrs = new AddressSet(addrSet);
		AddressRangeIterator iter = addrSet.getAddressRanges();
		while (iter.hasNext()) {
			AddressRange range = iter.next();
			Address rangeMin = range.getMinAddress();
			Address rangeMax = range.getMaxAddress();
			CodeUnit minCu = listing.getCodeUnitContaining(rangeMin);
			// NOTE: minCu does not consider prior code unit which may share bytes due to
			// possible instruction length-override.  Max address of code unit will factor-in
			// full length of instruction prototype.
			if (minCu != null) {
				Address minCuMinAddr = minCu.getMinAddress();
				if (minCuMinAddr.compareTo(rangeMin) != 0) {
					addrs.addRange(minCuMinAddr, getMaxAddress(minCu));
				}
			}
			CodeUnit maxCu = listing.getCodeUnitContaining(rangeMax);
			if (maxCu != null) {
				Address maxCuMaxAddr = getMaxAddress(maxCu);
				if (maxCuMaxAddr.compareTo(rangeMax) != 0) {
					addrs.addRange(maxCu.getMinAddress(), maxCuMaxAddr);
				}
			}
		}
		return addrs;
	}
Creates an address set that contains the entire code units within the
 program's listing that are part of the address set that is passed in.
<br>Note: This method will not remove any addresses from the address set even
if they are not part of code units in the program's listing.
@param addrSet The original address set that may contain portions of
code units.
@param program the program which has the code units.
@return the address set that contains addresses for whole code units.
Ghidra/Features/Base/src/main/java/ghidra/program/util/DiffUtility.java