private void getFunctionInfo(Address addr) {
		Function function = functionManager.getFunctionAt(addr);
		AddressSetView asv = function.getBody();
		Address maxAddr = asv.getMaxAddress();
		Long length = maxAddr.getUnsignedOffset() - addr.getUnsignedOffset();
		byte[] bytes = new byte[length.intValue()];
		try {
			memory.getBytes(addr, bytes);
		}
		catch (MemoryAccessException e) {
			Msg.warn(this, "Memory access error");
		}
		FunctionSignature sig = function.getSignature(true);
		Symbol symbol = symbolManager.getPrimarySymbol(addr);
		String name = symbol.getName(true);
		functionInfo.put(addr, new NameAndBytes(name, bytes));
		signatureInfo.put(addr, sig);
	}
Developer script to capture items from Program and PDB for developing tests
Ghidra/Features/PDB/developer_scripts/CaptureHelperScript.java