1 //===- lib/DebugInfo/Symbolize/DIPrinter.cpp ------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the DIPrinter class, which is responsible for printing
11 // structures defined in DebugInfo/DIContext.h
13 //===----------------------------------------------------------------------===//
15 #include "llvm/DebugInfo/Symbolize/DIPrinter.h"
17 #include "llvm/DebugInfo/DIContext.h"
22 // By default, DILineInfo contains "<invalid>" for function/filename it
23 // cannot fetch. We replace it to "??" to make our output closer to addr2line.
24 static const char kDILineInfoBadString[] = "<invalid>";
25 static const char kBadString[] = "??";
27 DIPrinter &DIPrinter::operator<<(const DILineInfo &Info) {
28 if (PrintFunctionNames) {
29 std::string FunctionName = Info.FunctionName;
30 if (FunctionName == kDILineInfoBadString)
31 FunctionName = kBadString;
32 OS << FunctionName << "\n";
34 std::string Filename = Info.FileName;
35 if (Filename == kDILineInfoBadString)
36 Filename = kBadString;
37 OS << Filename << ":" << Info.Line << ":" << Info.Column << "\n";
41 DIPrinter &DIPrinter::operator<<(const DIInliningInfo &Info) {
42 uint32_t FramesNum = Info.getNumberOfFrames();
44 return (*this << DILineInfo());
45 for (uint32_t i = 0; i < FramesNum; i++) {
46 *this << Info.getFrame(i);
51 DIPrinter &DIPrinter::operator<<(const DIGlobal &Global) {
52 std::string Name = Global.Name;
53 if (Name == kDILineInfoBadString)
56 OS << Global.Start << " " << Global.Size << "\n";