PDBExtras.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. //===- PDBExtras.cpp - helper functions and classes for PDBs --------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "llvm/DebugInfo/PDB/PDBExtras.h"
  9. #include "llvm/Support/raw_ostream.h"
  10. using namespace llvm;
  11. using namespace llvm::pdb;
  12. #define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream) \
  13. case Class::Value: \
  14. Stream << Str; \
  15. break;
  16. #define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream) \
  17. CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, #Value, Stream)
  18. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
  19. const PDB_VariantType &Type) {
  20. switch (Type) {
  21. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Bool, OS)
  22. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Single, OS)
  23. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Double, OS)
  24. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int8, OS)
  25. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int16, OS)
  26. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int32, OS)
  27. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int64, OS)
  28. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt8, OS)
  29. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt16, OS)
  30. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt32, OS)
  31. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt64, OS)
  32. default:
  33. OS << "Unknown";
  34. }
  35. return OS;
  36. }
  37. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
  38. const PDB_BuiltinType &Type) {
  39. switch (Type) {
  40. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, None, OS)
  41. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Void, OS)
  42. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char, OS)
  43. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, WCharT, OS)
  44. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Int, OS)
  45. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, UInt, OS)
  46. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Float, OS)
  47. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, BCD, OS)
  48. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Bool, OS)
  49. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Long, OS)
  50. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, ULong, OS)
  51. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Currency, OS)
  52. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Date, OS)
  53. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Variant, OS)
  54. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Complex, OS)
  55. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Bitfield, OS)
  56. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, BSTR, OS)
  57. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, HResult, OS)
  58. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char16, OS)
  59. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char32, OS)
  60. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char8, OS)
  61. }
  62. return OS;
  63. }
  64. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
  65. const PDB_CallingConv &Conv) {
  66. OS << "__";
  67. switch (Conv) {
  68. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearC , "cdecl", OS)
  69. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarC , "cdecl", OS)
  70. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearPascal , "pascal", OS)
  71. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarPascal , "pascal", OS)
  72. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearFast , "fastcall", OS)
  73. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarFast , "fastcall", OS)
  74. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearStdCall, "stdcall", OS)
  75. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarStdCall , "stdcall", OS)
  76. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearSysCall, "syscall", OS)
  77. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarSysCall , "syscall", OS)
  78. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ThisCall , "thiscall", OS)
  79. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, MipsCall , "mipscall", OS)
  80. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Generic , "genericcall", OS)
  81. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AlphaCall , "alphacall", OS)
  82. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, PpcCall , "ppccall", OS)
  83. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SHCall , "superhcall", OS)
  84. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ArmCall , "armcall", OS)
  85. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AM33Call , "am33call", OS)
  86. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, TriCall , "tricall", OS)
  87. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SH5Call , "sh5call", OS)
  88. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, M32RCall , "m32rcall", OS)
  89. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ClrCall , "clrcall", OS)
  90. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline , "inlinecall", OS)
  91. CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVector , "vectorcall", OS)
  92. }
  93. return OS;
  94. }
  95. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_DataKind &Data) {
  96. switch (Data) {
  97. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Unknown, "unknown", OS)
  98. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Local, "local", OS)
  99. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, StaticLocal, "static local", OS)
  100. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Param, "param", OS)
  101. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, ObjectPtr, "this ptr", OS)
  102. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, FileStatic, "static global", OS)
  103. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Global, "global", OS)
  104. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Member, "member", OS)
  105. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, StaticMember, "static member", OS)
  106. CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Constant, "const", OS)
  107. }
  108. return OS;
  109. }
  110. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
  111. const llvm::codeview::CPURegister &CpuReg) {
  112. if (CpuReg.Cpu == llvm::codeview::CPUType::ARMNT) {
  113. switch (CpuReg.Reg) {
  114. #define CV_REGISTERS_ARM
  115. #define CV_REGISTER(name, val) \
  116. case codeview::RegisterId::name: \
  117. OS << #name; \
  118. return OS;
  119. #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
  120. #undef CV_REGISTER
  121. #undef CV_REGISTERS_ARM
  122. default:
  123. break;
  124. }
  125. } else if (CpuReg.Cpu == llvm::codeview::CPUType::ARM64) {
  126. switch (CpuReg.Reg) {
  127. #define CV_REGISTERS_ARM64
  128. #define CV_REGISTER(name, val) \
  129. case codeview::RegisterId::name: \
  130. OS << #name; \
  131. return OS;
  132. #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
  133. #undef CV_REGISTER
  134. #undef CV_REGISTERS_ARM64
  135. default:
  136. break;
  137. }
  138. } else {
  139. switch (CpuReg.Reg) {
  140. #define CV_REGISTERS_X86
  141. #define CV_REGISTER(name, val) \
  142. case codeview::RegisterId::name: \
  143. OS << #name; \
  144. return OS;
  145. #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
  146. #undef CV_REGISTER
  147. #undef CV_REGISTERS_X86
  148. default:
  149. break;
  150. }
  151. }
  152. OS << static_cast<int>(CpuReg.Reg);
  153. return OS;
  154. }
  155. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_LocType &Loc) {
  156. switch (Loc) {
  157. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Static, "static", OS)
  158. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, TLS, "tls", OS)
  159. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, RegRel, "regrel", OS)
  160. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, ThisRel, "thisrel", OS)
  161. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Enregistered, "register", OS)
  162. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, BitField, "bitfield", OS)
  163. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Slot, "slot", OS)
  164. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, IlRel, "IL rel", OS)
  165. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, MetaData, "metadata", OS)
  166. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Constant, "constant", OS)
  167. CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, RegRelAliasIndir,
  168. "regrelaliasindir", OS)
  169. default:
  170. OS << "Unknown";
  171. }
  172. return OS;
  173. }
  174. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
  175. const codeview::ThunkOrdinal &Thunk) {
  176. switch (Thunk) {
  177. CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, BranchIsland, OS)
  178. CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, Pcode, OS)
  179. CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, Standard, OS)
  180. CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, ThisAdjustor, OS)
  181. CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, TrampIncremental, OS)
  182. CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, UnknownLoad, OS)
  183. CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, Vcall, OS)
  184. }
  185. return OS;
  186. }
  187. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
  188. const PDB_Checksum &Checksum) {
  189. switch (Checksum) {
  190. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, None, OS)
  191. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, MD5, OS)
  192. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, SHA1, OS)
  193. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, SHA256, OS)
  194. }
  195. return OS;
  196. }
  197. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_Lang &Lang) {
  198. switch (Lang) {
  199. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, C, OS)
  200. CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, Cpp, "C++", OS)
  201. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Fortran, OS)
  202. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Masm, OS)
  203. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Pascal, OS)
  204. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Basic, OS)
  205. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cobol, OS)
  206. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Link, OS)
  207. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cvtres, OS)
  208. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cvtpgd, OS)
  209. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, CSharp, OS)
  210. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, VB, OS)
  211. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, ILAsm, OS)
  212. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Java, OS)
  213. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, JScript, OS)
  214. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, MSIL, OS)
  215. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, HLSL, OS)
  216. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, D, OS)
  217. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Swift, OS)
  218. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Rust, OS)
  219. }
  220. return OS;
  221. }
  222. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_SymType &Tag) {
  223. switch (Tag) {
  224. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Exe, OS)
  225. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Compiland, OS)
  226. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CompilandDetails, OS)
  227. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CompilandEnv, OS)
  228. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Function, OS)
  229. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Block, OS)
  230. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Data, OS)
  231. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Annotation, OS)
  232. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Label, OS)
  233. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, PublicSymbol, OS)
  234. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, UDT, OS)
  235. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Enum, OS)
  236. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FunctionSig, OS)
  237. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, PointerType, OS)
  238. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, ArrayType, OS)
  239. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BuiltinType, OS)
  240. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Typedef, OS)
  241. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BaseClass, OS)
  242. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Friend, OS)
  243. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FunctionArg, OS)
  244. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FuncDebugStart, OS)
  245. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FuncDebugEnd, OS)
  246. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, UsingNamespace, OS)
  247. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VTableShape, OS)
  248. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VTable, OS)
  249. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Custom, OS)
  250. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Thunk, OS)
  251. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CustomType, OS)
  252. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, ManagedType, OS)
  253. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Dimension, OS)
  254. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CallSite, OS)
  255. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, InlineSite, OS)
  256. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BaseInterface, OS)
  257. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VectorType, OS)
  258. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, MatrixType, OS)
  259. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, HLSLType, OS)
  260. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Caller, OS)
  261. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Callee, OS)
  262. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Export, OS)
  263. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, HeapAllocationSite, OS)
  264. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CoffGroup, OS)
  265. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Inlinee, OS)
  266. default:
  267. OS << "Unknown SymTag " << uint32_t(Tag);
  268. }
  269. return OS;
  270. }
  271. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
  272. const PDB_MemberAccess &Access) {
  273. switch (Access) {
  274. CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Public, "public", OS)
  275. CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Protected, "protected", OS)
  276. CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Private, "private", OS)
  277. }
  278. return OS;
  279. }
  280. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_UdtType &Type) {
  281. switch (Type) {
  282. CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
  283. CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Struct, "struct", OS)
  284. CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Interface, "interface", OS)
  285. CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Union, "union", OS)
  286. }
  287. return OS;
  288. }
  289. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
  290. const PDB_Machine &Machine) {
  291. switch (Machine) {
  292. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Am33, OS)
  293. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Amd64, OS)
  294. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Arm, OS)
  295. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, ArmNT, OS)
  296. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Ebc, OS)
  297. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, x86, OS)
  298. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Ia64, OS)
  299. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, M32R, OS)
  300. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Mips16, OS)
  301. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, MipsFpu, OS)
  302. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, MipsFpu16, OS)
  303. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, PowerPC, OS)
  304. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, PowerPCFP, OS)
  305. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, R4000, OS)
  306. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH3, OS)
  307. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH3DSP, OS)
  308. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH4, OS)
  309. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH5, OS)
  310. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Thumb, OS)
  311. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, WceMipsV2, OS)
  312. default:
  313. OS << "Unknown";
  314. }
  315. return OS;
  316. }
  317. raw_ostream &llvm::pdb::dumpPDBSourceCompression(raw_ostream &OS,
  318. uint32_t Compression) {
  319. switch (Compression) {
  320. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, None, OS)
  321. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, Huffman, OS)
  322. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, LZ, OS)
  323. CASE_OUTPUT_ENUM_CLASS_STR(PDB_SourceCompression, RunLengthEncoded, "RLE",
  324. OS)
  325. CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, DotNet, OS)
  326. default:
  327. OS << "Unknown (" << Compression << ")";
  328. }
  329. return OS;
  330. }
  331. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const Variant &Value) {
  332. switch (Value.Type) {
  333. case PDB_VariantType::Bool:
  334. OS << (Value.Value.Bool ? "true" : "false");
  335. break;
  336. case PDB_VariantType::Double:
  337. OS << Value.Value.Double;
  338. break;
  339. case PDB_VariantType::Int16:
  340. OS << Value.Value.Int16;
  341. break;
  342. case PDB_VariantType::Int32:
  343. OS << Value.Value.Int32;
  344. break;
  345. case PDB_VariantType::Int64:
  346. OS << Value.Value.Int64;
  347. break;
  348. case PDB_VariantType::Int8:
  349. OS << static_cast<int>(Value.Value.Int8);
  350. break;
  351. case PDB_VariantType::Single:
  352. OS << Value.Value.Single;
  353. break;
  354. case PDB_VariantType::UInt16:
  355. OS << Value.Value.UInt16;
  356. break;
  357. case PDB_VariantType::UInt32:
  358. OS << Value.Value.UInt32;
  359. break;
  360. case PDB_VariantType::UInt64:
  361. OS << Value.Value.UInt64;
  362. break;
  363. case PDB_VariantType::UInt8:
  364. OS << static_cast<unsigned>(Value.Value.UInt8);
  365. break;
  366. case PDB_VariantType::String:
  367. OS << Value.Value.String;
  368. break;
  369. default:
  370. OS << Value.Type;
  371. }
  372. return OS;
  373. }
  374. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
  375. const VersionInfo &Version) {
  376. OS << Version.Major << "." << Version.Minor << "." << Version.Build;
  377. return OS;
  378. }
  379. raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const TagStats &Stats) {
  380. for (auto Tag : Stats) {
  381. OS << Tag.first << ":" << Tag.second << " ";
  382. }
  383. return OS;
  384. }