Creating a C++ Project from a PDB file: PDB Project [[Version 2.0]]

Creating a C++ Project from a PDB file: PDB Project [[Version 2.0]]

Rate This
  • Comments 8

We are thrilled to announce version 2.0 of the PDB Project extension on the Visual Studio Gallery. PDB Project, as the name suggests, takes the information contained in a .pdb file to create a C++ project. The Information extracted from the .pdb includes both the source files (.c, .cpp) used for building, as well as the sources of the linked libraries. The generated project will light up the IDE features including Find all References, GoToDefinition, and IntelliSense operations. One limitation of the current version of the extension is that the generated project cannot be built; so this extension cannot yet replace the build system.

Why Would I Use the PDB Project Extension?

Visual Studio IDE requires a .vcxproj for Browsing and IntelliSense operations. Many of the build systems used today are still based on non-vcxproj designs that are incompatible with Visual Studio. The PDB project extension helps bridge the gap: .pdb files produced from the legacy build can be used to generate .vcxproj files that be opened in Visual Studio to enable power capabilities of the IDE.

How to Use the Extension

The PDB Project Extension is publicly available on the Visual Studio Gallery. If you already have a previous version installed, please uninstall it prior to installing version 2.

Once version 2 is installed, you will be able to open a .pdb file by invoking the File->Open->Project/Solution command. Select a .pdb file you want to convert. A list of source files from the PDB will be displayed. Some files might be automatically resolved, if they are in the same location on the disk. In case there are unresolved files, use the "Folder Mapping" dialog to provide a mapping between the directory that was used when the .pdb was created (e.g. by the build system) and a directory where the sources are stored (e.g. a remote source server). Press "Refresh" to see the results of each directory mapping. After all files are resolved, click "Finish" and select the save file location. The tool will load the newly created project into the current solution.

Watch the demo on Channel 9!

Debugger Integration

Starting with version 2.0, the extension is integrated into the Visual Studio debugger. If you right-click on a row in the Call Stack window during a Visual Studio debug session, you will now have an option to generate a project from the associated .pdb. The generated project will silently be loaded into the current solution, in order to avoid having too many unwanted projects in the solution. This is most useful while debugging unfamiliar code: in a few minutes, you can have complete Browsing and IntelliSense information for every stack frame of the program that you're debugging.

Other Features

Command line tool: In addition to the UI based tool, the latest update has a command line tool which enables users to automate their conversion tasks. To extract the tool, you need to change the file extension from "vsix" to "zip".

Refresh Feature: Whenever the user opens a PDB-generated project, the user will get a prompt to re-generate the project if the .pdb from which it was generated has changed. Also, if you right click in Solution Explorer on a project that was generated from a .pdb, you will see an option to "Refresh PDB project".

Peeking Under the Hood

The PDB loader uses the DIA SDK to extract the information from the PDB. The extraction engine is based on the sample included in the DIA SDK.

The project creator uses MSBuild Construction Model to create the .vcxproj file. Because PDB is an extension, it cannot use the internal APIs of the project system. As a side effect, the project file will be slightly different from a normal .vcxproj file.

One major issue during development, we found Intellisense was about ~20 seconds slower per cpp file. On average, it should take no more than 2-3 seconds. With some investigation, we found that missing header files was causing the Intellisense to ignore using PCH. PCH skips for completeness because once a PCH is created, it only tracks the files used to construct it. Any missing files aren't tracked. When header file would appear later, the PCH would not trigger a refresh. To address slow load, PDB Project will detect missing header files and create a blank dummy file. This will let Intellisense to be fast even when dealing with incomplete projects.

Is PDB Project for everyone?

No. Most VC users would not need this extension. It is targeted for advances users who have non-vcxproj-based project system. Without a project, the IDE cannot provide its rich features. The PDB project will help bridge this gap.

We Want Your Feedback

If you use PDB Project, we would love your feedback. Feel free to post comments to this blog or email Felix, Balaji or Oleg

Thanks!

Felix Huang (yuehuang@microsoft.com), Balaji Thumbavanam Kachapeswaran (bathumba@microsoft.com), Oleg Kharitonov (olegkhar@microsoft.com) and the VC++ team 

  • OT: would it be possible to embed the source code in PDB files? With this information, it would be theoretically possible to generate a buildable, modifiable project. A detailed proposal is present in stackoverflow.com/.../embedding-source-into-pdb-and-having-debuggers-use-it

  • @Dario, this is definitely possible.  In fact, the attributed ATL support does this.  Based on the attributes specified, the compiler injects additional source which is compiled into the binary.  The injected source is also put into the PDB and is available during debugging.  So, the infrastructure is there to do this, but I don't think it is possible with the current tools.  Interesting idea, though.

  • I tried to use pdb project, but when I selected a pdb file, I get an error "Unable to extract any content from [my_pdb].pdb"

    What am I doing wrong?

  • @Jonathan, thanks for your feedback.  I would like to investigate the issue that you're seeing.  Can you please e-mail me the .pdb that you're unable to load?  My e-mail address is olegkhar@microsoft.com.  Thanks!

  • @Oleg, I've emailed you some more info about the pdb, but I'm not sure if I can share the pdb or not, will let you know.

  • Could you do a tutorial for creating a library project that'll build all possible variants (debug/release, dll/lib, etc)?

    Even better, could you improve the VC project templates to make this far easier?

  • I also get an error "unable to extract info". but I did not receive them in 1.5 I uninstalled  2.0 reinstalled 1.5 and the

    pdb were readable again.  I got an msg about an update was available from vs. I installed that way. I did not uninstalled. it did not ask to uninstall 1.5.

  • TO:PUBLIC DOMAIN@BLOGSPOT/VERSION 2.0

    FROM:YAHOOSTRONGERDRIVER@YSD/SUPPORTTEAM

    REFERENCE ID:CAPOTE_CIPRIANO@LIVE.COM

    MICROSOFT.COM ONE ACCOUNT DOMAIN

    PUBLIC NOTICE:

      DEAR,FRIENDS AND OLD ANS NEW COMPANY,WEBSITE FRIENDS AND CONNECTION OUR COMPANY"CIPRIANOSTRONGER.COMPANY"LOCATION ID AND PREFERENCE YAHOO.INC.COM 701 SUITE SUNNYVALE CA 94089 AND SISTER COMPANY MOUNTAIN VIEW 94043 REFERENCE NAME AND EMAIL WEBSITE OWNER WWW.MASTER-CJAMES21ACADEMY.WORLD<YAHOO!PHILIPPINES/TWITTER/FLICKER MAIL/GOOGLE SUPPOR6T/YAHOOSTRONGERDRIVER.COM/YSD

      TO MY DEAREST FRIEND I BLOG THIS MESSAGE MOST IMPORTANT TO RECALL MY COMPANY AND MY ASSOCIATE COMPANY SINCE AUGUST 7,2013 UNTIL THIS PRESENCE JANUARY 27,2014 THE COMPANY OF CIPRIANOJR CAPOTE<CIPRIANOSTRONGER.COM><GOOLYGOLYSPORTS.COM><CJAMES21CAPOTE.MASTER-SUPPORT LIBRARY>THIS THE NEW WEBSITE MANAGEMENT IS HAND BY HAND TO REMAKE THE BADLY PAST AND WE ACKNOWLEDGEMENT MY SUPPORT TEAM IS SERIOUSLY DEACTIVATE THE ACCOUNT WAS LOST TO MY OLDEST FRIENDS AND CONNECTION AND ASSOCIATE MEMBER ON BEHALF OF THE PRESIDENT AND YAHOO MANAGEMENT MARISSA MAYER,...I APOLOGIZE IN PUBLIC BLOG THE PROBLEM OF TOO MUCH CHANGE AND SETTING PORT ACTIVITY AND NETWORK COMPANY...THE YAHOOSTRONGERDRIVER@YSD.TEAM WE TALK AND APOLOGY IN PUBLIC OUR COMPANY TODAY SINCE THIS RENOVATE AND CHANGE THE NEW COMPANY NAME AS:CIPRIANOSTRONGER.COMPANY;SHARER COMPUTER TRUST IPR-INVESTOR PARTNER TO YAHOO.INC AND CIPRIANOSTRONGER.COMPANY AND OWNED BY.MASTER-CJAMES21ACADEMY.WORLD-REAL NAME IS CIPRIANOJR CAPOTE-DEMECILLO<PROPERTY OWNER OF THIS COMPANY>OLD COMPANY 7C'S MARINE PRODUCT INC. YAHOO-LOCAL ADDRESS CEBU CITY,PHILIPPINES 6000 AND CENTRAL VISAYAS REGION 7 AND MSN-LIVE ID<CIPRIANOJRC@HOTMAIL.COM> THIS A NEW ACTIVITY AND INFORMATION ADDRESS AND YOUR INFO.OUR WEBSITE.www.yahoostrongerdriver.com/YSS MY.YAHOO.COM<701 SUNNYVALE CA 94089;SISTER COMPANY MOUNTAIN VIEW 94043-LINK-IN PHILIPPINES AND CJAMES21ACADEMY/YAHOO

Page 1 of 1 (8 items)