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)?
Asked
Active
Viewed 5,071 times
7
-
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 Answers
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

user791139
- 271
- 3
- 4
-
-
See also http://stackoverflow.com/questions/19269350/how-to-generate-pdb-files-while-building-library-using-mingw – rogerdpack Aug 21 '15 at 22:01
-
@SevaAlekseyev Seen this same warning, fixed by compiling `exe` with `-g` flag. – Yuriy Vasylenko Nov 08 '19 at 09:37
-
The compiler was emitting stabs by default, with an option to generate DWARF instead. Once I've fixed that, cv2pdb did a decent job. – Seva Alekseyev Dec 14 '19 at 05:15
-
Some local variables are lost, and the call stack is missing entries. Still, this is semi-workable. – Seva Alekseyev Dec 14 '19 at 14:26
-
I know that this issue is old but is there a way to use this for RAD Studio debug symbols? As far as I know it also uses DWARF symbols. If so, how should I build the exe? – KapitaiN Dec 07 '20 at 10:40