rainers / cv2pdb

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

Various improvements for Ada #24

Closed pmderodat closed 6 years ago

pmderodat commented 6 years ago

Hello,

At @Adacore, we have started to use cv2pdb to translate GCC’s DWARF output for Ada into PDB/CodeView. We found several bugs, which we tried to fix (for instance array size computation with non-zero low bound index), and also several kinds of types for which we could add translation (for instance enumeration types).

Do you think these changes can be merged? For the record, we tested them by hand on several Ada examples, and are currently trying to develop an automated testsuite, probably based on Microsoft’s CDB command-line debugger. However we haven’t checked the effect on D programs.

Thank you in advance for having a look! :-)

pmderodat commented 6 years ago

I hope it’s for the better, indeed. ;-) Thank you for your review! I’ve just pushed modified commits following it. As I’ve done some work since yesterday, I also added a couple of commits on top of it.

I’m curious: do you know which languages/compilers have users that rely on cv2pdb? As for D, so if I understand correctly, DMD/LDC already generate CodeView info in various PE sections, and so in this context, cv2pdb’s only job is to extract this info to store it as a PDB file, right?

pmderodat commented 6 years ago

(I just edited the last commit as more testing revealed a memory corruption… sorry about this! Hopefully automated testing will prevent this kind of mistake…)

rainers commented 6 years ago

do you know which languages/compilers have users that rely on cv2pdb?

It seems used by a number of people with mingw and C++ and Haskell. IIRC it has also has been considered with Rust (before LLVM got CodeView support).

As for D, so if I understand correctly, DMD/LDC already generate CodeView info in various PE sections, and so in this context, cv2pdb’s only job is to extract this info to store it as a PDB file, right?

No, DMD and LDC can generate COFF object files with embedded CodeView information that the MS linker can extract and combine to generate the PDB file. cv2pdb is still used for DMD's ancient additional tool chain based on OMF object files and the Digital Mars linker. dmd/optlink emit CodeView 4 debug info which is not well supported by current debuggers and needs to be converted to something more recent.

pmderodat commented 6 years ago

That’s interesting. Thank you for the explanation!

pmderodat commented 6 years ago

Alright, so I’ve added a PDB corruption fix on top of the stack of fixes, plus the small fix (and then a typo fix…) mentionned in review. I think I’ll stop here, sorry if the back-and-forth complexified your review. :-)

rainers commented 6 years ago

I see a nice improvement for enums in the little test case that I have, but can't really test it a lot as my small test suite already fails with current master, so I'm going to merge this. I'll fix up a few signed/unsigned warnings regarding -1u after that changing it to ~0.

Thanks a lot for your contribution.

pmderodat commented 6 years ago

Great, thank you very much for your review and merge!