Sha256: dc54759cd71ac25572200603a344de75581c5228ba292c1333518b80372f8ec9
Contents?: true
Size: 1.78 KB
Versions: 135
Compression:
Stored size: 1.78 KB
Contents
/* * Copyright 2006-2007 Yu Su * Distributed under the BSD License */ package com.xruby.debug.cmd; import com.sun.jdi.StackFrame; import com.sun.jdi.IncompatibleThreadStateException; import com.sun.jdi.Location; import com.sun.jdi.AbsentInformationException; import com.xruby.debug.Instruction; import com.xruby.debug.Result; import com.xruby.debug.ThreadInfo; import com.xruby.debug.SourceCodeMgr; import static java.lang.System.err; import static java.lang.System.out; /** * List the source code, only for commandline tools * * @author Yu Su (beanworms@gmail.com) */ public class ListInsn implements Instruction { private int range; public ListInsn(int range) { if(range > 0) { this.range = range; } else { this.range = 5; } } public Result execute() { Result result = null; ThreadInfo threadInfo = ThreadInfo.getCurrentThreadInfo(); StackFrame frame; try { frame = threadInfo.getCurrentFrame(); } catch (IncompatibleThreadStateException exc) { err.println("<location unavailable>"); return result; } if (frame == null) { err.println("No frames on the current call stack"); } else { Location loc = frame.location(); // TODO: Print out source code try { String sourceFile = loc.sourceName(); int lineNumber = loc.lineNumber(); out.println(SourceCodeMgr.getSourceSnippet(sourceFile, lineNumber, range)); } catch (AbsentInformationException e) { err.println("Debug information lost"); } } return result; } }
Version data entries
135 entries across 135 versions & 2 rubygems