llvm-pdbutil.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. llvm-pdbutil - PDB File forensics and diagnostics
  2. =================================================
  3. .. program:: llvm-pdbutil
  4. .. contents::
  5. :local:
  6. Synopsis
  7. --------
  8. :program:`llvm-pdbutil` [*subcommand*] [*options*]
  9. Description
  10. -----------
  11. Display types, symbols, CodeView records, and other information from a
  12. PDB file, as well as manipulate and create PDB files. :program:`llvm-pdbutil`
  13. is normally used by FileCheck-based tests to test LLVM's PDB reading and
  14. writing functionality, but can also be used for general PDB file investigation
  15. and forensics, or as a replacement for cvdump.
  16. Subcommands
  17. -----------
  18. :program:`llvm-pdbutil` is separated into several subcommands each tailored to
  19. a different purpose. A brief summary of each command follows, with more detail
  20. in the sections that follow.
  21. * :ref:`pretty_subcommand` - Dump symbol and type information in a format that
  22. tries to look as much like the original source code as possible.
  23. * :ref:`dump_subcommand` - Dump low level types and structures from the PDB
  24. file, including CodeView records, hash tables, PDB streams, etc.
  25. * :ref:`bytes_subcommand` - Dump data from the PDB file's streams, records,
  26. types, symbols, etc as raw bytes.
  27. * :ref:`yaml2pdb_subcommand` - Given a yaml description of a PDB file, produce
  28. a valid PDB file that matches that description.
  29. * :ref:`pdb2yaml_subcommand` - For a given PDB file, produce a YAML
  30. description of some or all of the file in a way that the PDB can be
  31. reconstructed.
  32. * :ref:`merge_subcommand` - Given two PDBs, produce a third PDB that is the
  33. result of merging the two input PDBs.
  34. .. _pretty_subcommand:
  35. pretty
  36. ~~~~~~
  37. .. program:: llvm-pdbutil pretty
  38. .. important::
  39. The **pretty** subcommand is built on the Windows DIA SDK, and as such is not
  40. supported on non-Windows platforms.
  41. USAGE: :program:`llvm-pdbutil` pretty [*options*] <input PDB file>
  42. Summary
  43. ^^^^^^^^^^^
  44. The *pretty* subcommand displays a very high level representation of your
  45. program's debug info. Since it is built on the Windows DIA SDK which is the
  46. standard API that Windows tools and debuggers query debug information, it
  47. presents a more authoritative view of how a debugger is going to interpret your
  48. debug information than a mode which displays low-level CodeView records.
  49. Options
  50. ^^^^^^^
  51. Filtering and Sorting Options
  52. +++++++++++++++++++++++++++++
  53. .. note::
  54. *exclude* filters take priority over *include* filters. So if a filter
  55. matches both an include and an exclude rule, then it is excluded.
  56. .. option:: -exclude-compilands=<string>
  57. When dumping compilands, compiland source-file contributions, or per-compiland
  58. symbols, this option instructs **llvm-pdbutil** to omit any compilands that
  59. match the specified regular expression.
  60. .. option:: -exclude-symbols=<string>
  61. When dumping global, public, or per-compiland symbols, this option instructs
  62. **llvm-pdbutil** to omit any symbols that match the specified regular
  63. expression.
  64. .. option:: -exclude-types=<string>
  65. When dumping types, this option instructs **llvm-pdbutil** to omit any types
  66. that match the specified regular expression.
  67. .. option:: -include-compilands=<string>
  68. When dumping compilands, compiland source-file contributions, or per-compiland
  69. symbols, limit the initial search to only those compilands that match the
  70. specified regular expression.
  71. .. option:: -include-symbols=<string>
  72. When dumping global, public, or per-compiland symbols, limit the initial
  73. search to only those symbols that match the specified regular expression.
  74. .. option:: -include-types=<string>
  75. When dumping types, limit the initial search to only those types that match
  76. the specified regular expression.
  77. .. option:: -min-class-padding=<uint>
  78. Only display types that have at least the specified amount of alignment
  79. padding, accounting for padding in base classes and aggregate field members.
  80. .. option:: -min-class-padding-imm=<uint>
  81. Only display types that have at least the specified amount of alignment
  82. padding, ignoring padding in base classes and aggregate field members.
  83. .. option:: -min-type-size=<uint>
  84. Only display types T where sizeof(T) is greater than or equal to the specified
  85. amount.
  86. .. option:: -no-compiler-generated
  87. Don't show compiler generated types and symbols
  88. .. option:: -no-enum-definitions
  89. When dumping an enum, don't show the full enum (e.g. the individual enumerator
  90. values).
  91. .. option:: -no-system-libs
  92. Don't show symbols from system libraries
  93. Symbol Type Options
  94. +++++++++++++++++++
  95. .. option:: -all
  96. Implies all other options in this category.
  97. .. option:: -class-definitions=<format>
  98. Displays class definitions in the specified format.
  99. .. code-block:: text
  100. =all - Display all class members including data, constants, typedefs, functions, etc (default)
  101. =layout - Only display members that contribute to class size.
  102. =none - Don't display class definitions (e.g. only display the name and base list)
  103. .. option:: -class-order
  104. Displays classes in the specified order.
  105. .. code-block:: text
  106. =none - Undefined / no particular sort order (default)
  107. =name - Sort classes by name
  108. =size - Sort classes by size
  109. =padding - Sort classes by amount of padding
  110. =padding-pct - Sort classes by percentage of space consumed by padding
  111. =padding-imm - Sort classes by amount of immediate padding
  112. =padding-pct-imm - Sort classes by percentage of space consumed by immediate padding
  113. .. option:: -class-recurse-depth=<uint>
  114. When dumping class definitions, stop after recursing the specified number of times. The
  115. default is 0, which is no limit.
  116. .. option:: -classes
  117. Display classes
  118. .. option:: -compilands
  119. Display compilands (e.g. object files)
  120. .. option:: -enums
  121. Display enums
  122. .. option:: -externals
  123. Dump external (e.g. exported) symbols
  124. .. option:: -globals
  125. Dump global symbols
  126. .. option:: -lines
  127. Dump the mappings between source lines and code addresses.
  128. .. option:: -module-syms
  129. Display symbols (variables, functions, etc) for each compiland
  130. .. option:: -sym-types=<types>
  131. Type of symbols to dump when -globals, -externals, or -module-syms is
  132. specified. (default all)
  133. .. code-block:: text
  134. =thunks - Display thunk symbols
  135. =data - Display data symbols
  136. =funcs - Display function symbols
  137. =all - Display all symbols (default)
  138. .. option:: -symbol-order=<order>
  139. For symbols dumped via the -module-syms, -globals, or -externals options, sort
  140. the results in specified order.
  141. .. code-block:: text
  142. =none - Undefined / no particular sort order
  143. =name - Sort symbols by name
  144. =size - Sort symbols by size
  145. .. option:: -typedefs
  146. Display typedef types
  147. .. option:: -types
  148. Display all types (implies -classes, -enums, -typedefs)
  149. Other Options
  150. +++++++++++++
  151. .. option:: -color-output
  152. Force color output on or off. By default, color if used if outputting to a
  153. terminal.
  154. .. option:: -load-address=<uint>
  155. When displaying relative virtual addresses, assume the process is loaded at the
  156. given address and display what would be the absolute address.
  157. .. _dump_subcommand:
  158. dump
  159. ~~~~
  160. USAGE: :program:`llvm-pdbutil` dump [*options*] <input PDB file>
  161. .. program:: llvm-pdbutil dump
  162. Summary
  163. ^^^^^^^^^^^
  164. The **dump** subcommand displays low level information about the structure of a
  165. PDB file. It is used heavily by LLVM's testing infrastructure, but can also be
  166. used for PDB forensics. It serves a role similar to that of Microsoft's
  167. `cvdump` tool.
  168. .. note::
  169. The **dump** subcommand exposes internal details of the file format. As
  170. such, the reader should be familiar with :doc:`/PDB/index` before using this
  171. command.
  172. Options
  173. ^^^^^^^
  174. MSF Container Options
  175. +++++++++++++++++++++
  176. .. option:: -streams
  177. dump a summary of all of the streams in the PDB file.
  178. .. option:: -stream-blocks
  179. In conjunction with :option:`-streams`, add information to the output about
  180. what blocks the specified stream occupies.
  181. .. option:: -summary
  182. Dump MSF and PDB header information.
  183. Module & File Options
  184. +++++++++++++++++++++
  185. .. option:: -modi=<uint>
  186. For all options that dump information from each module/compiland, limit to
  187. the specified module.
  188. .. option:: -files
  189. Dump the source files that contribute to each displayed module.
  190. .. option:: -il
  191. Dump inlinee line information (DEBUG_S_INLINEELINES CodeView subsection)
  192. .. option:: -l
  193. Dump line information (DEBUG_S_LINES CodeView subsection)
  194. .. option:: -modules
  195. Dump compiland information
  196. .. option:: -xme
  197. Dump cross module exports (DEBUG_S_CROSSSCOPEEXPORTS CodeView subsection)
  198. .. option:: -xmi
  199. Dump cross module imports (DEBUG_S_CROSSSCOPEIMPORTS CodeView subsection)
  200. Symbol Options
  201. ++++++++++++++
  202. .. option:: -globals
  203. dump global symbol records
  204. .. option:: -global-extras
  205. dump additional information about the globals, such as hash buckets and hash
  206. values.
  207. .. option:: -publics
  208. dump public symbol records
  209. .. option:: -public-extras
  210. dump additional information about the publics, such as hash buckets and hash
  211. values.
  212. .. option:: -symbols
  213. dump symbols (functions, variables, etc) for each module dumped.
  214. .. option:: -sym-data
  215. For each symbol record dumped as a result of the :option:`-symbols` option,
  216. display the full bytes of the record in binary as well.
  217. Type Record Options
  218. +++++++++++++++++++
  219. .. option:: -types
  220. Dump CodeView type records from TPI stream
  221. .. option:: -type-extras
  222. Dump additional information from the TPI stream, such as hashes and the type
  223. index offsets array.
  224. .. option:: -type-data
  225. For each type record dumped, display the full bytes of the record in binary as
  226. well.
  227. .. option:: -type-index=<uint>
  228. Only dump types with the specified type index.
  229. .. option:: -ids
  230. Dump CodeView type records from IPI stream.
  231. .. option:: -id-extras
  232. Dump additional information from the IPI stream, such as hashes and the type
  233. index offsets array.
  234. .. option:: -id-data
  235. For each ID record dumped, display the full bytes of the record in binary as
  236. well.
  237. .. option:: -id-index=<uint>
  238. only dump ID records with the specified hexadecimal type index.
  239. .. option:: -dependents
  240. When used in conjunction with :option:`-type-index` or :option:`-id-index`,
  241. dumps the entire dependency graph for the specified index instead of just the
  242. single record with the specified index. For example, if type index 0x4000 is
  243. a function whose return type has index 0x3000, and you specify
  244. `-dependents=0x4000`, then this would dump both records (as well as any other
  245. dependents in the tree).
  246. Miscellaneous Options
  247. +++++++++++++++++++++
  248. .. option:: -all
  249. Implies most other options.
  250. .. option:: -section-contribs
  251. Dump section contributions.
  252. .. option:: -section-headers
  253. Dump image section headers.
  254. .. option:: -section-map
  255. Dump section map.
  256. .. option:: -string-table
  257. Dump PDB string table.
  258. .. _bytes_subcommand:
  259. bytes
  260. ~~~~~
  261. USAGE: :program:`llvm-pdbutil` bytes [*options*] <input PDB file>
  262. .. program:: llvm-pdbutil bytes
  263. Summary
  264. ^^^^^^^
  265. Like the **dump** subcommand, the **bytes** subcommand displays low level
  266. information about the structure of a PDB file, but it is used for even deeper
  267. forensics. The **bytes** subcommand finds various structures in a PDB file
  268. based on the command line options specified, and dumps them in hex. Someone
  269. working on support for emitting PDBs would use this heavily, for example, to
  270. compare one PDB against another PDB to ensure byte-for-byte compatibility. It
  271. is not enough to simply compare the bytes of an entire file, or an entire stream
  272. because it's perfectly fine for the same structure to exist at different
  273. locations in two different PDBs, and "finding" the structure is half the battle.
  274. Options
  275. ^^^^^^^
  276. MSF File Options
  277. ++++++++++++++++
  278. .. option:: -block-range=<start[-end]>
  279. Dump binary data from specified range of MSF file blocks.
  280. .. option:: -byte-range=<start[-end]>
  281. Dump binary data from specified range of bytes in the file.
  282. .. option:: -fpm
  283. Dump the MSF free page map.
  284. .. option:: -stream-data=<string>
  285. Dump binary data from the specified streams. Format is SN[:Start][@Size].
  286. For example, `-stream-data=7:3@12` dumps 12 bytes from stream 7, starting
  287. at offset 3 in the stream.
  288. PDB Stream Options
  289. ++++++++++++++++++
  290. .. option:: -name-map
  291. Dump bytes of PDB Name Map
  292. DBI Stream Options
  293. ++++++++++++++++++
  294. .. option:: -ec
  295. Dump the edit and continue map substream of the DBI stream.
  296. .. option:: -files
  297. Dump the file info substream of the DBI stream.
  298. .. option:: -modi
  299. Dump the modi substream of the DBI stream.
  300. .. option:: -sc
  301. Dump section contributions substream of the DBI stream.
  302. .. option:: -sm
  303. Dump the section map from the DBI stream.
  304. .. option:: -type-server
  305. Dump the type server map from the DBI stream.
  306. Module Options
  307. ++++++++++++++
  308. .. option:: -mod=<uint>
  309. Limit all options in this category to the specified module index. By default,
  310. options in this category will dump bytes from all modules.
  311. .. option:: -chunks
  312. Dump the bytes of each module's C13 debug subsection.
  313. .. option:: -split-chunks
  314. When specified with :option:`-chunks`, split the C13 debug subsection into a
  315. separate chunk for each subsection type, and dump them separately.
  316. .. option:: -syms
  317. Dump the symbol record substream from each module.
  318. Type Record Options
  319. +++++++++++++++++++
  320. .. option:: -id=<uint>
  321. Dump the record from the IPI stream with the given type index.
  322. .. option:: -type=<uint>
  323. Dump the record from the TPI stream with the given type index.
  324. .. _pdb2yaml_subcommand:
  325. pdb2yaml
  326. ~~~~~~~~
  327. USAGE: :program:`llvm-pdbutil` pdb2yaml [*options*] <input PDB file>
  328. .. program:: llvm-pdbutil pdb2yaml
  329. Summary
  330. ^^^^^^^
  331. Options
  332. ^^^^^^^
  333. .. _yaml2pdb_subcommand:
  334. yaml2pdb
  335. ~~~~~~~~
  336. USAGE: :program:`llvm-pdbutil` yaml2pdb [*options*] <input YAML file>
  337. .. program:: llvm-pdbutil yaml2pdb
  338. Summary
  339. ^^^^^^^
  340. Generate a PDB file from a YAML description. The YAML syntax is not described
  341. here. Instead, use :ref:`llvm-pdbutil pdb2yaml <pdb2yaml_subcommand>` and
  342. examine the output for an example starting point.
  343. Options
  344. ^^^^^^^
  345. .. option:: -pdb=<file-name>
  346. Write the resulting PDB to the specified file.
  347. .. _merge_subcommand:
  348. merge
  349. ~~~~~
  350. USAGE: :program:`llvm-pdbutil` merge [*options*] <input PDB file 1> <input PDB file 2>
  351. .. program:: llvm-pdbutil merge
  352. Summary
  353. ^^^^^^^
  354. Merge two PDB files into a single file.
  355. Options
  356. ^^^^^^^
  357. .. option:: -pdb=<file-name>
  358. Write the resulting PDB to the specified file.