示例#1
0
        // Looks up the Cmd at a given index into the trace
        public Cmd getTraceCmd(TraceLocation loc)
        {
            Debug.Assert(loc.numBlock < Trace.Count);
            Block b = Trace[loc.numBlock];

            Debug.Assert(loc.numInstr < b.Cmds.Count);
            return(b.Cmds[loc.numInstr]);
        }
示例#2
0
        public void Print(int indent, TextWriter tw, Action <Block> blockAction = null)
        {
            int    numBlock = -1;
            string ind      = new string(' ', indent);

            foreach (Block b in Trace)
            {
                Contract.Assert(b != null);
                numBlock++;
                if (b.tok == null)
                {
                    tw.WriteLine("{0}<intermediate block>", ind);
                }
                else
                {
                    // for ErrorTrace == 1 restrict the output;
                    // do not print tokens with -17:-4 as their location because they have been
                    // introduced in the translation and do not give any useful feedback to the user
                    if (!(CommandLineOptions.Clo.ErrorTrace == 1 && b.tok.line == -17 && b.tok.col == -4))
                    {
                        if (blockAction != null)
                        {
                            blockAction(b);
                        }

                        tw.WriteLine("{4}{0}({1},{2}): {3}", b.tok.filename, b.tok.line, b.tok.col, b.Label, ind);

                        for (int numInstr = 0; numInstr < b.Cmds.Count; numInstr++)
                        {
                            var loc = new TraceLocation(numBlock, numInstr);
                            if (calleeCounterexamples.ContainsKey(loc))
                            {
                                var cmd        = getTraceCmd(loc);
                                var calleeName = getCalledProcName(cmd);
                                if (calleeName.StartsWith(VC.StratifiedVCGen.recordProcName) &&
                                    CommandLineOptions.Clo.StratifiedInlining > 0)
                                {
                                    Contract.Assert(calleeCounterexamples[loc].args.Count == 1);
                                    var arg = calleeCounterexamples[loc].args[0];
                                    tw.WriteLine("{0}value = {1}", ind, arg.ToString());
                                }
                                else
                                {
                                    tw.WriteLine("{1}Inlined call to procedure {0} begins", calleeName, ind);
                                    calleeCounterexamples[loc].counterexample.Print(indent + 4, tw);
                                    tw.WriteLine("{1}Inlined call to procedure {0} ends", calleeName, ind);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#3
0
 public void AddCalleeCounterexample(TraceLocation loc, CalleeCounterexampleInfo cex)
 {
     Contract.Requires(cex != null);
     calleeCounterexamples[loc] = cex;
 }