rainers / cv2pdb

converter of DMD CodeView/DWARF debug information to PDB files
Artistic License 2.0
466 stars 110 forks source link

What files from VisualStudio are strictly required for cv2pdb to run? #74

Closed videoerror closed 2 years ago

videoerror commented 2 years ago

Hi,

I'm developing a C application that needs to display a stacktrace to the user when the application crashes. I'm using MinGW and I don't want to use a MSVC toolchain to build my application. So I'm looking to integrate cv2pdb into my build process so I can generate a PDB file that will work with standard Win32 stacktracing calls. However, it seems cv2pdb needs VisualStudio to be installed for it to generate PDB files. Upon closer inspection of the source, I see it seems to only rely on "mspdbXYZ.dll" where XYZ are some version numbers. I don't want to install VisualStudio on my main development workstation so I installed it in a Windows 10 VM. I then located the mspdb dll (In my case it was mspdb140.dll) and dumped it my cv2pdb folder located on my host machine, not the VM. I then tried to generate a pdb file by running: "cv2pdb.exe test.exe" where test.exe is located in the same folder as cv2pdb, is a valid PE image compiled with MinGW-w64, and contains DWARF4 debugging information via the GCC flags: "-gdwarf -dwarf-4 -g3". Some of the mspdb140 dlls work, and others do not. There are a total of 6 of them in my Windows 10 VM Visual Studio 2022 install directory, some were duplicates, some weren't but only a couple are recognized by cv2pdb. Of the ones that are recognized by cv2pdb, It simply fails with "cannot create PDB file". How can I fix this error? What does cv2pdb need from Visual Studio for it to generate a pdb file? I want to use cv2pdb without VisualStudio by copying the required dependencies. I should note that on the Windows 10 VM, most confusingly it works some of the time, but not when i place the DLLs directly into a cv2pdb folder on the machine. On my host machine, it never works. It either fails with a pdb generation error or a dll helper dll error.

rainers commented 2 years ago

Some of the mspdb140 dlls work, and others do not.

I guess that depends on the architecture they are compiled for, x86 or x64.

What does cv2pdb need from Visual Studio for it to generate a pdb file?

mspdb.dll usually starts mspdbsrv.exe that needs a couple more DLLs, e.g. mspdbcore.dll and msobj.dll.

If you are looking for a redistributable PDB generation, you might want to check the LLVM source as it can write PDB files without any dependencies to MS DLLs.

videoerror commented 2 years ago

Thanks! That helped me fix my issue. I already suspected the architecture had something to do with some DLLs being found but thanks for confirming. I now have a working portable version of cv2pdb which will be useful for me working on new machines without having to install Visual Studio. For any interested parties, the only files I needed were the x86 versions of:

For me, these files were located in: <drive_letter>:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\<MSVC_version>\bin\Hostx86\x86\ However, your path may vary slightly based upon what edition and version of Visual Studio you installed. I installed Visual Studio 2022 Community Edition. Hopefully that still gives anyone who has the same issue as I do a good idea of what and where to look for these files.

In any case, thank you rainers for taking the time. I appreciate it, this is a really helpful project.