{"id":7481,"date":"2016-02-08T20:27:37","date_gmt":"2016-02-08T20:27:37","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=7481"},"modified":"2019-02-18T18:04:50","modified_gmt":"2019-02-18T18:04:50","slug":"whats-inside-a-pdb-file","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/whats-inside-a-pdb-file\/","title":{"rendered":"What&#039;s inside a PDB File?"},"content":{"rendered":"<h2>Background<\/h2>\n<p>We have all used the Visual Studio Debugger to step through code, in the hunt for\u00a0bugs.\u00a0 For C or C++ code, that Debugger relies upon a file, with\u00a0the extension &#8220;.pdb&#8221;, called the &#8220;Program DataBase&#8221;, or simply &#8220;the PDB&#8221;.\u00a0 The PDB is written by the Linker when you build your program; it contains\u00a0line-number and symbols information.\nBut what lies\u00a0inside these PDBs, exactly?\nMost C\/C++ developers need never worry about the answer. \u00a0But for those few, working\u00a0on tools such compilers, linkers, analyzers and verifiers, knowing the details can be useful.\u00a0 Especially where you want these\u00a0tools to work within the broader\u00a0Windows <em>ecosystem:<\/em> for example, enabling your own compiler to write PDBs so that Apps, built with your compiler, can be executed under existing Windows debuggers.\nTo answer the needs of those few, and\/or for readers who are simply interested, we\u00a0have recently\u00a0created a GitHub repo where you can browse the actual Linker code that creates PDBs.<\/p>\n<h2>Prior\u00a0APIs and Documentation<\/h2>\n<p>We have published outline information on PDB content\u00a0in years past.\u00a0 This includes an\u00a0API for reading and writing PDBs.\u00a0 For example:<\/p>\n<ul>\n<li>Description of PDB files: <a title=\"\u2022https:\/\/support.microsoft.com\/en-us\/kb\/121366\" href=\"https:\/\/support.microsoft.com\/en-us\/kb\/121366\">https:\/\/support.microsoft.com\/en-us\/kb\/121366<\/a><\/li>\n<li>Querying the PDB: <a title=\"https:\/\/msdn.microsoft.com\/en-us\/library\/eee38t3h.aspx\" href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/eee38t3h.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/eee38t3h.aspx<\/a><\/li>\n<li>Debug Interface Access SDK: <a title=\"https:\/\/msdn.microsoft.com\/en-us\/library\/x93ctkx8(VS.80).aspx\" href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/x93ctkx8(VS.80).aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/x93ctkx8(VS.80).aspx<\/a><\/li>\n<\/ul>\n<p>If you want to read or write PDBs on Windows, we strongly recommend you use the already-published APIs.\u00a0 This abstracts away the nitty-gritty details and gets the job done.\u00a0\u00a0 However, for those who want to dig deeper . . .<\/p>\n<h2>Source Code<\/h2>\n<p>Please browse the content in the GitHub repo at: <a title=\"https:\/\/github.com\/Microsoft\/microsoft-pdb\" href=\"https:\/\/github.com\/Microsoft\/microsoft-pdb\"><span style=\"color: #0000ff\">https:\/\/github.com\/Microsoft\/microsoft-pdb<\/span><\/a>\nThe repo includes 7 folders.\u00a0 A good place to start your exploration would be in \/cvdump.\u00a0 This holds\u00a0.h and .cpp files for a tool that dumps\u00a0the contents of a PDB.\nLook for other useful header files in the folders \/include and \/langapi\/include.\u00a0 Whilst\u00a0\/pdbtest\u00a0holds a small .cpp file that sanity-checks a PDB.\nFinally, the docs folder provides a list of links to related information.\nNote that the repo does not\u00a0include build files, so the intention is that you can browse the code to help understand the PDB. \u00a0Note too that the code is published under the liberal <a title=\"MIT License\" href=\"https:\/\/opensource.org\/licenses\/MIT\">MIT License<\/a>.<\/p>\n<h2>Next?<\/h2>\n<p>We will try to keep this\u00a0GitHub repo up-to-date with any changes in PDB formats.\u00a0 The format is long-established, so ongoing changes are infrequent, and usually small.\nThe PDB format is complicated.\u00a0 We&#8217;re not sure whether the files uploaded so far provide all the details you might need.\u00a0 If you have brief questions, please post them as comments to this blog. \u00a0But for issues (eg: I need to view the header that defines the XXX struct), please file them directly on the GitHub project so we can track and respond.\nThe link, once again: <a title=\"https:\/\/github.com\/Microsoft\/microsoft-pdb\" href=\"https:\/\/github.com\/Microsoft\/microsoft-pdb\"><span style=\"color: #0000ff\">https:\/\/github.com\/Microsoft\/microsoft-pdb<\/span><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Background We have all used the Visual Studio Debugger to step through code, in the hunt for\u00a0bugs.\u00a0 For C or C++ code, that Debugger relies upon a file, with\u00a0the extension &#8220;.pdb&#8221;, called the &#8220;Program DataBase&#8221;, or simply &#8220;the PDB&#8221;.\u00a0 The PDB is written by the Linker when you build your program; it contains\u00a0line-number and symbols [&hellip;]<\/p>\n","protected":false},"author":271,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[140,65,36],"class_list":["post-7481","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-c","tag-compiler","tag-vc"],"acf":[],"blog_post_summary":"<p>Background We have all used the Visual Studio Debugger to step through code, in the hunt for\u00a0bugs.\u00a0 For C or C++ code, that Debugger relies upon a file, with\u00a0the extension &#8220;.pdb&#8221;, called the &#8220;Program DataBase&#8221;, or simply &#8220;the PDB&#8221;.\u00a0 The PDB is written by the Linker when you build your program; it contains\u00a0line-number and symbols [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/7481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/271"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=7481"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/7481\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=7481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=7481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=7481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}