* Screen.debug("{ex at pc:"); Screen.debug(pc); Screen.debug(" of " + * method.getBytecodeSize()); Screen.debug(method.getName());
* Screen.debug("{ex at pc:"); Screen.debug(pc); Screen.debug(" of " + method.getBytecodeSize()); Screen.debug(method.getName());
	public static Address findThrowableHandler(Throwable ex, Address frame, Address address) {		try {			if (ex == null) {				Unsafe.debug("NPE");				throw new NullPointerException();			}			if (frame == null) {				Unsafe.debug("frame==null");				return null;			}			final VmProcessor proc = Unsafe.getCurrentProcessor();			final VmStackReader reader = proc.getArchitecture().getStackReader();			final int magic = reader.getMagic(frame);			final boolean interpreted = (magic == VmStackFrame.MAGIC_INTERPRETED);			final boolean compiled = (magic == VmStackFrame.MAGIC_COMPILED);			if (!(interpreted || compiled)) {				Unsafe.debug("Unknown magic");				return null;			}			final VmType exClass = Unsafe.getVmClass(ex);			final VmMethod method = reader.getMethod(frame);			final int pc = reader.getPC(frame);			if (method == null) {				Unsafe.debug("Unknown method");				return null;			}			//if (interpreted) {			/*			 * Screen.debug("{ex at pc:"); Screen.debug(pc); Screen.debug(" of " +			 * method.getBytecodeSize()); Screen.debug(method.getName());			 */			//}			final int count;			final VmByteCode bc = method.getBytecode();			final VmCompiledCode cc = method.getCompiledCode();			if (bc != null) {				count = bc.getNoExceptionHandlers();			} else {				count = 0;			}			//Screen.debug("eCount=" + count);			for (int i = 0; i < count; i++) {				final AbstractExceptionHandler eh;				final VmCompiledExceptionHandler ceh;				final VmInterpretedExceptionHandler ieh;				if (compiled) {					ceh = cc.getExceptionHandler(i);					eh = ceh;					ieh = null;				} else {					ieh = bc.getExceptionHandler(i);					eh = ieh;					ceh = null;				}				boolean match;				if (compiled) {					match = ceh.isInScope(address);				} else {					match = ieh.isInScope(pc);				}				if (match) {					final VmConstClass catchType = eh.getCatchType();					if (catchType == null) {						/* Catch all exceptions */						if (compiled) {							return ceh.getHandler();						} else {							reader.setPC(frame, ieh.getHandlerPC());							//Screen.debug("Found ANY handler");							return Unsafe.intToAddress(RC_HANDLER);						}					} else {						if (!catchType.isResolved()) {							SoftByteCodes.resolveClass(catchType);						}						final VmType handlerClass = catchType.getResolvedVmClass();						if (handlerClass != null) {							if (handlerClass.isAssignableFrom(exClass)) {								if (compiled) {									return ceh.getHandler();								} else {									reader.setPC(frame, ieh.getHandlerPC());									//Screen.debug("Found specific handler");									return Unsafe.intToAddress(RC_HANDLER);								}							}						} else {							System.err.println("Warning: handler class==null in " + method.getName());						}					}				}			}			if (compiled) {				if (cc.contains(address)) {					return cc.getDefaultExceptionHandler();				} else {					return null;				}			} else {				//Screen.debug("Def.handler");				return Unsafe.intToAddress(RC_DEFHANDLER);			}		} catch (Throwable ex2) {			Unsafe.debug("Exception in findThrowableHandler");			Unsafe.die("findThrowableHandler");			return null;		}	}