public Breakpoint findFor(Environment env, TraceInfo trace) { String fileName = trace.getFileName(); if (!fileName.startsWith("/") && !fileName.matches("^[A-Za-z](\\\\:)(.+?)")) { fileName = debugger.getFileName(fileName); } int line = trace.getStartLine(); for (Breakpoint breakpoint : breakpoints.values()) { if (breakpoint.line == line + 1 && fileName != null && fileName.equalsIgnoreCase(breakpoint.fileName)) { return breakpoint; } } return null; }
@Override public void run(Debugger context, CommandArguments args, Document result) { DebugTick tick = context.waitTick(Debugger.Step.OVER); Element response = createResponse(args, result); response.setAttribute("reason", "ok"); response.setAttribute("status", "break"); if (tick.getTrace() != null) { Element message = result.createElement("xdebug:message"); message.setAttribute("filename", context.getFileName(tick.getTrace().getFileName())); message.setAttribute("lineno", String.valueOf(tick.getTrace().getStartLine() + 1)); response.appendChild(message); } } }
@Override public void run(Debugger context, CommandArguments args, Document result) { DebugTick tick = context.waitTick(Debugger.Step.OUT); Element response = createResponse(args, result); response.setAttribute("reason", "ok"); response.setAttribute("status", "break"); if (tick.getTrace() != null) { Element message = result.createElement("xdebug:message"); message.setAttribute("filename", context.getFileName(tick.getTrace().getFileName())); message.setAttribute("lineno", String.valueOf(tick.getTrace().getStartLine() + 1)); response.appendChild(message); } } }
@Override public void run(Debugger context, CommandArguments args, Document result) { DebugTick tick = context.waitTick(Debugger.Step.INTO); Element response = createResponse(args, result); response.setAttribute("reason", "ok"); response.setAttribute("status", "break"); if (tick.getTrace() != null) { Element message = result.createElement("xdebug:message"); message.setAttribute("filename", context.getFileName(tick.getTrace().getFileName())); message.setAttribute("lineno", String.valueOf(tick.getTrace().getStartLine() + 1)); response.appendChild(message); } } }
@Override public void run(Debugger context, CommandArguments args, Document result) { DebugTick tick = context.runTicks(); Element response = createResponse(args, result); response.setAttribute("reason", "ok"); if (tick.getBreakpoint() != null) { response.setAttribute("status", "break"); } else { response.setAttribute("status", "stopping"); } if (tick.getTrace() != null) { Element message = result.createElement("xdebug:message"); message.setAttribute("filename", context.getFileName(tick.getTrace().getFileName())); message.setAttribute("lineno", String.valueOf(tick.getTrace().getStartLine() + 1)); response.appendChild(message); } } }
@Signature public Memory getStartLine(Environment env, Memory... args){ if (getClosureEntity() != null) return LongMemory.valueOf(getClosureEntity().getTrace().getStartLine() + 1); return LongMemory.valueOf(getEntity().getTrace().getStartLine() + 1); }
private static String evalErrorMessage(ErrorException e) { return e.getMessage() + ", eval()'s code on line " + (e.getTraceInfo().getStartLine() + 1) + ", position " + (e.getTraceInfo().getStartPosition() + 1); }
public void writeTickTrigger(TraceInfo trace) { if (compiler.getScope().isDebugMode() && method.getLocalVariable("~local") != null) { int line = trace.getStartLine(); if (method.registerTickTrigger(line)) { writePushEnv(); writePushTraceInfo(trace.getStartLine(), trace.getStartPosition()); writePushLocal(); writeSysDynamicCall(Environment.class, "__tick", void.class, TraceInfo.class, ArrayMemory.class); } } }
public TraceInfo getTraceAppliedSourceMap(TraceInfo trace) { if (trace == null) { return null; } if (trace.getFile() == null) { return trace; } if (trace instanceof SourceMappedTraceInfo) { return trace; } SourceMap sourceMap = sourceMaps.get(trace.getFileName()); if (sourceMap != null) { int sourceLine = sourceMap.getSourceLine(trace.getStartLine() + 1); if (sourceLine != trace.getStartLine() && sourceLine != -1) { trace = new SourceMappedTraceInfo( trace.getContext(), sourceLine - 1, trace.getEndLine(), trace.getStartPosition(), trace.getEndPosition() ); } } return trace; }
public String getDebugMessage(){ return getType().getTypeName() + ": " + getMessage() + " in '" + trace.trace.getFileName() + "'" + " on line " + (trace.trace.getStartLine() + 1) + " at pos " + (trace.trace.getStartPosition() + 1); }
@Signature public Memory getStartLine(Environment env, Memory... args) { if (entity.isInternal() || entity.getTrace().isUnknown()) return Memory.FALSE; return LongMemory.valueOf(entity.getTrace().getStartLine() + 1); }
public void writeTrace(TraceInfo trace) throws IOException { writeBoolean(trace != null); if (trace != null){ writeInt(trace.getStartLine()); writeInt(trace.getStartPosition()); writeUTF(trace.getFileName()); } }
@Override public void setTraceInfo(Environment env, TraceInfo trace) { super.setTraceInfo(env, trace); Memory line = clazz.refOfProperty(props, "line"); Memory file = clazz.refOfProperty(props, "file"); if (!line.isNull() || !file.isNull()){ this.trace = new TraceInfo( file.isNull() ? trace.getFileName() : file.toString(), line.isNull() ? trace.getStartLine() : line.toInteger() - 1, trace.getStartPosition() ); } }
@Override public boolean onFatal(ErrorException error) { Environment.this.echo("\n"); Environment.this.echo(error.getType().getTypeName() + ": " + error.getMessage()); if (error.getTraceInfo() != null) { Environment.this.echo( " in " + error.getTraceInfo().getFileName() + " on line " + (error.getTraceInfo().getStartLine() + 1) + ", position " + (error.getTraceInfo().getStartPosition() + 1) ); } return false; } });
args[1] = new StringMemory(message.getMessage()); args[2] = new StringMemory(trace.getFileName()); args[3] = LongMemory.valueOf(trace.getStartLine() + 1); if (argCount > 4) args[4] = new ArrayMemory(false, message.getTrace().args);
+ " on line " + (trace.getStartLine() + 1) + "\n" );
@Override public ArrayMemory getProperties() { if (!init){ init = true; if (trace != null) { Memory m; m = clazz.refOfProperty(props, "file"); if (m.isNull()) { m.assign(trace.getFileName()); } m = clazz.refOfProperty(props, "line"); if (m.isNull()) { m.assign(trace.getStartLine() + 1); } m = clazz.refOfProperty(props, "position"); if (m.isNull()) { m.assign(trace.getStartPosition() + 1); } ArrayMemory backTrace = new ArrayMemory(); for(CallStackItem el : callStack) { backTrace.add(el.toArray()); } clazz.refOfProperty(props, "trace").assign(backTrace); } } return props; }
public static Memory error_get_last(Environment env) { SystemMessage err = env.getLastMessage(); if (err == null) return Memory.NULL; ArrayMemory result = new ArrayMemory(); result.refOfIndex("type").assign(err.getType().value); result.refOfIndex("message").assign(err.getMessage()); if (err.getTrace() != null && err.getTrace().trace != null) { result.refOfIndex("file").assign(err.getTrace().trace.getFileName()); result.refOfIndex("line").assign(err.getTrace().trace.getStartLine() + 1); result.refOfIndex("position").assign(err.getTrace().trace.getStartPosition() + 1); } return result.toConstant(); }
public ArrayMemory toArray(boolean provideObject, boolean ignoreArgs){ ArrayMemory el = new ArrayMemory(); if (trace != null) { if (trace.getFile() != null) el.refOfIndex("file").assign(trace.getFileName()); el.refOfIndex("line").assign(trace.getStartLine() + 1); } el.refOfIndex("function").assign(function); if (clazz != null) { el.refOfIndex("class").assign(clazz); el.refOfIndex("type").assign("::"); } if (object != null){ if (provideObject){ el.refOfIndex("object").assign(new ObjectMemory(object)); } el.refOfIndex("type").assign("->"); } if (!ignoreArgs){ el.refOfIndex("args").assign(ArrayMemory.of(args)); } if (trace != null) el.refOfIndex("position").assign(trace.getStartPosition() + 1); return el; }
@Test public void testParseError() throws IOException { Throwable ex = null; Tokenizer tokenizer = new Tokenizer(new Context( " 'foobar \n ")); try { tokenizer.nextToken(); } catch (Throwable e){ ex = e; } assertTrue(ex instanceof ParseException); TraceInfo traceInfo = ((ParseException) ex).getTraceInfo(); assertNotNull(traceInfo); assertNull(traceInfo.getContext().getFileName()); assertEquals(1, traceInfo.getStartLine()); assertEquals(1, traceInfo.getEndLine()); assertEquals(1, traceInfo.getStartPosition()); assertEquals(1, traceInfo.getEndPosition()); }