blob: f014b3959b0a3de63454ca38732c5dcbf5d725fc [file] [log] [blame]
Zachary Turner21473f72015-02-08 00:29:29 +00001//===- PDBSymbolCompiland.cpp - compiland details --------*- C++ -*-===//
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
Zachary Turner52c9f882015-02-14 03:53:56 +000010#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
11
Zachary Turner21473f72015-02-08 00:29:29 +000012#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
Zachary Turnera5549172015-02-10 22:43:25 +000013#include "llvm/DebugInfo/PDB/IPDBSession.h"
14#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
15#include "llvm/DebugInfo/PDB/PDBExtras.h"
Zachary Turner21473f72015-02-08 00:29:29 +000016#include "llvm/DebugInfo/PDB/PDBSymbol.h"
Zachary Turner21473f72015-02-08 00:29:29 +000017#include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h"
Zachary Turnera5549172015-02-10 22:43:25 +000018#include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h"
Zachary Turnerc074de02015-02-12 21:09:24 +000019#include "llvm/Support/Path.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000020#include "llvm/Support/raw_ostream.h"
Zachary Turner52c9f882015-02-14 03:53:56 +000021
Chandler Carruth71f308a2015-02-13 09:09:03 +000022#include <utility>
23#include <vector>
Zachary Turner21473f72015-02-08 00:29:29 +000024
25using namespace llvm;
26
Zachary Turner98571ed2015-02-08 22:53:53 +000027PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
Zachary Turnerbae16b32015-02-08 20:58:09 +000028 std::unique_ptr<IPDBRawSymbol> Symbol)
29 : PDBSymbol(PDBSession, std::move(Symbol)) {}
Zachary Turner21473f72015-02-08 00:29:29 +000030
Zachary Turnerc0acf682015-02-15 20:27:53 +000031#define SKIP_SYMBOL_IF_FLAG_UNSET(Tag, Flag) \
32 case PDB_SymType::Tag: \
33 if ((Flags & Flag) == 0) \
34 continue; \
35 break;
36
Zachary Turnera5549172015-02-10 22:43:25 +000037void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent,
Zachary Turnerc0acf682015-02-15 20:27:53 +000038 PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
Zachary Turnera952c492015-02-13 07:40:03 +000039 if (Level == PDB_DumpLevel::Detailed) {
40 std::string FullName = getName();
Zachary Turnerc0acf682015-02-15 20:27:53 +000041 OS << stream_indent(Indent) << FullName;
42 if (Flags & PDB_DF_Children) {
43 if (Level >= PDB_DumpLevel::Detailed) {
44 auto ChildrenEnum = findAllChildren();
45 while (auto Child = ChildrenEnum->getNext()) {
46 switch (Child->getSymTag()) {
47 SKIP_SYMBOL_IF_FLAG_UNSET(Function, PDB_DF_Functions)
48 SKIP_SYMBOL_IF_FLAG_UNSET(Data, PDB_DF_Data)
49 SKIP_SYMBOL_IF_FLAG_UNSET(Label, PDB_DF_Labels)
50 SKIP_SYMBOL_IF_FLAG_UNSET(PublicSymbol, PDB_DF_PublicSyms)
51 SKIP_SYMBOL_IF_FLAG_UNSET(UDT, PDB_DF_Classes)
52 SKIP_SYMBOL_IF_FLAG_UNSET(Enum, PDB_DF_Enums)
53 SKIP_SYMBOL_IF_FLAG_UNSET(FunctionSig, PDB_DF_Funcsigs)
54 SKIP_SYMBOL_IF_FLAG_UNSET(VTable, PDB_DF_VTables)
55 SKIP_SYMBOL_IF_FLAG_UNSET(Thunk, PDB_DF_Thunks)
56 SKIP_SYMBOL_IF_FLAG_UNSET(Compiland, PDB_DF_ObjFiles)
57 default:
58 continue;
59 }
60 PDB_DumpLevel ChildLevel = (Level == PDB_DumpLevel::Detailed)
61 ? PDB_DumpLevel::Normal
62 : PDB_DumpLevel::Compact;
63 OS << "\n";
64 Child->dump(OS, Indent + 2, ChildLevel, PDB_DF_Children);
65 }
Zachary Turnera952c492015-02-13 07:40:03 +000066 }
Zachary Turnera5549172015-02-10 22:43:25 +000067 }
Zachary Turnera952c492015-02-13 07:40:03 +000068 } else {
69 std::string FullName = getName();
70 OS << stream_indent(Indent) << "Compiland: " << FullName;
Zachary Turnera5549172015-02-10 22:43:25 +000071 }
Zachary Turner21473f72015-02-08 00:29:29 +000072}