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 PhpException(String message, Context context){ super(message); this.traceInfo = new TraceInfo(context); }
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; }
public String getDebugMessage(){ return getType().getTypeName() + ": " + getMessage() + " in '" + trace.trace.getFileName() + "'" + " on line " + (trace.trace.getStartLine() + 1) + " at pos " + (trace.trace.getStartPosition() + 1); }
CallStackItem prevLast = list.get(list.size() - 2); TraceInfo trace = prevLast.getTrace(); prevLast.setTrace(new TraceInfo( trace.getContext(), last.getTrace().getStartLine(), trace.getEndLine(), last.getTrace().getStartPosition(), trace.getEndLine() )); stack.setAttribute("type", "file"); stack.setAttribute("filename", context.getFileName(stackItem.trace.getFileName())); stack.setAttribute("lineno", String.valueOf(stackItem.trace.getStartLine() + 1));
@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()); }
@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() ); } }
private static String evalErrorMessage(ErrorException e) { return e.getMessage() + ", eval()'s code on line " + (e.getTraceInfo().getStartLine() + 1) + ", position " + (e.getTraceInfo().getStartPosition() + 1); }
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; }
} catch (ParseException e){ TraceInfo oldTrace = e.getTraceInfo(); e.setTraceInfo(new TraceInfo( analyzer.getContext(), meta.getStartLine() + oldTrace.getStartLine(), meta.getEndLine() + oldTrace.getEndLine(), meta.getStartLine() + oldTrace.getStartLine(), meta.getEndLine() + oldTrace.getEndLine() )); throw e;
throw new CustomErrorException(e.getType(), e.getMessage() + " line: " + (e.getTraceInfo().getStartLine() + test.getSectionLine("FILE") + 2) + ", pos: " + (e.getTraceInfo().getStartPosition() + 1), e.getTraceInfo()); environment, TraceInfo.valueOf(file.getName(), 0, 0), rtrim(lastOutput), test.getExpectF() ); if (result.isNull())
@Signature public Memory getPosition(Environment env, Memory... args) { if (entity.isInternal() || entity.getTrace().isUnknown()) return Memory.FALSE; return LongMemory.valueOf(entity.getTrace().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); }
@Signature public Memory getEndLine(Environment env, Memory... args) { return LongMemory.valueOf(entity.getTrace().getEndLine()); }
@Signature public Memory getPosition(Environment env, Memory... args){ if (getClosureEntity() != null) return LongMemory.valueOf(getClosureEntity().getTrace().getStartPosition() + 1); return LongMemory.valueOf(getEntity().getTrace().getStartPosition() + 1); }
@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); }
public ModuleEntity findModule(TraceInfo traceInfo) { if (traceInfo == null || traceInfo == TraceInfo.UNKNOWN) { return null; } return findModule(traceInfo.getFileName()); }
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 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); } } }
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); } } }