@Override
	public void run() throws Exception {
		AddressSet set = new AddressSet();
		Listing listing = currentProgram.getListing();

		InstructionIterator initer = listing.getInstructions(currentProgram.getMemory(), true);
		while (initer.hasNext() && !monitor.isCancelled()) {
			Instruction instruct = initer.next();
			set.addRange(instruct.getMinAddress(), instruct.getMaxAddress());
		}
		FunctionIterator iter = listing.getFunctions(true);
		while (iter.hasNext() && !monitor.isCancelled()) {
			Function f = iter.next();
			set.delete(f.getBody());
		}

		if (set.getNumAddressRanges() == 0) {
			popup("NO RESULTS - all instructions are contained inside functions");
			return;
		}

		//
		// go through address set and find the actual start of flow into the dead code
		//
		IsolatedEntrySubModel submodel = new IsolatedEntrySubModel(currentProgram);
		CodeBlockIterator subIter = submodel.getCodeBlocksContaining(set, monitor);
		AddressSet codeStarts = new AddressSet();
		while (subIter.hasNext()) {
			CodeBlock block = subIter.next();
			Address deadStart = block.getFirstStartAddress();
			codeStarts.add(deadStart);
		}

		if (SystemUtilities.isInHeadlessMode()) {
			Msg.error(this, "POSSIBLE UNDEFINED FUNCTIONS: # " + codeStarts.getNumAddresses());
		}
		else {
			show("Possible Undefined functions", codeStarts);
		}
	}
@see ghidra.app.script.GhidraScript#run()
Ghidra/Features/Base/ghidra_scripts/FindInstructionsNotInsideFunctionScript.java