简体   繁体   中英

Debugging cross-compiled code: Linux->Windows

I'm cross-compiling a project from Linux to target Windows (using mingw). The output is a DLL and p-invoking into it from C# works, but debugging is very difficult. The build outputs ao 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?

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

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM