suszterpatt
suszterpatt

Reputation: 8273

Need help attaching gdb to my project

I use VS2k8 to write and compile (but not run) a program using the MPICH2 libraries on Vista x64. I then use mpiexec from the command line to launch the program (with only 1 process for the purposes of debugging), and I'd like to attach gdb to it. Simply using attach or gdb --pid=### doesn't work (I get the error Can't attach to process), presumably because VS doesn't compile the code with the right debug info. On the other hand, despite several google sessions I have yet to find the actual command line that VS uses to compile, so I can't just go in and edit it.

Note that the only reason I use VS is because I couldn't get g++ to find the MPI libraries when trying to compile from command line, whereas VS only needed a couple clicks to make everything work. (Yes, I tried the -I and -l switches, but to no avail)

All I need is attaching gdb to the process running my MPI program, I don't really care how it's done. Any help is appreciated.

Upvotes: 0

Views: 568

Answers (2)

Nemanja Trifunovic
Nemanja Trifunovic

Reputation: 24561

gdb won't work, but you can use Gflags to make your program run from a debugger (VS, windbg,...) whenever it is launched. There is also a registry option to do that directly: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ImageFileName\Debugger

Upvotes: 2

marshall_law
marshall_law

Reputation: 511

The binary formats of cl.exe (Visual Studio) and gdb are unfortunately incompatible. You won't be able to use gdb for debugging unless you can figure out a way to rebuild the code with gcc. In the meantime, you can debug your program with Visual Studio directly, by going to Tools > Attach to Process (or pressing Ctrl+Alt+P)

Upvotes: 2

Related Questions