File: DbiStream.html

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-6~deb10u4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,418,792 kB
  • sloc: cpp: 5,290,827; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,900; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,892; xml: 953; cs: 573; fortran: 539
file content (543 lines) | stat: -rw-r--r-- 47,257 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543


<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>The PDB DBI (Debug Info) Stream &#8212; LLVM 13 documentation</title>
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/llvm-theme.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="The Module Information Stream" href="ModiStream.html" />
    <link rel="prev" title="The PDB TPI and IPI Streams" href="TpiStream.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head><body>
<div class="logo">
  <a href="../index.html">
    <img src="../_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="ModiStream.html" title="The Module Information Stream"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="TpiStream.html" title="The PDB TPI and IPI Streams"
             accesskey="P">previous</a> |</li>
  <li><a href="https://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="../Reference.html" >Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">The PDB File Format</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">The PDB DBI (Debug Info) Stream</a></li> 
      </ul>
    </div>

      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">

<h3>Documentation</h3>

<ul class="want-points">
    <li><a href="https://llvm.org/docs/GettingStartedTutorials.html">Getting Started/Tutorials</a></li>
    <li><a href="https://llvm.org/docs/UserGuides.html">User Guides</a></li>
    <li><a href="https://llvm.org/docs/Reference.html">Reference</a></li>
</ul>

<h3>Getting Involved</h3>

<ul class="want-points">
    <li><a href="https://llvm.org/docs/Contributing.html">Contributing to LLVM</a></li>
    <li><a href="https://llvm.org/docs/HowToSubmitABug.html">Submitting Bug Reports</a></li>
    <li><a href="https://llvm.org/docs/GettingInvolved.html#mailing-lists">Mailing Lists</a></li>
    <li><a href="https://llvm.org/docs/GettingInvolved.html#irc">IRC</a></li>
    <li><a href="https://llvm.org/docs/GettingInvolved.html#meetups-and-social-events">Meetups and Social Events</a></li>
</ul>

<h3>Additional Links</h3>

<ul class="want-points">
    <li><a href="https://llvm.org/docs/FAQ.html">FAQ</a></li>
    <li><a href="https://llvm.org/docs/Lexicon.html">Glossary</a></li>
    <li><a href="https://llvm.org/pubs">Publications</a></li>
    <li><a href="https://github.com/llvm/llvm-project//">Github Repository</a></li>
</ul>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/PDB/DbiStream.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="the-pdb-dbi-debug-info-stream">
<h1>The PDB DBI (Debug Info) Stream<a class="headerlink" href="#the-pdb-dbi-debug-info-stream" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#introduction" id="id1">Introduction</a></p></li>
<li><p><a class="reference internal" href="#stream-header" id="id2">Stream Header</a></p></li>
<li><p><a class="reference internal" href="#substreams" id="id3">Substreams</a></p>
<ul>
<li><p><a class="reference internal" href="#module-info-substream" id="id4">Module Info Substream</a></p></li>
<li><p><a class="reference internal" href="#section-contribution-substream" id="id5">Section Contribution Substream</a></p></li>
<li><p><a class="reference internal" href="#section-map-substream" id="id6">Section Map Substream</a></p></li>
<li><p><a class="reference internal" href="#file-info-substream" id="id7">File Info Substream</a></p></li>
<li><p><a class="reference internal" href="#type-server-map-substream" id="id8">Type Server Map Substream</a></p></li>
<li><p><a class="reference internal" href="#ec-substream" id="id9">EC Substream</a></p></li>
<li><p><a class="reference internal" href="#optional-debug-header-stream" id="id10">Optional Debug Header Stream</a></p></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="introduction">
<span id="dbi-intro"></span><h2><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>The PDB DBI Stream (Index 3) is one of the largest and most important streams
in a PDB file.  It contains information about how the program was compiled,
(e.g. compilation flags, etc), the compilands (e.g. object files) that
were used to link together the program, the source files which were used
to build the program, as well as references to other streams that contain more
detailed information about each compiland, such as the CodeView symbol records
contained within each compiland and the source and line information for
functions and other symbols within each compiland.</p>
</div>
<div class="section" id="stream-header">
<span id="dbi-header"></span><h2><a class="toc-backref" href="#id2">Stream Header</a><a class="headerlink" href="#stream-header" title="Permalink to this headline">¶</a></h2>
<p>At offset 0 of the DBI Stream is a header with the following layout:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="nc">DbiStreamHeader</span> <span class="p">{</span>
  <span class="kt">int32_t</span> <span class="n">VersionSignature</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">VersionHeader</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">Age</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">GlobalStreamIndex</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">BuildNumber</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">PublicStreamIndex</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">PdbDllVersion</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">SymRecordStream</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">PdbDllRbld</span><span class="p">;</span>
  <span class="kt">int32_t</span> <span class="n">ModInfoSize</span><span class="p">;</span>
  <span class="kt">int32_t</span> <span class="n">SectionContributionSize</span><span class="p">;</span>
  <span class="kt">int32_t</span> <span class="n">SectionMapSize</span><span class="p">;</span>
  <span class="kt">int32_t</span> <span class="n">SourceInfoSize</span><span class="p">;</span>
  <span class="kt">int32_t</span> <span class="n">TypeServerMapSize</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">MFCTypeServerIndex</span><span class="p">;</span>
  <span class="kt">int32_t</span> <span class="n">OptionalDbgHeaderSize</span><span class="p">;</span>
  <span class="kt">int32_t</span> <span class="n">ECSubstreamSize</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">Flags</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">Machine</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">Padding</span><span class="p">;</span>
<span class="p">};</span>
</pre></div>
</div>
<ul class="simple">
<li><p><strong>VersionSignature</strong> - Unknown meaning.  Appears to always be <code class="docutils literal notranslate"><span class="pre">-1</span></code>.</p></li>
<li><p><strong>VersionHeader</strong> - A value from the following enum.</p></li>
</ul>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">enum</span> <span class="k">class</span> <span class="nc">DbiStreamVersion</span> <span class="o">:</span> <span class="kt">uint32_t</span> <span class="p">{</span>
  <span class="n">VC41</span> <span class="o">=</span> <span class="mi">930803</span><span class="p">,</span>
  <span class="n">V50</span> <span class="o">=</span> <span class="mi">19960307</span><span class="p">,</span>
  <span class="n">V60</span> <span class="o">=</span> <span class="mi">19970606</span><span class="p">,</span>
  <span class="n">V70</span> <span class="o">=</span> <span class="mi">19990903</span><span class="p">,</span>
  <span class="n">V110</span> <span class="o">=</span> <span class="mi">20091201</span>
<span class="p">};</span>
</pre></div>
</div>
<p>Similar to the <a class="reference internal" href="PdbStream.html"><span class="doc">PDB Stream</span></a>, this value always appears to be
<code class="docutils literal notranslate"><span class="pre">V70</span></code>, and it is not clear what the other values are for.</p>
<ul class="simple">
<li><p><strong>Age</strong> - The number of times the PDB has been written.  Equal to the same
field from the <a class="reference internal" href="PdbStream.html#pdb-stream-header"><span class="std std-ref">PDB Stream header</span></a>.</p></li>
<li><p><strong>GlobalStreamIndex</strong> - The index of the <a class="reference internal" href="GlobalStream.html"><span class="doc">Global Symbol Stream</span></a>,
which contains CodeView symbol records for all global symbols.  Actual records
are stored in the symbol record stream, and are referenced from this stream.</p></li>
<li><p><strong>BuildNumber</strong> - A bitfield containing values representing the major and minor
version number of the toolchain (e.g. 12.0 for MSVC 2013) used to build the
program, with the following layout:</p></li>
</ul>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">uint16_t</span> <span class="nl">MinorVersion</span> <span class="p">:</span> <span class="mi">8</span><span class="p">;</span>
<span class="kt">uint16_t</span> <span class="nl">MajorVersion</span> <span class="p">:</span> <span class="mi">7</span><span class="p">;</span>
<span class="kt">uint16_t</span> <span class="nl">NewVersionFormat</span> <span class="p">:</span> <span class="mi">1</span><span class="p">;</span>
</pre></div>
</div>
<p>For the purposes of LLVM, we assume <code class="docutils literal notranslate"><span class="pre">NewVersionFormat</span></code> to be always <code class="docutils literal notranslate"><span class="pre">true</span></code>.
If it is <code class="docutils literal notranslate"><span class="pre">false</span></code>, the layout above does not apply and the reader should consult
the <a class="reference external" href="https://github.com/Microsoft/microsoft-pdb">Microsoft Source Code</a> for
further guidance.</p>
<ul class="simple">
<li><p><strong>PublicStreamIndex</strong> - The index of the <a class="reference internal" href="PublicStream.html"><span class="doc">Public Symbol Stream</span></a>,
which contains CodeView symbol records for all public symbols.  Actual records
are stored in the symbol record stream, and are referenced from this stream.</p></li>
<li><p><strong>PdbDllVersion</strong> - The version number of <code class="docutils literal notranslate"><span class="pre">mspdbXXXX.dll</span></code> used to produce this
PDB.  Note this obviously does not apply for LLVM as LLVM does not use <code class="docutils literal notranslate"><span class="pre">mspdb.dll</span></code>.</p></li>
<li><p><strong>SymRecordStream</strong> - The stream containing all CodeView symbol records used
by the program.  This is used for deduplication, so that many different
compilands can refer to the same symbols without having to include the full record
content inside of each module stream.</p></li>
<li><p><strong>PdbDllRbld</strong> - Unknown</p></li>
<li><p><strong>MFCTypeServerIndex</strong> - The index of the MFC type server in the
<a class="reference internal" href="#dbi-type-server-map-substream"><span class="std std-ref">Type Server Map Substream</span></a>.</p></li>
<li><p><strong>Flags</strong> - A bitfield with the following layout, containing various
information about how the program was built:</p></li>
</ul>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="kt">uint16_t</span> <span class="nl">WasIncrementallyLinked</span> <span class="p">:</span> <span class="mi">1</span><span class="p">;</span>
<span class="kt">uint16_t</span> <span class="nl">ArePrivateSymbolsStripped</span> <span class="p">:</span> <span class="mi">1</span><span class="p">;</span>
<span class="kt">uint16_t</span> <span class="nl">HasConflictingTypes</span> <span class="p">:</span> <span class="mi">1</span><span class="p">;</span>
<span class="kt">uint16_t</span> <span class="nl">Reserved</span> <span class="p">:</span> <span class="mi">13</span><span class="p">;</span>
</pre></div>
</div>
<p>The only one of these that is not self-explanatory is <code class="docutils literal notranslate"><span class="pre">HasConflictingTypes</span></code>.
Although undocumented, <code class="docutils literal notranslate"><span class="pre">link.exe</span></code> contains a hidden flag <code class="docutils literal notranslate"><span class="pre">/DEBUG:CTYPES</span></code>.
If it is passed to <code class="docutils literal notranslate"><span class="pre">link.exe</span></code>, this field will be set.  Otherwise it will
not be set.  It is unclear what this flag does, although it seems to have
subtle implications on the algorithm used to look up type records.</p>
<ul class="simple">
<li><p><strong>Machine</strong> - A value from the <a class="reference external" href="https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx">CV_CPU_TYPE_e</a>
enumeration.  Common values are <code class="docutils literal notranslate"><span class="pre">0x8664</span></code> (x86-64) and <code class="docutils literal notranslate"><span class="pre">0x14C</span></code> (x86).</p></li>
</ul>
<p>Immediately after the fixed-size DBI Stream header are <code class="docutils literal notranslate"><span class="pre">7</span></code> variable-length
<cite>substreams</cite>.  The following <code class="docutils literal notranslate"><span class="pre">7</span></code> fields of the DBI Stream header specify the
number of bytes of the corresponding substream.  Each substream’s contents will
be described in detail <a class="reference internal" href="#dbi-substreams"><span class="std std-ref">below</span></a>.  The length of the entire
DBI Stream should equal <code class="docutils literal notranslate"><span class="pre">64</span></code> (the length of the header above) plus the value
of each of the following <code class="docutils literal notranslate"><span class="pre">7</span></code> fields.</p>
<ul class="simple">
<li><p><strong>ModInfoSize</strong> - The length of the <a class="reference internal" href="#dbi-mod-info-substream"><span class="std std-ref">Module Info Substream</span></a>.</p></li>
<li><p><strong>SectionContributionSize</strong> - The length of the <a class="reference internal" href="#dbi-sec-contr-substream"><span class="std std-ref">Section Contribution Substream</span></a>.</p></li>
<li><p><strong>SectionMapSize</strong> - The length of the <a class="reference internal" href="#dbi-section-map-substream"><span class="std std-ref">Section Map Substream</span></a>.</p></li>
<li><p><strong>SourceInfoSize</strong> - The length of the <a class="reference internal" href="#dbi-file-info-substream"><span class="std std-ref">File Info Substream</span></a>.</p></li>
<li><p><strong>TypeServerMapSize</strong> - The length of the <a class="reference internal" href="#dbi-type-server-map-substream"><span class="std std-ref">Type Server Map Substream</span></a>.</p></li>
<li><p><strong>OptionalDbgHeaderSize</strong> - The length of the <a class="reference internal" href="#dbi-optional-dbg-stream"><span class="std std-ref">Optional Debug Header Stream</span></a>.</p></li>
<li><p><strong>ECSubstreamSize</strong> - The length of the <a class="reference internal" href="#dbi-ec-substream"><span class="std std-ref">EC Substream</span></a>.</p></li>
</ul>
</div>
<div class="section" id="substreams">
<span id="dbi-substreams"></span><h2><a class="toc-backref" href="#id3">Substreams</a><a class="headerlink" href="#substreams" title="Permalink to this headline">¶</a></h2>
<div class="section" id="module-info-substream">
<span id="dbi-mod-info-substream"></span><h3><a class="toc-backref" href="#id4">Module Info Substream</a><a class="headerlink" href="#module-info-substream" title="Permalink to this headline">¶</a></h3>
<p>Begins at offset <code class="docutils literal notranslate"><span class="pre">0</span></code> immediately after the <a class="reference internal" href="#dbi-header"><span class="std std-ref">header</span></a>.  The
module info substream is an array of variable-length records, each one
describing a single module (e.g. object file) linked into the program.  Each
record in the array has the format:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="nc">ModInfo</span> <span class="p">{</span>
  <span class="kt">uint32_t</span> <span class="n">Unused1</span><span class="p">;</span>
  <span class="k">struct</span> <span class="nc">SectionContribEntry</span> <span class="p">{</span>
    <span class="kt">uint16_t</span> <span class="n">Section</span><span class="p">;</span>
    <span class="kt">char</span> <span class="n">Padding1</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
    <span class="kt">int32_t</span> <span class="n">Offset</span><span class="p">;</span>
    <span class="kt">int32_t</span> <span class="n">Size</span><span class="p">;</span>
    <span class="kt">uint32_t</span> <span class="n">Characteristics</span><span class="p">;</span>
    <span class="kt">uint16_t</span> <span class="n">ModuleIndex</span><span class="p">;</span>
    <span class="kt">char</span> <span class="n">Padding2</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
    <span class="kt">uint32_t</span> <span class="n">DataCrc</span><span class="p">;</span>
    <span class="kt">uint32_t</span> <span class="n">RelocCrc</span><span class="p">;</span>
  <span class="p">}</span> <span class="n">SectionContr</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">Flags</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">ModuleSymStream</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">SymByteSize</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">C11ByteSize</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">C13ByteSize</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">SourceFileCount</span><span class="p">;</span>
  <span class="kt">char</span> <span class="n">Padding</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
  <span class="kt">uint32_t</span> <span class="n">Unused2</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">SourceFileNameIndex</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">PdbFilePathNameIndex</span><span class="p">;</span>
  <span class="kt">char</span> <span class="n">ModuleName</span><span class="p">[];</span>
  <span class="kt">char</span> <span class="n">ObjFileName</span><span class="p">[];</span>
<span class="p">};</span>
</pre></div>
</div>
<ul>
<li><p><strong>SectionContr</strong> - Describes the properties of the section in the final binary
which contain the code and data from this module.</p>
<p><code class="docutils literal notranslate"><span class="pre">SectionContr.Characteristics</span></code> corresponds to the <code class="docutils literal notranslate"><span class="pre">Characteristics</span></code> field
of the <a class="reference external" href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms680341(v=vs.85).aspx">IMAGE_SECTION_HEADER</a>
structure.</p>
</li>
<li><p><strong>Flags</strong> - A bitfield with the following format:</p></li>
</ul>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="c1">// ``true`` if this ModInfo has been written since reading the PDB.  This is</span>
<span class="c1">// likely used to support incremental linking, so that the linker can decide</span>
<span class="c1">// if it needs to commit changes to disk.</span>
<span class="kt">uint16_t</span> <span class="nl">Dirty</span> <span class="p">:</span> <span class="mi">1</span><span class="p">;</span>
<span class="c1">// ``true`` if EC information is present for this module. EC is presumed to</span>
<span class="c1">// stand for &quot;Edit &amp; Continue&quot;, which LLVM does not support.  So this flag</span>
<span class="c1">// will always be be false.</span>
<span class="kt">uint16_t</span> <span class="nl">EC</span> <span class="p">:</span> <span class="mi">1</span><span class="p">;</span>
<span class="kt">uint16_t</span> <span class="nl">Unused</span> <span class="p">:</span> <span class="mi">6</span><span class="p">;</span>
<span class="c1">// Type Server Index for this module.  This is assumed to be related to /Zi,</span>
<span class="c1">// but as LLVM treats /Zi as /Z7, this field will always be invalid for LLVM</span>
<span class="c1">// generated PDBs.</span>
<span class="kt">uint16_t</span> <span class="nl">TSM</span> <span class="p">:</span> <span class="mi">8</span><span class="p">;</span>
</pre></div>
</div>
<ul class="simple">
<li><p><strong>ModuleSymStream</strong> - The index of the stream that contains symbol information
for this module.  This includes CodeView symbol information as well as source
and line information.  If this field is -1, then no additional debug info will
be present for this module (for example, this is what happens when you strip
private symbols from a PDB).</p></li>
<li><p><strong>SymByteSize</strong> - The number of bytes of data from the stream identified by
<code class="docutils literal notranslate"><span class="pre">ModuleSymStream</span></code> that represent CodeView symbol records.</p></li>
<li><p><strong>C11ByteSize</strong> - The number of bytes of data from the stream identified by
<code class="docutils literal notranslate"><span class="pre">ModuleSymStream</span></code> that represent C11-style CodeView line information.</p></li>
<li><p><strong>C13ByteSize</strong> - The number of bytes of data from the stream identified by
<code class="docutils literal notranslate"><span class="pre">ModuleSymStream</span></code> that represent C13-style CodeView line information.  At
most one of <code class="docutils literal notranslate"><span class="pre">C11ByteSize</span></code> and <code class="docutils literal notranslate"><span class="pre">C13ByteSize</span></code> will be non-zero.  Modern PDBs
always use C13 instead of C11.</p></li>
<li><p><strong>SourceFileCount</strong> - The number of source files that contributed to this
module during compilation.</p></li>
<li><p><strong>SourceFileNameIndex</strong> - The offset in the names buffer of the primary
translation unit used to build this module.  All PDB files observed to date
always have this value equal to 0.</p></li>
<li><p><strong>PdbFilePathNameIndex</strong> - The offset in the names buffer of the PDB file
containing this module’s symbol information.  This has only been observed
to be non-zero for the special <code class="docutils literal notranslate"><span class="pre">*</span> <span class="pre">Linker</span> <span class="pre">*</span></code> module.</p></li>
<li><p><strong>ModuleName</strong> - The module name.  This is usually either a full path to an
object file (either directly passed to <code class="docutils literal notranslate"><span class="pre">link.exe</span></code> or from an archive) or
a string of the form <code class="docutils literal notranslate"><span class="pre">Import:&lt;dll</span> <span class="pre">name&gt;</span></code>.</p></li>
<li><p><strong>ObjFileName</strong> - The object file name.  In the case of an module that is
linked directly passed to <code class="docutils literal notranslate"><span class="pre">link.exe</span></code>, this is the same as <strong>ModuleName</strong>.
In the case of a module that comes from an archive, this is usually the full
path to the archive.</p></li>
</ul>
</div>
<div class="section" id="section-contribution-substream">
<span id="dbi-sec-contr-substream"></span><h3><a class="toc-backref" href="#id5">Section Contribution Substream</a><a class="headerlink" href="#section-contribution-substream" title="Permalink to this headline">¶</a></h3>
<p>Begins at offset <code class="docutils literal notranslate"><span class="pre">0</span></code> immediately after the <a class="reference internal" href="#dbi-mod-info-substream"><span class="std std-ref">Module Info Substream</span></a> ends,
and consumes <code class="docutils literal notranslate"><span class="pre">Header-&gt;SectionContributionSize</span></code> bytes.  This substream begins
with a single <code class="docutils literal notranslate"><span class="pre">uint32_t</span></code> which will be one of the following values:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">enum</span> <span class="k">class</span> <span class="nc">SectionContrSubstreamVersion</span> <span class="o">:</span> <span class="kt">uint32_t</span> <span class="p">{</span>
  <span class="n">Ver60</span> <span class="o">=</span> <span class="mh">0xeffe0000</span> <span class="o">+</span> <span class="mi">19970605</span><span class="p">,</span>
  <span class="n">V2</span> <span class="o">=</span> <span class="mh">0xeffe0000</span> <span class="o">+</span> <span class="mi">20140516</span>
<span class="p">};</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">Ver60</span></code> is the only value which has been observed in a PDB so far.  Following
this is an array of fixed-length structures.  If the version is <code class="docutils literal notranslate"><span class="pre">Ver60</span></code>,
it is an array of <code class="docutils literal notranslate"><span class="pre">SectionContribEntry</span></code> structures (this is the nested structure
from the <code class="docutils literal notranslate"><span class="pre">ModInfo</span></code> type.  If the version is <code class="docutils literal notranslate"><span class="pre">V2</span></code>, it is an array of
<code class="docutils literal notranslate"><span class="pre">SectionContribEntry2</span></code> structures, defined as follows:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="nc">SectionContribEntry2</span> <span class="p">{</span>
  <span class="n">SectionContribEntry</span> <span class="n">SC</span><span class="p">;</span>
  <span class="kt">uint32_t</span> <span class="n">ISectCoff</span><span class="p">;</span>
<span class="p">};</span>
</pre></div>
</div>
<p>The purpose of the second field is not well understood.  The name implies that
is the index of the COFF section, but this also describes the existing field
<code class="docutils literal notranslate"><span class="pre">SectionContribEntry::Section</span></code>.</p>
</div>
<div class="section" id="section-map-substream">
<span id="dbi-section-map-substream"></span><h3><a class="toc-backref" href="#id6">Section Map Substream</a><a class="headerlink" href="#section-map-substream" title="Permalink to this headline">¶</a></h3>
<p>Begins at offset <code class="docutils literal notranslate"><span class="pre">0</span></code> immediately after the <a class="reference internal" href="#dbi-sec-contr-substream"><span class="std std-ref">Section Contribution Substream</span></a> ends,
and consumes <code class="docutils literal notranslate"><span class="pre">Header-&gt;SectionMapSize</span></code> bytes.  This substream begins with an <code class="docutils literal notranslate"><span class="pre">4</span></code>
byte header followed by an array of fixed-length records.  The header and records
have the following layout:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="nc">SectionMapHeader</span> <span class="p">{</span>
  <span class="kt">uint16_t</span> <span class="n">Count</span><span class="p">;</span>    <span class="c1">// Number of segment descriptors</span>
  <span class="kt">uint16_t</span> <span class="n">LogCount</span><span class="p">;</span> <span class="c1">// Number of logical segment descriptors</span>
<span class="p">};</span>

<span class="k">struct</span> <span class="nc">SectionMapEntry</span> <span class="p">{</span>
  <span class="kt">uint16_t</span> <span class="n">Flags</span><span class="p">;</span>         <span class="c1">// See the SectionMapEntryFlags enum below.</span>
  <span class="kt">uint16_t</span> <span class="n">Ovl</span><span class="p">;</span>           <span class="c1">// Logical overlay number</span>
  <span class="kt">uint16_t</span> <span class="n">Group</span><span class="p">;</span>         <span class="c1">// Group index into descriptor array.</span>
  <span class="kt">uint16_t</span> <span class="n">Frame</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">SectionName</span><span class="p">;</span>   <span class="c1">// Byte index of segment / group name in string table, or 0xFFFF.</span>
  <span class="kt">uint16_t</span> <span class="n">ClassName</span><span class="p">;</span>     <span class="c1">// Byte index of class in string table, or 0xFFFF.</span>
  <span class="kt">uint32_t</span> <span class="n">Offset</span><span class="p">;</span>        <span class="c1">// Byte offset of the logical segment within physical segment.  If group is set in flags, this is the offset of the group.</span>
  <span class="kt">uint32_t</span> <span class="n">SectionLength</span><span class="p">;</span> <span class="c1">// Byte count of the segment or group.</span>
<span class="p">};</span>

<span class="k">enum</span> <span class="k">class</span> <span class="nc">SectionMapEntryFlags</span> <span class="o">:</span> <span class="kt">uint16_t</span> <span class="p">{</span>
  <span class="n">Read</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mi">0</span><span class="p">,</span>              <span class="c1">// Segment is readable.</span>
  <span class="n">Write</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mi">1</span><span class="p">,</span>             <span class="c1">// Segment is writable.</span>
  <span class="n">Execute</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mi">2</span><span class="p">,</span>           <span class="c1">// Segment is executable.</span>
  <span class="n">AddressIs32Bit</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mi">3</span><span class="p">,</span>    <span class="c1">// Descriptor describes a 32-bit linear address.</span>
  <span class="n">IsSelector</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mi">8</span><span class="p">,</span>        <span class="c1">// Frame represents a selector.</span>
  <span class="n">IsAbsoluteAddress</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mi">9</span><span class="p">,</span> <span class="c1">// Frame represents an absolute address.</span>
  <span class="n">IsGroup</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mi">10</span>           <span class="c1">// If set, descriptor represents a group.</span>
<span class="p">};</span>
</pre></div>
</div>
<p>Many of these fields are not well understood, so will not be discussed further.</p>
</div>
<div class="section" id="file-info-substream">
<span id="dbi-file-info-substream"></span><h3><a class="toc-backref" href="#id7">File Info Substream</a><a class="headerlink" href="#file-info-substream" title="Permalink to this headline">¶</a></h3>
<p>Begins at offset <code class="docutils literal notranslate"><span class="pre">0</span></code> immediately after the <a class="reference internal" href="#dbi-section-map-substream"><span class="std std-ref">Section Map Substream</span></a> ends,
and consumes <code class="docutils literal notranslate"><span class="pre">Header-&gt;SourceInfoSize</span></code> bytes.  This substream defines the mapping
from module to the source files that contribute to that module.  Since multiple
modules can use the same source file (for example, a header file), this substream
uses a string table to store each unique file name only once, and then have each
module use offsets into the string table rather than embedding the string’s value
directly.  The format of this substream is as follows:</p>
<div class="highlight-c++ notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span> <span class="nc">FileInfoSubstream</span> <span class="p">{</span>
  <span class="kt">uint16_t</span> <span class="n">NumModules</span><span class="p">;</span>
  <span class="kt">uint16_t</span> <span class="n">NumSourceFiles</span><span class="p">;</span>

  <span class="kt">uint16_t</span> <span class="n">ModIndices</span><span class="p">[</span><span class="n">NumModules</span><span class="p">];</span>
  <span class="kt">uint16_t</span> <span class="n">ModFileCounts</span><span class="p">[</span><span class="n">NumModules</span><span class="p">];</span>
  <span class="kt">uint32_t</span> <span class="n">FileNameOffsets</span><span class="p">[</span><span class="n">NumSourceFiles</span><span class="p">];</span>
  <span class="kt">char</span> <span class="n">NamesBuffer</span><span class="p">[][</span><span class="n">NumSourceFiles</span><span class="p">];</span>
<span class="p">};</span>
</pre></div>
</div>
<p><strong>NumModules</strong> - The number of modules for which source file information is
contained within this substream.  Should match the corresponding value from the
ref:<cite>dbi_header</cite>.</p>
<p><strong>NumSourceFiles</strong>: In theory this is supposed to contain the number of source
files for which this substream contains information.  But that would present a
problem in that the width of this field being <code class="docutils literal notranslate"><span class="pre">16</span></code>-bits would prevent one from
having more than 64K source files in a program.  In early versions of the file
format, this seems to have been the case.  In order to support more than this, this
field of the is simply ignored, and computed dynamically by summing up the values of
the <code class="docutils literal notranslate"><span class="pre">ModFileCounts</span></code> array (discussed below).  In short, this value should be
ignored.</p>
<p><strong>ModIndices</strong> - This array is present, but does not appear to be useful.</p>
<p><strong>ModFileCountArray</strong> - An array of <code class="docutils literal notranslate"><span class="pre">NumModules</span></code> integers, each one containing
the number of source files which contribute to the module at the specified index.
While each individual module is limited to 64K contributing source files, the
union of all modules’ source files may be greater than 64K.  The real number of
source files is thus computed by summing this array.  Note that summing this array
does not give the number of <cite>unique</cite> source files, only the total number of source
file contributions to modules.</p>
<p><strong>FileNameOffsets</strong> - An array of <strong>NumSourceFiles</strong> integers (where <strong>NumSourceFiles</strong>
here refers to the 32-bit value obtained from summing <strong>ModFileCountArray</strong>), where
each integer is an offset into <strong>NamesBuffer</strong> pointing to a null terminated string.</p>
<p><strong>NamesBuffer</strong> - An array of null terminated strings containing the actual source
file names.</p>
</div>
<div class="section" id="type-server-map-substream">
<span id="dbi-type-server-map-substream"></span><h3><a class="toc-backref" href="#id8">Type Server Map Substream</a><a class="headerlink" href="#type-server-map-substream" title="Permalink to this headline">¶</a></h3>
<p>Begins at offset <code class="docutils literal notranslate"><span class="pre">0</span></code> immediately after the <a class="reference internal" href="#dbi-file-info-substream"><span class="std std-ref">File Info Substream</span></a>
ends, and consumes <code class="docutils literal notranslate"><span class="pre">Header-&gt;TypeServerMapSize</span></code> bytes.  Neither the purpose
nor the layout of this substream is understood, although it is assumed to
related somehow to the usage of <code class="docutils literal notranslate"><span class="pre">/Zi</span></code> and <code class="docutils literal notranslate"><span class="pre">mspdbsrv.exe</span></code>.  This substream
will not be discussed further.</p>
</div>
<div class="section" id="ec-substream">
<span id="dbi-ec-substream"></span><h3><a class="toc-backref" href="#id9">EC Substream</a><a class="headerlink" href="#ec-substream" title="Permalink to this headline">¶</a></h3>
<p>Begins at offset <code class="docutils literal notranslate"><span class="pre">0</span></code> immediately after the
<a class="reference internal" href="#dbi-type-server-map-substream"><span class="std std-ref">Type Server Map Substream</span></a> ends, and consumes
<code class="docutils literal notranslate"><span class="pre">Header-&gt;ECSubstreamSize</span></code> bytes.  This is presumed to be related to Edit &amp;
Continue support in MSVC.  LLVM does not support Edit &amp; Continue, so this
stream will not be discussed further.</p>
</div>
<div class="section" id="optional-debug-header-stream">
<span id="dbi-optional-dbg-stream"></span><h3><a class="toc-backref" href="#id10">Optional Debug Header Stream</a><a class="headerlink" href="#optional-debug-header-stream" title="Permalink to this headline">¶</a></h3>
<p>Begins at offset <code class="docutils literal notranslate"><span class="pre">0</span></code> immediately after the <a class="reference internal" href="#dbi-ec-substream"><span class="std std-ref">EC Substream</span></a> ends, and
consumes <code class="docutils literal notranslate"><span class="pre">Header-&gt;OptionalDbgHeaderSize</span></code> bytes.  This field is an array of
stream indices (e.g. <code class="docutils literal notranslate"><span class="pre">uint16_t</span></code>’s), each of which identifies a stream
index in the larger MSF file which contains some additional debug information.
Each position of this array has a special meaning, allowing one to determine
what kind of debug information is at the referenced stream.  <code class="docutils literal notranslate"><span class="pre">11</span></code> indices
are currently understood, although it’s possible there may be more.  The
layout of each stream generally corresponds exactly to a particular type
of debug data directory from the PE/COFF file.  The format of these fields
can be found in the <a class="reference external" href="https://www.microsoft.com/en-us/download/details.aspx?id=19509">Microsoft PE/COFF Specification</a>.
If any of these fields is -1, it means the corresponding type of debug info is
not present in the PDB.</p>
<p><strong>FPO Data</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[0]</span></code>.  The data in the referenced stream is an
array of <code class="docutils literal notranslate"><span class="pre">FPO_DATA</span></code> structures.  This contains the relocated contents of
any <code class="docutils literal notranslate"><span class="pre">.debug$F</span></code> section from any of the linker inputs.</p>
<p><strong>Exception Data</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[1]</span></code>.  The data in the referenced stream
is a debug data directory of type <code class="docutils literal notranslate"><span class="pre">IMAGE_DEBUG_TYPE_EXCEPTION</span></code>.</p>
<p><strong>Fixup Data</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[2]</span></code>.  The data in the referenced stream is a
debug data directory of type <code class="docutils literal notranslate"><span class="pre">IMAGE_DEBUG_TYPE_FIXUP</span></code>.</p>
<p><strong>Omap To Src Data</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[3]</span></code>.  The data in the referenced stream
is a debug data directory of type <code class="docutils literal notranslate"><span class="pre">IMAGE_DEBUG_TYPE_OMAP_TO_SRC</span></code>.  This
is used for mapping addresses between instrumented and uninstrumented code.</p>
<p><strong>Omap From Src Data</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[4]</span></code>.  The data in the referenced stream
is a debug data directory of type <code class="docutils literal notranslate"><span class="pre">IMAGE_DEBUG_TYPE_OMAP_FROM_SRC</span></code>.  This
is used for mapping addresses between instrumented and uninstrumented code.</p>
<p><strong>Section Header Data</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[5]</span></code>.  A dump of all section headers from
the original executable.</p>
<p><strong>Token / RID Map</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[6]</span></code>.  The layout of this stream is not
understood, but it is assumed to be a mapping from <code class="docutils literal notranslate"><span class="pre">CLR</span> <span class="pre">Token</span></code> to
<code class="docutils literal notranslate"><span class="pre">CLR</span> <span class="pre">Record</span> <span class="pre">ID</span></code>.  Refer to <a class="reference external" href="http://www.ecma-international.org/publications/standards/Ecma-335.htm">ECMA 335</a>
for more information.</p>
<p><strong>Xdata</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[7]</span></code>.  A copy of the <code class="docutils literal notranslate"><span class="pre">.xdata</span></code> section from the
executable.</p>
<p><strong>Pdata</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[8]</span></code>. This is assumed to be a copy of the <code class="docutils literal notranslate"><span class="pre">.pdata</span></code>
section from the executable, but that would make it identical to
<code class="docutils literal notranslate"><span class="pre">DbgStreamArray[1]</span></code>.  The difference between these two indices is not well
understood.</p>
<p><strong>New FPO Data</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[9]</span></code>.  The data in the referenced stream is a
debug data directory of type <code class="docutils literal notranslate"><span class="pre">IMAGE_DEBUG_TYPE_FPO</span></code>.  Note that this is different
from <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[0]</span></code> in that <code class="docutils literal notranslate"><span class="pre">.debug$F</span></code> sections are only emitted by MASM.
Thus, it is possible for both to appear in the same PDB if both MASM object files
and cl object files are linked into the same program.</p>
<p><strong>Original Section Header Data</strong> - <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[10]</span></code>.  Similar to
<code class="docutils literal notranslate"><span class="pre">DbgStreamArray[5]</span></code>, but contains the section headers before any binary translation
has been performed.  This can be used in conjunction with <code class="docutils literal notranslate"><span class="pre">DebugStreamArray[3]</span></code>
and <code class="docutils literal notranslate"><span class="pre">DbgStreamArray[4]</span></code> to map instrumented and uninstrumented addresses.</p>
</div>
</div>
</div>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="ModiStream.html" title="The Module Information Stream"
             >next</a> |</li>
        <li class="right" >
          <a href="TpiStream.html" title="The PDB TPI and IPI Streams"
             >previous</a> |</li>
  <li><a href="https://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="../Reference.html" >Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" >The PDB File Format</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">The PDB DBI (Debug Info) Stream</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2003-2021, LLVM Project.
      Last updated on 2021-09-18.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.5.4.
    </div>
  </body>
</html>