开发者

Debugging cross-compiled code: Linux->Windows

I'm cross-compiling a project from Linux to t开发者_运维问答arget Windows (using mingw). The output is a DLL and p-invoking into it from C# works, but debugging is very difficult. The build outputs a .o file, which can provide symbols to gdb, but basically all I can do there is break on exceptions and find the name of the function that was executing when the exception happened; not even the full stack trace. I can't debug with WinDbg because I don't have .pdb files.

This is an open source project set up to build on Linux; I believe their build process relies on several installed Linux packages to work.

Do I have any options here? Is there a utility that can convert .o files into .pdb? Or some program that can give me more information than gdb when debugging?


Try a IDE that support mingw. For example the open source Code::blocks.


Another possibility is to do it manually: compile it with debug symbols, start you application and attach the GDB debugger to it. It is also part of the MingW32 distribution. Then you can set your breakpoints and debug your application

But I guess using Code::Block is more comfortable

By the way, the GCC compiler does not generate pdb files because it is a propietary format


What xpol means is maybe: if you have a complete mingw installation then Code::blocks can use gdb to visualize a debugging session like it is done in Visual Studio or Eclipse. See chapter "Debugger" at http://www.codeblocks.org/features


You can generate a .pdb file using cv2pdb.exe from Visual D. This works even for programs not written in D if they were compiled with mingw. Once you've downloaded and installed Visual D cv2pdb.exe can be found at C:\Program Files (x86)\VisualD\cv2pdb\cv2pdb.exe.

You can run cv2pdb.exe against an executable like this:

cv2pdb.exe -n target.exe

This will produce a file called target.pdb. Assuming both target.pdb and target.exe are in the current director, you can then use windbg like this:

windbg -sflags 0x80030377 -y . -z target.dmp

In this case I'm also passing a minidump file as target.dmp. This can be omitted. The -sflags 0x80030377 option tells windbg to load target.pdb even though it thinks it doesn't match target.exe.

Note, that it can take windbg a very long time to load target.pdb. Just wait until it no longer says *BUSY* to the left of the command entry box.

Alternatively you can try DrMinGW.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜