Remove the MachineMove class.
[oota-llvm.git] / tools / llvm-objdump / MachODump.cpp
1 //===-- MachODump.cpp - Object file dumping utility for llvm --------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the MachO-specific dumper for llvm-objdump.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm-objdump.h"
15 #include "MCFunction.h"
16 #include "llvm/ADT/OwningPtr.h"
17 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/DebugInfo/DIContext.h"
20 #include "llvm/MC/MCAsmInfo.h"
21 #include "llvm/MC/MCDisassembler.h"
22 #include "llvm/MC/MCInst.h"
23 #include "llvm/MC/MCInstPrinter.h"
24 #include "llvm/MC/MCInstrAnalysis.h"
25 #include "llvm/MC/MCInstrDesc.h"
26 #include "llvm/MC/MCInstrInfo.h"
27 #include "llvm/MC/MCRegisterInfo.h"
28 #include "llvm/MC/MCSubtargetInfo.h"
29 #include "llvm/Object/MachO.h"
30 #include "llvm/Support/Casting.h"
31 #include "llvm/Support/CommandLine.h"
32 #include "llvm/Support/Debug.h"
33 #include "llvm/Support/Format.h"
34 #include "llvm/Support/GraphWriter.h"
35 #include "llvm/Support/MachO.h"
36 #include "llvm/Support/MemoryBuffer.h"
37 #include "llvm/Support/TargetRegistry.h"
38 #include "llvm/Support/TargetSelect.h"
39 #include "llvm/Support/raw_ostream.h"
40 #include "llvm/Support/system_error.h"
41 #include <algorithm>
42 #include <cstring>
43 using namespace llvm;
44 using namespace object;
45
46 static cl::opt<bool>
47   CFG("cfg", cl::desc("Create a CFG for every symbol in the object file and"
48                       " write it to a graphviz file (MachO-only)"));
49
50 static cl::opt<bool>
51   UseDbg("g", cl::desc("Print line information from debug info if available"));
52
53 static cl::opt<std::string>
54   DSYMFile("dsym", cl::desc("Use .dSYM file for debug info"));
55
56 static const Target *GetTarget(const MachOObjectFile *MachOObj) {
57   // Figure out the target triple.
58   if (TripleName.empty()) {
59     llvm::Triple TT("unknown-unknown-unknown");
60     TT.setArch(Triple::ArchType(MachOObj->getArch()));
61     TripleName = TT.str();
62   }
63
64   // Get the target specific parser.
65   std::string Error;
66   const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
67   if (TheTarget)
68     return TheTarget;
69
70   errs() << "llvm-objdump: error: unable to get target for '" << TripleName
71          << "', see --version and --triple.\n";
72   return 0;
73 }
74
75 struct SymbolSorter {
76   bool operator()(const SymbolRef &A, const SymbolRef &B) {
77     SymbolRef::Type AType, BType;
78     A.getType(AType);
79     B.getType(BType);
80
81     uint64_t AAddr, BAddr;
82     if (AType != SymbolRef::ST_Function)
83       AAddr = 0;
84     else
85       A.getAddress(AAddr);
86     if (BType != SymbolRef::ST_Function)
87       BAddr = 0;
88     else
89       B.getAddress(BAddr);
90     return AAddr < BAddr;
91   }
92 };
93
94 // Print additional information about an address, if available.
95 static void DumpAddress(uint64_t Address, ArrayRef<SectionRef> Sections,
96                         const MachOObjectFile *MachOObj, raw_ostream &OS) {
97   for (unsigned i = 0; i != Sections.size(); ++i) {
98     uint64_t SectAddr = 0, SectSize = 0;
99     Sections[i].getAddress(SectAddr);
100     Sections[i].getSize(SectSize);
101     uint64_t addr = SectAddr;
102     if (SectAddr <= Address &&
103         SectAddr + SectSize > Address) {
104       StringRef bytes, name;
105       Sections[i].getContents(bytes);
106       Sections[i].getName(name);
107       // Print constant strings.
108       if (!name.compare("__cstring"))
109         OS << '"' << bytes.substr(addr, bytes.find('\0', addr)) << '"';
110       // Print constant CFStrings.
111       if (!name.compare("__cfstring"))
112         OS << "@\"" << bytes.substr(addr, bytes.find('\0', addr)) << '"';
113     }
114   }
115 }
116
117 typedef std::map<uint64_t, MCFunction*> FunctionMapTy;
118 typedef SmallVector<MCFunction, 16> FunctionListTy;
119 static void createMCFunctionAndSaveCalls(StringRef Name,
120                                          const MCDisassembler *DisAsm,
121                                          MemoryObject &Object, uint64_t Start,
122                                          uint64_t End,
123                                          MCInstrAnalysis *InstrAnalysis,
124                                          uint64_t Address,
125                                          raw_ostream &DebugOut,
126                                          FunctionMapTy &FunctionMap,
127                                          FunctionListTy &Functions) {
128   SmallVector<uint64_t, 16> Calls;
129   MCFunction f =
130     MCFunction::createFunctionFromMC(Name, DisAsm, Object, Start, End,
131                                      InstrAnalysis, DebugOut, Calls);
132   Functions.push_back(f);
133   FunctionMap[Address] = &Functions.back();
134
135   // Add the gathered callees to the map.
136   for (unsigned i = 0, e = Calls.size(); i != e; ++i)
137     FunctionMap.insert(std::make_pair(Calls[i], (MCFunction*)0));
138 }
139
140 // Write a graphviz file for the CFG inside an MCFunction.
141 static void emitDOTFile(const char *FileName, const MCFunction &f,
142                         MCInstPrinter *IP) {
143   // Start a new dot file.
144   std::string Error;
145   raw_fd_ostream Out(FileName, Error);
146   if (!Error.empty()) {
147     errs() << "llvm-objdump: warning: " << Error << '\n';
148     return;
149   }
150
151   Out << "digraph " << f.getName() << " {\n";
152   Out << "graph [ rankdir = \"LR\" ];\n";
153   for (MCFunction::iterator i = f.begin(), e = f.end(); i != e; ++i) {
154     bool hasPreds = false;
155     // Only print blocks that have predecessors.
156     // FIXME: Slow.
157     for (MCFunction::iterator pi = f.begin(), pe = f.end(); pi != pe;
158         ++pi)
159       if (pi->second.contains(i->first)) {
160         hasPreds = true;
161         break;
162       }
163
164     if (!hasPreds && i != f.begin())
165       continue;
166
167     Out << '"' << i->first << "\" [ label=\"<a>";
168     // Print instructions.
169     for (unsigned ii = 0, ie = i->second.getInsts().size(); ii != ie;
170         ++ii) {
171       // Escape special chars and print the instruction in mnemonic form.
172       std::string Str;
173       raw_string_ostream OS(Str);
174       IP->printInst(&i->second.getInsts()[ii].Inst, OS, "");
175       Out << DOT::EscapeString(OS.str()) << '|';
176     }
177     Out << "<o>\" shape=\"record\" ];\n";
178
179     // Add edges.
180     for (MCBasicBlock::succ_iterator si = i->second.succ_begin(),
181         se = i->second.succ_end(); si != se; ++si)
182       Out << i->first << ":o -> " << *si <<":a\n";
183   }
184   Out << "}\n";
185 }
186
187 static void
188 getSectionsAndSymbols(const macho::Header Header,
189                       MachOObjectFile *MachOObj,
190                       std::vector<SectionRef> &Sections,
191                       std::vector<SymbolRef> &Symbols,
192                       SmallVectorImpl<uint64_t> &FoundFns) {
193   error_code ec;
194   for (symbol_iterator SI = MachOObj->begin_symbols(),
195        SE = MachOObj->end_symbols(); SI != SE; SI.increment(ec))
196     Symbols.push_back(*SI);
197
198   for (section_iterator SI = MachOObj->begin_sections(),
199        SE = MachOObj->end_sections(); SI != SE; SI.increment(ec)) {
200     SectionRef SR = *SI;
201     StringRef SectName;
202     SR.getName(SectName);
203     Sections.push_back(*SI);
204   }
205
206   MachOObjectFile::LoadCommandInfo Command =
207     MachOObj->getFirstLoadCommandInfo();
208   for (unsigned i = 0; ; ++i) {
209     if (Command.C.Type == macho::LCT_FunctionStarts) {
210       // We found a function starts segment, parse the addresses for later
211       // consumption.
212       macho::LinkeditDataLoadCommand LLC =
213         MachOObj->getLinkeditDataLoadCommand(Command);
214
215       MachOObj->ReadULEB128s(LLC.DataOffset, FoundFns);
216     }
217
218     if (i == Header.NumLoadCommands - 1)
219       break;
220     else
221       Command = MachOObj->getNextLoadCommandInfo(Command);
222   }
223 }
224
225 static void DisassembleInputMachO2(StringRef Filename,
226                                    MachOObjectFile *MachOOF);
227
228 void llvm::DisassembleInputMachO(StringRef Filename) {
229   OwningPtr<MemoryBuffer> Buff;
230
231   if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
232     errs() << "llvm-objdump: " << Filename << ": " << ec.message() << "\n";
233     return;
234   }
235
236   OwningPtr<MachOObjectFile> MachOOF(static_cast<MachOObjectFile*>(
237         ObjectFile::createMachOObjectFile(Buff.take())));
238
239   DisassembleInputMachO2(Filename, MachOOF.get());
240 }
241
242 static void DisassembleInputMachO2(StringRef Filename,
243                                    MachOObjectFile *MachOOF) {
244   const Target *TheTarget = GetTarget(MachOOF);
245   if (!TheTarget) {
246     // GetTarget prints out stuff.
247     return;
248   }
249   OwningPtr<const MCInstrInfo> InstrInfo(TheTarget->createMCInstrInfo());
250   OwningPtr<MCInstrAnalysis>
251     InstrAnalysis(TheTarget->createMCInstrAnalysis(InstrInfo.get()));
252
253   // Set up disassembler.
254   OwningPtr<const MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
255   OwningPtr<const MCAsmInfo> AsmInfo(
256       TheTarget->createMCAsmInfo(*MRI, TripleName));
257   OwningPtr<const MCSubtargetInfo>
258     STI(TheTarget->createMCSubtargetInfo(TripleName, "", ""));
259   OwningPtr<const MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI));
260   int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
261   OwningPtr<MCInstPrinter>
262     IP(TheTarget->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *InstrInfo,
263                                       *MRI, *STI));
264
265   if (!InstrAnalysis || !AsmInfo || !STI || !DisAsm || !IP) {
266     errs() << "error: couldn't initialize disassembler for target "
267            << TripleName << '\n';
268     return;
269   }
270
271   outs() << '\n' << Filename << ":\n\n";
272
273   macho::Header Header = MachOOF->getHeader();
274
275   std::vector<SectionRef> Sections;
276   std::vector<SymbolRef> Symbols;
277   SmallVector<uint64_t, 8> FoundFns;
278
279   getSectionsAndSymbols(Header, MachOOF, Sections, Symbols, FoundFns);
280
281   // Make a copy of the unsorted symbol list. FIXME: duplication
282   std::vector<SymbolRef> UnsortedSymbols(Symbols);
283   // Sort the symbols by address, just in case they didn't come in that way.
284   std::sort(Symbols.begin(), Symbols.end(), SymbolSorter());
285
286 #ifndef NDEBUG
287   raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
288 #else
289   raw_ostream &DebugOut = nulls();
290 #endif
291
292   OwningPtr<DIContext> diContext;
293   ObjectFile *DbgObj = MachOOF;
294   // Try to find debug info and set up the DIContext for it.
295   if (UseDbg) {
296     // A separate DSym file path was specified, parse it as a macho file,
297     // get the sections and supply it to the section name parsing machinery.
298     if (!DSYMFile.empty()) {
299       OwningPtr<MemoryBuffer> Buf;
300       if (error_code ec = MemoryBuffer::getFileOrSTDIN(DSYMFile.c_str(), Buf)) {
301         errs() << "llvm-objdump: " << Filename << ": " << ec.message() << '\n';
302         return;
303       }
304       DbgObj = ObjectFile::createMachOObjectFile(Buf.take());
305     }
306
307     // Setup the DIContext
308     diContext.reset(DIContext::getDWARFContext(DbgObj));
309   }
310
311   FunctionMapTy FunctionMap;
312   FunctionListTy Functions;
313
314   for (unsigned SectIdx = 0; SectIdx != Sections.size(); SectIdx++) {
315     StringRef SectName;
316     if (Sections[SectIdx].getName(SectName) ||
317         SectName != "__text")
318       continue; // Skip non-text sections
319
320     DataRefImpl DR = Sections[SectIdx].getRawDataRefImpl();
321     StringRef SegmentName = MachOOF->getSectionFinalSegmentName(DR);
322     if (SegmentName != "__TEXT")
323       continue;
324
325     // Insert the functions from the function starts segment into our map.
326     uint64_t VMAddr;
327     Sections[SectIdx].getAddress(VMAddr);
328     for (unsigned i = 0, e = FoundFns.size(); i != e; ++i) {
329       StringRef SectBegin;
330       Sections[SectIdx].getContents(SectBegin);
331       uint64_t Offset = (uint64_t)SectBegin.data();
332       FunctionMap.insert(std::make_pair(VMAddr + FoundFns[i]-Offset,
333                                         (MCFunction*)0));
334     }
335
336     StringRef Bytes;
337     Sections[SectIdx].getContents(Bytes);
338     StringRefMemoryObject memoryObject(Bytes);
339     bool symbolTableWorked = false;
340
341     // Parse relocations.
342     std::vector<std::pair<uint64_t, SymbolRef> > Relocs;
343     error_code ec;
344     for (relocation_iterator RI = Sections[SectIdx].begin_relocations(),
345          RE = Sections[SectIdx].end_relocations(); RI != RE; RI.increment(ec)) {
346       uint64_t RelocOffset, SectionAddress;
347       RI->getOffset(RelocOffset);
348       Sections[SectIdx].getAddress(SectionAddress);
349       RelocOffset -= SectionAddress;
350
351       SymbolRef RelocSym;
352       RI->getSymbol(RelocSym);
353
354       Relocs.push_back(std::make_pair(RelocOffset, RelocSym));
355     }
356     array_pod_sort(Relocs.begin(), Relocs.end());
357
358     // Disassemble symbol by symbol.
359     for (unsigned SymIdx = 0; SymIdx != Symbols.size(); SymIdx++) {
360       StringRef SymName;
361       Symbols[SymIdx].getName(SymName);
362
363       SymbolRef::Type ST;
364       Symbols[SymIdx].getType(ST);
365       if (ST != SymbolRef::ST_Function)
366         continue;
367
368       // Make sure the symbol is defined in this section.
369       bool containsSym = false;
370       Sections[SectIdx].containsSymbol(Symbols[SymIdx], containsSym);
371       if (!containsSym)
372         continue;
373
374       // Start at the address of the symbol relative to the section's address.
375       uint64_t SectionAddress = 0;
376       uint64_t Start = 0;
377       Sections[SectIdx].getAddress(SectionAddress);
378       Symbols[SymIdx].getAddress(Start);
379       Start -= SectionAddress;
380
381       // Stop disassembling either at the beginning of the next symbol or at
382       // the end of the section.
383       bool containsNextSym = false;
384       uint64_t NextSym = 0;
385       uint64_t NextSymIdx = SymIdx+1;
386       while (Symbols.size() > NextSymIdx) {
387         SymbolRef::Type NextSymType;
388         Symbols[NextSymIdx].getType(NextSymType);
389         if (NextSymType == SymbolRef::ST_Function) {
390           Sections[SectIdx].containsSymbol(Symbols[NextSymIdx],
391                                            containsNextSym);
392           Symbols[NextSymIdx].getAddress(NextSym);
393           NextSym -= SectionAddress;
394           break;
395         }
396         ++NextSymIdx;
397       }
398
399       uint64_t SectSize;
400       Sections[SectIdx].getSize(SectSize);
401       uint64_t End = containsNextSym ?  NextSym : SectSize;
402       uint64_t Size;
403
404       symbolTableWorked = true;
405
406       if (!CFG) {
407         // Normal disassembly, print addresses, bytes and mnemonic form.
408         StringRef SymName;
409         Symbols[SymIdx].getName(SymName);
410
411         outs() << SymName << ":\n";
412         DILineInfo lastLine;
413         for (uint64_t Index = Start; Index < End; Index += Size) {
414           MCInst Inst;
415
416           if (DisAsm->getInstruction(Inst, Size, memoryObject, Index,
417                                      DebugOut, nulls())) {
418             uint64_t SectAddress = 0;
419             Sections[SectIdx].getAddress(SectAddress);
420             outs() << format("%8" PRIx64 ":\t", SectAddress + Index);
421
422             DumpBytes(StringRef(Bytes.data() + Index, Size));
423             IP->printInst(&Inst, outs(), "");
424
425             // Print debug info.
426             if (diContext) {
427               DILineInfo dli =
428                 diContext->getLineInfoForAddress(SectAddress + Index);
429               // Print valid line info if it changed.
430               if (dli != lastLine && dli.getLine() != 0)
431                 outs() << "\t## " << dli.getFileName() << ':'
432                        << dli.getLine() << ':' << dli.getColumn();
433               lastLine = dli;
434             }
435             outs() << "\n";
436           } else {
437             errs() << "llvm-objdump: warning: invalid instruction encoding\n";
438             if (Size == 0)
439               Size = 1; // skip illegible bytes
440           }
441         }
442       } else {
443         // Create CFG and use it for disassembly.
444         StringRef SymName;
445         Symbols[SymIdx].getName(SymName);
446         createMCFunctionAndSaveCalls(
447             SymName, DisAsm.get(), memoryObject, Start, End,
448             InstrAnalysis.get(), Start, DebugOut, FunctionMap, Functions);
449       }
450     }
451     if (!CFG && !symbolTableWorked) {
452       // Reading the symbol table didn't work, disassemble the whole section. 
453       uint64_t SectAddress;
454       Sections[SectIdx].getAddress(SectAddress);
455       uint64_t SectSize;
456       Sections[SectIdx].getSize(SectSize);
457       uint64_t InstSize;
458       for (uint64_t Index = 0; Index < SectSize; Index += InstSize) {
459         MCInst Inst;
460
461         if (DisAsm->getInstruction(Inst, InstSize, memoryObject, Index,
462                                    DebugOut, nulls())) {
463           outs() << format("%8" PRIx64 ":\t", SectAddress + Index);
464           DumpBytes(StringRef(Bytes.data() + Index, InstSize));
465           IP->printInst(&Inst, outs(), "");
466           outs() << "\n";
467         } else {
468           errs() << "llvm-objdump: warning: invalid instruction encoding\n";
469           if (InstSize == 0)
470             InstSize = 1; // skip illegible bytes
471         }
472       }
473     }
474
475     if (CFG) {
476       if (!symbolTableWorked) {
477         // Reading the symbol table didn't work, create a big __TEXT symbol.
478         uint64_t SectSize = 0, SectAddress = 0;
479         Sections[SectIdx].getSize(SectSize);
480         Sections[SectIdx].getAddress(SectAddress);
481         createMCFunctionAndSaveCalls("__TEXT", DisAsm.get(), memoryObject,
482                                      0, SectSize,
483                                      InstrAnalysis.get(),
484                                      SectAddress, DebugOut,
485                                      FunctionMap, Functions);
486       }
487       for (std::map<uint64_t, MCFunction*>::iterator mi = FunctionMap.begin(),
488            me = FunctionMap.end(); mi != me; ++mi)
489         if (mi->second == 0) {
490           // Create functions for the remaining callees we have gathered,
491           // but we didn't find a name for them.
492           uint64_t SectSize = 0;
493           Sections[SectIdx].getSize(SectSize);
494
495           SmallVector<uint64_t, 16> Calls;
496           MCFunction f =
497             MCFunction::createFunctionFromMC("unknown", DisAsm.get(),
498                                              memoryObject, mi->first,
499                                              SectSize,
500                                              InstrAnalysis.get(), DebugOut,
501                                              Calls);
502           Functions.push_back(f);
503           mi->second = &Functions.back();
504           for (unsigned i = 0, e = Calls.size(); i != e; ++i) {
505             std::pair<uint64_t, MCFunction*> p(Calls[i], (MCFunction*)0);
506             if (FunctionMap.insert(p).second)
507               mi = FunctionMap.begin();
508           }
509         }
510
511       DenseSet<uint64_t> PrintedBlocks;
512       for (unsigned ffi = 0, ffe = Functions.size(); ffi != ffe; ++ffi) {
513         MCFunction &f = Functions[ffi];
514         for (MCFunction::iterator fi = f.begin(), fe = f.end(); fi != fe; ++fi){
515           if (!PrintedBlocks.insert(fi->first).second)
516             continue; // We already printed this block.
517
518           // We assume a block has predecessors when it's the first block after
519           // a symbol.
520           bool hasPreds = FunctionMap.find(fi->first) != FunctionMap.end();
521
522           // See if this block has predecessors.
523           // FIXME: Slow.
524           for (MCFunction::iterator pi = f.begin(), pe = f.end(); pi != pe;
525               ++pi)
526             if (pi->second.contains(fi->first)) {
527               hasPreds = true;
528               break;
529             }
530
531           uint64_t SectSize = 0, SectAddress;
532           Sections[SectIdx].getSize(SectSize);
533           Sections[SectIdx].getAddress(SectAddress);
534
535           // No predecessors, this is a data block. Print as .byte directives.
536           if (!hasPreds) {
537             uint64_t End = llvm::next(fi) == fe ? SectSize :
538                                                   llvm::next(fi)->first;
539             outs() << "# " << End-fi->first << " bytes of data:\n";
540             for (unsigned pos = fi->first; pos != End; ++pos) {
541               outs() << format("%8x:\t", SectAddress + pos);
542               DumpBytes(StringRef(Bytes.data() + pos, 1));
543               outs() << format("\t.byte 0x%02x\n", (uint8_t)Bytes[pos]);
544             }
545             continue;
546           }
547
548           if (fi->second.contains(fi->first)) // Print a header for simple loops
549             outs() << "# Loop begin:\n";
550
551           DILineInfo lastLine;
552           // Walk over the instructions and print them.
553           for (unsigned ii = 0, ie = fi->second.getInsts().size(); ii != ie;
554                ++ii) {
555             const MCDecodedInst &Inst = fi->second.getInsts()[ii];
556
557             // If there's a symbol at this address, print its name.
558             if (FunctionMap.find(SectAddress + Inst.Address) !=
559                 FunctionMap.end())
560               outs() << FunctionMap[SectAddress + Inst.Address]-> getName()
561                      << ":\n";
562
563             outs() << format("%8" PRIx64 ":\t", SectAddress + Inst.Address);
564             DumpBytes(StringRef(Bytes.data() + Inst.Address, Inst.Size));
565
566             if (fi->second.contains(fi->first)) // Indent simple loops.
567               outs() << '\t';
568
569             IP->printInst(&Inst.Inst, outs(), "");
570
571             // Look for relocations inside this instructions, if there is one
572             // print its target and additional information if available.
573             for (unsigned j = 0; j != Relocs.size(); ++j)
574               if (Relocs[j].first >= SectAddress + Inst.Address &&
575                   Relocs[j].first < SectAddress + Inst.Address + Inst.Size) {
576                 StringRef SymName;
577                 uint64_t Addr;
578                 Relocs[j].second.getAddress(Addr);
579                 Relocs[j].second.getName(SymName);
580
581                 outs() << "\t# " << SymName << ' ';
582                 DumpAddress(Addr, Sections, MachOOF, outs());
583               }
584
585             // If this instructions contains an address, see if we can evaluate
586             // it and print additional information.
587             uint64_t targ = InstrAnalysis->evaluateBranch(Inst.Inst,
588                                                           Inst.Address,
589                                                           Inst.Size);
590             if (targ != -1ULL)
591               DumpAddress(targ, Sections, MachOOF, outs());
592
593             // Print debug info.
594             if (diContext) {
595               DILineInfo dli =
596                 diContext->getLineInfoForAddress(SectAddress + Inst.Address);
597               // Print valid line info if it changed.
598               if (dli != lastLine && dli.getLine() != 0)
599                 outs() << "\t## " << dli.getFileName() << ':'
600                        << dli.getLine() << ':' << dli.getColumn();
601               lastLine = dli;
602             }
603
604             outs() << '\n';
605           }
606         }
607
608         emitDOTFile((f.getName().str() + ".dot").c_str(), f, IP.get());
609       }
610     }
611   }
612 }