7

Is there a way to convert the debugging information from binutils' DWARF format (as emitted by GCC on Cygwin, for example) to Microsoft PDB (as consumed by Visual Studio)?

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
  • FWIW I have never heard of such a tool -- but of course that doesn't mean it doesn't exist. You could probably write your own by using one of the existing DWARF-reading libraries (I'm partial to `elfutils`) to read the debuginfo and then some other library (I don't know what) to write PDB. – Tom Tromey Mar 20 '15 at 15:04
  • The primary target I'm after is Windows; it has PE executables, not ELF. Still, point taken. – Seva Alekseyev Mar 20 '15 at 17:00
  • Oh right. Well, it's harder then -- there is BFD for reading any sort of object file, but BFD's built-in DWARF-reading capabilities are quite primitive. Still might be more useful than wholly rolling your own. Or you could objcopy to an ELF just to use elfutils to do the DWARF reading -- but then you're into serious hackery :-) – Tom Tromey Mar 20 '15 at 21:34
  • Well, gdb under Cygwin does is somehow :) I've poked around the sources - PE-specific parts are there. – Seva Alekseyev Mar 21 '15 at 17:24
  • GDB uses the BFD library for decoding the file format, like ELF or PE. Sometimes it has some additional things it does itself. However for reading the debuginfo, it has its own DWARF reader, which would be reasonably hard to reuse from some other program. Maybe it would be possible to add some code to gdb to write out PDB. The danger there is that the translation might necessarily be lossy due to gdb's internal symbol representation. – Tom Tromey Mar 21 '15 at 22:10

1 Answers1

12

cv2pdb can do this. I have had mixed results, sometimes it works splendidly while at other times some local and global variables are lost

https://github.com/rainers/cv2pdb

user791139
  • 271
  • 3
  • 4